apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@gmail.com>
Subject Re: [PATCH] %lld support in apr_snprintf()
Date Sun, 07 Nov 2010 23:36:00 GMT
On Sun, Nov 7, 2010 at 5:18 PM, Jeff Trawick <trawick@gmail.com> wrote:
> On Sun, Nov 7, 2010 at 5:07 PM, Sander Temme <sander@temme.net> wrote:
>>
>> On Nov 4, 2010, at 12:15 PM, William A. Rowe Jr. wrote:
>>
>>> Looks good here.
>>
>> If folks find this unproblematic, can someone please commit it?  I don't have karma
here.
>>
>> Thanks,
>
> looks fine to me; starting to try it out now

The patch is apparently not needed to make %lld work in 32-bit mode on
Leopard since APR_INT64_T_FMT is %lld.
It didn't make %lld work in 64-bit mode.

What are the cases where you see this help out?

I guess you're on Snow Leopard?

Here's what I tried in 64-bit mode:

Index: strings/apr_snprintf.c
===================================================================
--- strings/apr_snprintf.c	(revision 1032408)
+++ strings/apr_snprintf.c	(working copy)
@@ -832,6 +832,11 @@
             else if (*fmt == 'l') {
                 var_type = IS_LONG;
                 fmt++;
+                /* Catch the %lld type modifier for long long and its ilk */
+                if (*fmt == 'l') {
+                    var_type = IS_QUAD;
+                    fmt++;
+                }
             }
             else if (*fmt == 'h') {
                 var_type = IS_SHORT;


ndex: testfmt.c
===================================================================
--- testfmt.c	(revision 1032408)
+++ testfmt.c	(working copy)
@@ -126,6 +126,9 @@

     apr_snprintf(buf, sizeof buf, "%" APR_INT64_T_FMT, ibig);
     ABTS_STR_EQUAL(tc, "-314159265358979323", buf);
+
+    apr_snprintf(buf, sizeof buf, "%lld", ibig);
+    ABTS_STR_EQUAL(tc, "-314159265358979323", buf);
 }

 static void error_fmt(abts_case *tc, void *data)

./testall -v testfmt
testfmt             : /Line 131: expected <-314159265358979323>, but saw <%ld>
FAILED 1 of 10
Failed Tests   		Total	Fail	Failed %
===================================================
testfmt        		   10	   1	 10.00%

Mime
View raw message