Handle the particular PRIdMAX values on MacOS X and mingw.
authorBruno Haible <bruno@clisp.org>
Wed, 9 Jan 2008 01:15:36 +0000 (02:15 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 9 Jan 2008 01:15:36 +0000 (02:15 +0100)
ChangeLog
lib/printf-parse.c

index 9cdc779..be8067f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-01-08  Jim Meyering  <meyering@redhat.com>
+            Bruno Haible  <bruno@clisp.org>
+
+       * lib/printf-parse.c (PRINTF_PARSE): Handle a size specifier "q"
+       on MacOS X and a size specifier "I64" on mingw. Needed for PRIdMAX.
+       Reported by Peter Fales in
+       <http://lists.gnu.org/archive/html/bug-coreutils/2007-12/msg00148.html>.
+
 2008-01-08  Bruno Haible  <bruno@clisp.org>
 
        * modules/unictype/category-of (Depends-on): Add
index e3aa95a..b11f6bb 100644 (file)
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 1999-2000, 2002-2003, 2006-2007 Free Software Foundation, Inc.
+   Copyright (C) 1999-2000, 2002-2003, 2006-2008 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -392,6 +392,44 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
                        }
                      cp++;
                    }
+#if defined __APPLE__ && defined __MACH__
+                 /* On MacOS X 10.3, PRIdMAX is defined as "qd".
+                    We cannot change it to "lld" because PRIdMAX must also
+                    be understood by the system's printf routines.  */
+                 else if (*cp == 'q')
+                   {
+                     if (64 / 8 > sizeof (long))
+                       {
+                         /* int64_t = long long */
+                         flags += 16;
+                       }
+                     else
+                       {
+                         /* int64_t = long */
+                         flags += 8;
+                       }
+                     cp++;
+                   }
+#endif
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+                 /* On native Win32, PRIdMAX is defined as "I64d".
+                    We cannot change it to "lld" because PRIdMAX must also
+                    be understood by the system's printf routines.  */
+                 else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
+                   {
+                     if (64 / 8 > sizeof (long))
+                       {
+                         /* __int64 = long long */
+                         flags += 16;
+                       }
+                     else
+                       {
+                         /* __int64 = long */
+                         flags += 8;
+                       }
+                     cp += 3;
+                   }
+#endif
                  else
                    break;
                }