summaryrefslogtreecommitdiff
path: root/strings/apr_snprintf.c
diff options
context:
space:
mode:
authorWilliam A. Rowe Jr <wrowe@apache.org>2005-09-03 14:01:49 +0000
committerWilliam A. Rowe Jr <wrowe@apache.org>2005-09-03 14:01:49 +0000
commitb140938bb65543de484e01638789416c8fe36551 (patch)
treeb9990bc06aa735225bc91b5bea21c9dc3da7c224 /strings/apr_snprintf.c
parent0781a27e054e1591b849f94ee33dd436518bc6d8 (diff)
downloadapr-b140938bb65543de484e01638789416c8fe36551.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: https://svn.apache.org/repos/asf/apr/apr/trunk@267459 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'strings/apr_snprintf.c')
-rw-r--r--strings/apr_snprintf.c20
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;