From 2caf4791a548a8b4fb500256a6dfe05626f2e467 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 9 Jan 2008 02:15:36 +0100 Subject: [PATCH] Handle the particular PRIdMAX values on MacOS X and mingw. --- ChangeLog | 8 ++++++++ lib/printf-parse.c | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9cdc7790e..be8067f22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-01-08 Jim Meyering + Bruno Haible + + * 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 + . + 2008-01-08 Bruno Haible * modules/unictype/category-of (Depends-on): Add diff --git a/lib/printf-parse.c b/lib/printf-parse.c index e3aa95a02..b11f6bb22 100644 --- 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 @@ 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; } -- 2.11.0