diff options
author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2005-09-03 14:01:49 +0000 |
---|---|---|
committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2005-09-03 14:01:49 +0000 |
commit | 2e48543c83f9784545b21e97bbc8ff113c06142d (patch) | |
tree | b9990bc06aa735225bc91b5bea21c9dc3da7c224 /strings | |
parent | 41ed671f40f8a4cca51f061987f2d5df23332629 (diff) | |
download | libapr-2e48543c83f9784545b21e97bbc8ff113c06142d.tar.gz |
Fix multiple sign'edness issues; for %width.prec variables, neither
is -ever- signed, we pull out -width as a flag, and prec is folded +.
Changing the code only required special handling of %*.* variables,
continuing to read them as int, and preserving the folding of negative
values that's already there.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@267459 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'strings')
-rw-r--r-- | strings/apr_snprintf.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/strings/apr_snprintf.c b/strings/apr_snprintf.c index e903d2d31..bfd941e35 100644 --- a/strings/apr_snprintf.c +++ b/strings/apr_snprintf.c @@ -290,7 +290,8 @@ static char *apr_gcvt(double number, int ndigit, char *buf, boolean_e altform) */ #define FIX_PRECISION(adjust, precision, s, s_len) \ if (adjust) { \ - int p = precision < NUM_BUF_SIZE - 1 ? precision : NUM_BUF_SIZE - 1; \ + apr_size_t p = (precision + 1 < NUM_BUF_SIZE) \ + ? precision : NUM_BUF_SIZE - 1; \ while (s_len < p) \ { \ *--s = '0'; \ @@ -703,8 +704,8 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), char *q; apr_size_t s_len; - register int min_width = 0; - int precision = 0; + register apr_size_t min_width = 0; + apr_size_t precision = 0; enum { LEFT, RIGHT } adjust; @@ -784,13 +785,15 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), adjust_width = YES; } else if (*fmt == '*') { - min_width = va_arg(ap, int); + int v = va_arg(ap, int); fmt++; adjust_width = YES; - if (min_width < 0) { + if (v < 0) { adjust = LEFT; - min_width = -min_width; + min_width = (apr_size_t)(-v); } + else + min_width = (apr_size_t)v; } else adjust_width = NO; @@ -805,10 +808,9 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *), STR_TO_DEC(fmt, precision); } else if (*fmt == '*') { - precision = va_arg(ap, int); + int v = va_arg(ap, int); fmt++; - if (precision < 0) - precision = 0; + precision = (v < 0) ? 0 : (apr_size_t)v; } else precision = 0; |