You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by ji...@apache.org on 2011/01/17 22:38:17 UTC

svn commit: r1060106 - /apr/apr/branches/1.4.x/strings/apr_snprintf.c

Author: jim
Date: Mon Jan 17 21:38:17 2011
New Revision: 1060106

URL: http://svn.apache.org/viewvc?rev=1060106&view=rev
Log:
Fix cases where off_t (and APR_OFF_T_FMT) may be "larger" than
int64 (and APR_INT64_T_FMT).


Modified:
    apr/apr/branches/1.4.x/strings/apr_snprintf.c

Modified: apr/apr/branches/1.4.x/strings/apr_snprintf.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/strings/apr_snprintf.c?rev=1060106&r1=1060105&r2=1060106&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/strings/apr_snprintf.c (original)
+++ apr/apr/branches/1.4.x/strings/apr_snprintf.c Mon Jan 17 21:38:17 2011
@@ -810,10 +810,27 @@ APR_DECLARE(int) apr_vformatter(int (*fl
                 adjust_precision = adjust_width = NO;
 
             /*
-             * Modifier check.  Note that if APR_INT64_T_FMT is "d",
-             * the first if condition is never true.
+             * Modifier check.  In same cases, APR_OFF_T_FMT can be
+             * "lld" and APR_INT64_T_FMT can be "ld" (that is, off_t is
+             * "larger" than int64). Check that case 1st.
+             * Note that if APR_OFF_T_FMT is "d",
+             * the first if condition is never true. If APR_INT64_T_FMT
+             * is "d' then the second if condition is never true.
              */
-            if ((sizeof(APR_INT64_T_FMT) == 4 &&
+            if ((sizeof(APR_OFF_T_FMT) > sizeof(APR_INT64_T_FMT)) &&
+                (sizeof(APR_OFF_T_FMT) == 4 &&
+                 fmt[0] == APR_OFF_T_FMT[0] &&
+                 fmt[1] == APR_OFF_T_FMT[1]) ||
+                (sizeof(APR_OFF_T_FMT) == 3 &&
+                 fmt[0] == APR_OFF_T_FMT[0]) ||
+                (sizeof(APR_OFF_T_FMT) > 4 &&
+                 strncmp(fmt, APR_OFF_T_FMT, 
+                         sizeof(APR_OFF_T_FMT) - 2) == 0)) {
+                /* Need to account for trailing 'd' and null in sizeof() */
+                var_type = IS_QUAD;
+                fmt += (sizeof(APR_OFF_T_FMT) - 2);
+            }
+            else if ((sizeof(APR_INT64_T_FMT) == 4 &&
                  fmt[0] == APR_INT64_T_FMT[0] &&
                  fmt[1] == APR_INT64_T_FMT[1]) ||
                 (sizeof(APR_INT64_T_FMT) == 3 &&