summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-08-01 19:38:29 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-08-01 19:38:29 +0000
commit41b01a2448e5d5de474613c0bf5aff6cfcb30316 (patch)
tree3a91d91e1f4f94e0b9068f8f1b399f8b1fb433c9
parenta4156c97a7eaea0360abdbc488f740cc4ad6f79f (diff)
downloadmandoc-41b01a2448e5d5de474613c0bf5aff6cfcb30316.tar.gz
Fix floating point handling: When converting double to size_t,
properly round to the nearest M (=0.001m), which is the smallest available unit. This avoids weirdness like (size_t)(0.6 * 10.0) == 5 by instead calculating (size_t)(0.6 * 10.0 + 0.0005) == 6, and so it fixes the indentation of the readline(3) manual.
-rw-r--r--term.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/term.c b/term.c
index 7e5c05eb..22fdf818 100644
--- a/term.c
+++ b/term.c
@@ -793,7 +793,7 @@ term_vspan(const struct termp *p, const struct roffsu *su)
if (r < 0.0)
r = 0.0;
- return((size_t)r);
+ return((size_t)(r + 0.0005));
}
size_t
@@ -804,5 +804,5 @@ term_hspan(const struct termp *p, const struct roffsu *su)
v = (*p->hspan)(p, su);
if (v < 0.0)
v = 0.0;
- return((size_t)v);
+ return((size_t)(v + 0.0005));
}