diff options
author | wlemb <wlemb> | 2004-04-19 20:19:43 +0000 |
---|---|---|
committer | wlemb <wlemb> | 2004-04-19 20:19:43 +0000 |
commit | d7ea5c964dc134244c05077f0e3059252470697d (patch) | |
tree | a218d80f5e4d19567909db6d5982a67d1d2723ad | |
parent | 85ef3aadf1f6f6a359d524543856fa9c799d2044 (diff) | |
download | groff-d7ea5c964dc134244c05077f0e3059252470697d.tar.gz |
* device.c (scale_round): Round correctly for negative values
(this is the same function as in src/libs/libgroff/font.c).
Found by Paul Eggert.
-rw-r--r-- | src/xditview/ChangeLog | 8 | ||||
-rw-r--r-- | src/xditview/device.c | 7 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/xditview/ChangeLog b/src/xditview/ChangeLog index 2d00ac7e..b82a3e7e 100644 --- a/src/xditview/ChangeLog +++ b/src/xditview/ChangeLog @@ -1,6 +1,12 @@ +2004-04-17 Werner LEMBERG <wl@gnu.org> + + * device.c (scale_round): Round correctly for negative values + (this is the same function as in src/libs/libgroff/font.c). + Found by Paul Eggert. + 2003-11-10 Werner LEMBERG <wl@gnu.org> - * doc/Makefile.in: s/@top_srcdir@/@abs_top_srcdir@/, + * Imakefile.in: s/@top_srcdir@/@abs_top_srcdir@/, s/@groff_top_builddir@/@abs_top_builddir@/. Version 1.19 released diff --git a/src/xditview/device.c b/src/xditview/device.c index 0716bbdb..88e5ae5e 100644 --- a/src/xditview/device.c +++ b/src/xditview/device.c @@ -305,10 +305,13 @@ int scale_round(n, x, y) if (n >= 0) { if (n <= (INT_MAX - y2)/x) return (n*x + y2)/y; + return (int)(n*(double)x/(double)y + .5); } - else if (-(unsigned)n <= (-(unsigned)INT_MIN - y2)/x) + else { + if (-(unsigned)n <= (-(unsigned)INT_MIN - y2)/x) return (n*x - y2)/y; - return (int)(n*(double)x/(double)y + .5); + return (int)(n*(double)x/(double)y + .5); + } } static |