apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject cvs commit: apr/strings apr_snprintf.c
Date Sun, 04 Apr 2004 11:50:18 GMT
jorton      2004/04/04 04:50:18

  Modified:    test     testfmt.c
               strings  apr_snprintf.c
  Log:
  * string/apr_snprintf.c (conv_10_quad): Fix formatting of integers
  smaller than LONG_MIN.
  
  * test/testfmt.c (more_int64_fmts): Add regression test.
  
  Revision  Changes    Path
  1.14      +4 -0      apr/test/testfmt.c
  
  Index: testfmt.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testfmt.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -w -d -u -r1.13 -r1.14
  --- testfmt.c	13 Feb 2004 09:38:34 -0000	1.13
  +++ testfmt.c	4 Apr 2004 11:50:17 -0000	1.14
  @@ -99,6 +99,7 @@
   {
       char buf[100];
       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);
   
  @@ -110,6 +111,9 @@
   
       apr_snprintf(buf, sizeof buf, "%" APR_UINT64_T_FMT, big);
       CuAssertStrEquals(tc, buf, "3141592653589793238");
  +
  +    apr_snprintf(buf, sizeof buf, "%" APR_INT64_T_FMT, ibig);
  +    CuAssertStrEquals(tc, buf, "-314159265358979323");
   }
   
   CuSuite *testfmt(void)
  
  
  
  1.38      +2 -1      apr/strings/apr_snprintf.c
  
  Index: apr_snprintf.c
  ===================================================================
  RCS file: /home/cvs/apr/strings/apr_snprintf.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -w -d -u -r1.37 -r1.38
  --- apr_snprintf.c	13 Feb 2004 09:38:34 -0000	1.37
  +++ apr_snprintf.c	4 Apr 2004 11:50:17 -0000	1.38
  @@ -393,7 +393,8 @@
        * number against the largest long value it can be. If <=, we
        * punt to the quicker version.
        */
  -    if ((num <= ULONG_MAX && is_unsigned) || (num <= LONG_MAX &&
!is_unsigned))
  +    if ((num <= 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));
   
  
  
  

Mime
View raw message