diff options
author | 2014-08-08 16:02:55 +0000 | |
---|---|---|
committer | 2014-08-08 16:02:55 +0000 | |
commit | 7c776b600a048be404ca8331f99c5efc3fc211f0 (patch) | |
tree | 4cd0bd6c47ac6cbb2b2684fa8173d465ace15ffe | |
parent | add bochs and microsoft emulated vga (diff) | |
download | wireguard-openbsd-7c776b600a048be404ca8331f99c5efc3fc211f0.tar.xz wireguard-openbsd-7c776b600a048be404ca8331f99c5efc3fc211f0.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.
-rw-r--r-- | usr.bin/mandoc/term.c | 6 |
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)); } |