summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-08-08 16:02:56 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-08-08 16:02:56 +0000
commit11708299de44a688048aba378b955f93e44489b4 (patch)
tree567f8ea7bd73ff0baa1831c0d13ef3488782a561 /usr.bin/mandoc/term.c
parent251e85d6ae3b09a1672d15f649f21772c7474fba (diff)
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.
Diffstat (limited to 'usr.bin/mandoc/term.c')
-rw-r--r--usr.bin/mandoc/term.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index fc8743ed3c6..8a27aea0f35 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.86 2014/08/08 16:00:23 schwarze Exp $ */
+/* $Id: term.c,v 1.87 2014/08/08 16:02:55 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -789,7 +789,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
@@ -800,5 +800,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));
}