aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term.c
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
commitbf5632c30654b3560633b58019d13b37260ca137 (patch)
treec47680f784796924fc36b55ddd524d679fde1be2 /term.c
parent7f0ffae23166177e2bf9143942da3b5d722ab016 (diff)
downloadmandoc-bf5632c30654b3560633b58019d13b37260ca137.tar.gz
mandoc-bf5632c30654b3560633b58019d13b37260ca137.tar.zst
mandoc-bf5632c30654b3560633b58019d13b37260ca137.zip
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 'term.c')
-rw-r--r--term.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/term.c b/term.c
index 3a8fddda..4d50856a 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.225 2014/08/01 19:25:52 schwarze Exp $ */
+/* $Id: term.c,v 1.226 2014/08/01 19:38:29 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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));
}