diff options
author | Colin Watson <cjwatson@debian.org> | 2018-08-24 12:49:36 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2018-08-30 00:57:27 +0100 |
commit | 816386e17654ca36834bebbf351419e460fad8f6 (patch) | |
tree | 3dc79d831cb73bc25b92f5a4d18f8e328c0c570a /openbsd-compat/fmt_scaled.c | |
parent | 3e6f76c7039d3df22b1d0a3a5f30150efb09b69d (diff) | |
parent | 16a47fc4b04977a14f44dd433c8da1499fa80671 (diff) |
New upstream release (7.8p1)
Closes: #907534
Diffstat (limited to 'openbsd-compat/fmt_scaled.c')
-rw-r--r-- | openbsd-compat/fmt_scaled.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/openbsd-compat/fmt_scaled.c b/openbsd-compat/fmt_scaled.c index 7c5193e26..2f76ef931 100644 --- a/openbsd-compat/fmt_scaled.c +++ b/openbsd-compat/fmt_scaled.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: fmt_scaled.c,v 1.16 2017/03/16 02:40:46 dtucker Exp $ */ | 1 | /* $OpenBSD: fmt_scaled.c,v 1.17 2018/05/14 04:39:04 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved. | 4 | * Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved. |
@@ -188,7 +188,7 @@ scan_scaled(char *scaled, long long *result) | |||
188 | /* scale whole part */ | 188 | /* scale whole part */ |
189 | whole *= scale_fact; | 189 | whole *= scale_fact; |
190 | 190 | ||
191 | /* truncate fpart so it does't overflow. | 191 | /* truncate fpart so it doesn't overflow. |
192 | * then scale fractional part. | 192 | * then scale fractional part. |
193 | */ | 193 | */ |
194 | while (fpart >= LLONG_MAX / scale_fact) { | 194 | while (fpart >= LLONG_MAX / scale_fact) { |
@@ -246,12 +246,15 @@ fmt_scaled(long long number, char *result) | |||
246 | 246 | ||
247 | fract = (10 * fract + 512) / 1024; | 247 | fract = (10 * fract + 512) / 1024; |
248 | /* if the result would be >= 10, round main number */ | 248 | /* if the result would be >= 10, round main number */ |
249 | if (fract == 10) { | 249 | if (fract >= 10) { |
250 | if (number >= 0) | 250 | if (number >= 0) |
251 | number++; | 251 | number++; |
252 | else | 252 | else |
253 | number--; | 253 | number--; |
254 | fract = 0; | 254 | fract = 0; |
255 | } else if (fract < 0) { | ||
256 | /* shouldn't happen */ | ||
257 | fract = 0; | ||
255 | } | 258 | } |
256 | 259 | ||
257 | if (number == 0) | 260 | if (number == 0) |