diff options
author | Joe Orton <jorton@apache.org> | 2007-04-26 13:10:34 +0000 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2007-04-26 13:10:34 +0000 |
commit | 9c9da2e0a35a67e50aaaf37419ec0dc77d8b45fa (patch) | |
tree | 498c947055be8b5825850d1997a950c4273f8180 | |
parent | fe21f4eebaea06db06cbfd2f40abdb4a33e890d0 (diff) | |
download | apr-9c9da2e0a35a67e50aaaf37419ec0dc77d8b45fa.tar.gz |
* strings/apr_snprintf.c (conv_10_quad): Fix formatting of unsigned
integers between 2^63 and 2^64 on 32-bit platforms.
* test/testfmt.c (more_int64_fmts): Test an even bigger unsigned
int64.
Submitted by: Wynn Wilkes <wynn bungeelabs.com>
PR: 42250
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@532733 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | strings/apr_snprintf.c | 2 | ||||
-rw-r--r-- | test/testfmt.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/strings/apr_snprintf.c b/strings/apr_snprintf.c index 7ad741100..a8b5db593 100644 --- a/strings/apr_snprintf.c +++ b/strings/apr_snprintf.c @@ -397,7 +397,7 @@ static char *conv_10_quad(widest_int num, register bool_int is_unsigned, * number against the largest long value it can be. If <=, we * punt to the quicker version. */ - if ((num <= ULONG_MAX && is_unsigned) + if (((u_widest_int)num <= (u_widest_int)ULONG_MAX && is_unsigned) || (num <= LONG_MAX && num >= LONG_MIN && !is_unsigned)) return(conv_10( (wide_int)num, is_unsigned, is_negative, buf_end, len)); diff --git a/test/testfmt.c b/test/testfmt.c index 30b6155d5..d06726a68 100644 --- a/test/testfmt.c +++ b/test/testfmt.c @@ -102,7 +102,7 @@ static void more_int64_fmts(abts_case *tc, void *data) apr_int64_t i = APR_INT64_C(-42); apr_int64_t ibig = APR_INT64_C(-314159265358979323); apr_uint64_t ui = APR_UINT64_C(42); - apr_uint64_t big = APR_UINT64_C(3141592653589793238); + apr_uint64_t big = APR_UINT64_C(10267677267010969076); apr_snprintf(buf, sizeof buf, "%" APR_INT64_T_FMT, i); ABTS_STR_EQUAL(tc, buf, "-42"); @@ -111,7 +111,7 @@ static void more_int64_fmts(abts_case *tc, void *data) ABTS_STR_EQUAL(tc, buf, "42"); apr_snprintf(buf, sizeof buf, "%" APR_UINT64_T_FMT, big); - ABTS_STR_EQUAL(tc, buf, "3141592653589793238"); + ABTS_STR_EQUAL(tc, "10267677267010969076", buf); apr_snprintf(buf, sizeof buf, "%" APR_INT64_T_FMT, ibig); ABTS_STR_EQUAL(tc, buf, "-314159265358979323"); |