changeset 9588:82384b8e3c31

Handle the particular PRIdMAX values on MacOS X and mingw.
author Bruno Haible <bruno@clisp.org>
date Wed, 09 Jan 2008 02:15:36 +0100
parents 263f472dc864
children 2f578a20fda7
files ChangeLog lib/printf-parse.c
diffstat 2 files changed, 47 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/lib/printf-parse.c
+++ b/lib/printf-parse.c
@@ -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 @@
 			}
 		      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;
 		}