Work around lack of support of grouping flag.
authorBruno Haible <bruno@clisp.org>
Sun, 6 May 2007 15:29:04 +0000 (15:29 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 6 May 2007 15:29:04 +0000 (15:29 +0000)
24 files changed:
ChangeLog
doc/functions/fprintf.texi
doc/functions/printf.texi
doc/functions/snprintf.texi
doc/functions/sprintf.texi
doc/functions/vfprintf.texi
doc/functions/vprintf.texi
doc/functions/vsnprintf.texi
doc/functions/vsprintf.texi
lib/vasnprintf.c
m4/fprintf-posix.m4
m4/printf.m4
m4/snprintf-posix.m4
m4/sprintf-posix.m4
m4/vasnprintf-posix.m4
m4/vasnprintf.m4
m4/vasprintf-posix.m4
m4/vfprintf-posix.m4
m4/vsnprintf-posix.m4
m4/vsprintf-posix.m4
tests/test-snprintf-posix.h
tests/test-sprintf-posix.h
tests/test-vasnprintf-posix.c
tests/test-vasprintf-posix.c

index 67d2fea..3bae344 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2007-05-06  Bruno Haible  <bruno@clisp.org>
+
+       * lib/vasnprintf.c (VASNPRINTF) [NEED_PRINTF_FLAG_GROUPING]: Don't
+       pass the ' flag character to sprintf or snprintf.
+       * m4/printf.m4 (gl_PRINTF_FLAG_GROUPING): New macro.
+       * m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF_FLAG_GROUPING): New macro.
+       * m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_POSIX): Invoke
+       gl_PRINTF_FLAG_GROUPING and test its result. Invoke
+       gl_PREREQ_VASNPRINTF_FLAG_GROUPING.
+       * m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_POSIX): Likewise.
+       * m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_POSIX): Likewise.
+       * m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_POSIX): Likewise.
+       * m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_POSIX): Likewise.
+       * m4/vfprintf-posix.m4 (gl_FUNC_VFPRINTF_POSIX): Likewise.
+       * m4/vsnprintf-posix.m4 (gl_FUNC_VSNPRINTF_POSIX): Likewise.
+       * m4/vsprintf-posix.m4 (gl_FUNC_VSPRINTF_POSIX): Likewise.
+       * tests/test-snprintf-posix.h (test_function): Also check the grouping
+       flag.
+       * tests/test-sprintf-posix.h (test_function): Likewise.
+       * tests/test-vasnprintf-posix.c (test_function): Likewise.
+       * tests/test-vasprintf-posix.c (test_function): Likewise.
+       * doc/functions/fprintf.texi: Update.
+       * doc/functions/printf.texi: Update.
+       * doc/functions/snprintf.texi: Update.
+       * doc/functions/sprintf.texi: Update.
+       * doc/functions/vfprintf.texi: Update.
+       * doc/functions/vprintf.texi: Update.
+       * doc/functions/vsnprintf.texi: Update.
+       * doc/functions/vsprintf.texi: Update.
+
 2007-05-01  Bruno Haible  <bruno@clisp.org>
 
        * tests/test-argp-2.sh (func_compare): Drop .exe suffix.
index 86ea0bf..476c31c 100644 (file)
@@ -23,14 +23,14 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin, mingw,
 This function does not support format directives that access arguments in an
 arbitrary order, such as @code{"%2$s"}, on some platforms:
 NetBSD 3.0, mingw, BeOS.
+@item
+This function doesn't support the @code{'} flag on some platforms:
+NetBSD 3.0, mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function doesn't support the @code{'} flag on some platforms:
-mingw.
-@item
 printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
 with zeroes) on some platforms:
 FreeBSD 6.0.
index e2f1fa4..f794c80 100644 (file)
@@ -23,14 +23,14 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin, mingw,
 This function does not support format directives that access arguments in an
 arbitrary order, such as @code{"%2$s"}, on some platforms:
 NetBSD 3.0, mingw, BeOS.
+@item
+This function doesn't support the @code{'} flag on some platforms:
+NetBSD 3.0, mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function doesn't support the @code{'} flag on some platforms:
-mingw.
-@item
 printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
 with zeroes) on some platforms:
 FreeBSD 6.0.
index 688e88d..5a41a67 100644 (file)
@@ -31,6 +31,9 @@ This function does not support format directives that access arguments in an
 arbitrary order, such as @code{"%2$s"}, on some platforms:
 NetBSD 3.0, mingw, BeOS.
 @item
+This function doesn't support the @code{'} flag on some platforms:
+NetBSD 3.0, mingw.
+@item
 This function does not truncate the result as specified in C99 on some platforms:
 mingw.
 @item
@@ -48,9 +51,6 @@ OSF/1 5.1.
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function doesn't support the @code{'} flag on some platforms:
-mingw.
-@item
 printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
 with zeroes) on some platforms:
 FreeBSD 6.0.
index c38a790..0760dd5 100644 (file)
@@ -23,14 +23,14 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin, mingw,
 This function does not support format directives that access arguments in an
 arbitrary order, such as @code{"%2$s"}, on some platforms:
 NetBSD 3.0, mingw, BeOS.
+@item
+This function doesn't support the @code{'} flag on some platforms:
+NetBSD 3.0, mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function doesn't support the @code{'} flag on some platforms:
-mingw.
-@item
 printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
 with zeroes) on some platforms:
 FreeBSD 6.0.
index 1fc3c92..d5eeef2 100644 (file)
@@ -23,14 +23,14 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin, mingw,
 This function does not support format directives that access arguments in an
 arbitrary order, such as @code{"%2$s"}, on some platforms:
 NetBSD 3.0, mingw, BeOS.
+@item
+This function doesn't support the @code{'} flag on some platforms:
+NetBSD 3.0, mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function doesn't support the @code{'} flag on some platforms:
-mingw.
-@item
 printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
 with zeroes) on some platforms:
 FreeBSD 6.0.
index d9ee5c6..430dab2 100644 (file)
@@ -23,14 +23,14 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin, mingw,
 This function does not support format directives that access arguments in an
 arbitrary order, such as @code{"%2$s"}, on some platforms:
 NetBSD 3.0, mingw, BeOS.
+@item
+This function doesn't support the @code{'} flag on some platforms:
+NetBSD 3.0, mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function doesn't support the @code{'} flag on some platforms:
-mingw.
-@item
 printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
 with zeroes) on some platforms:
 FreeBSD 6.0.
index 6c85907..3e61716 100644 (file)
@@ -31,6 +31,9 @@ This function does not support format directives that access arguments in an
 arbitrary order, such as @code{"%2$s"}, on some platforms:
 NetBSD 3.0, mingw, BeOS.
 @item
+This function doesn't support the @code{'} flag on some platforms:
+NetBSD 3.0, mingw.
+@item
 This function does not truncate the result as specified in C99 on some platforms:
 mingw.
 @item
@@ -48,9 +51,6 @@ HP-UX 11, OSF/1 5.1.
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function doesn't support the @code{'} flag on some platforms:
-mingw.
-@item
 printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
 with zeroes) on some platforms:
 FreeBSD 6.0.
index a9bfe72..6ec8e1b 100644 (file)
@@ -23,14 +23,14 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin, mingw,
 This function does not support format directives that access arguments in an
 arbitrary order, such as @code{"%2$s"}, on some platforms:
 NetBSD 3.0, mingw, BeOS.
+@item
+This function doesn't support the @code{'} flag on some platforms:
+NetBSD 3.0, mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function doesn't support the @code{'} flag on some platforms:
-mingw.
-@item
 printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
 with zeroes) on some platforms:
 FreeBSD 6.0.
index e11f1e9..205200b 100644 (file)
@@ -1012,8 +1012,14 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
                   sprintf.  */
                p = buf;
                *p++ = '%';
+#if NEED_PRINTF_FLAG_GROUPING
+               /* The underlying implementation doesn't support the ' flag.
+                  Produce no grouping characters in this case; this is
+                  acceptable because the grouping is locale dependent.  */
+#else
                if (dp->flags & FLAG_GROUP)
                  *p++ = '\'';
+#endif
                if (dp->flags & FLAG_LEFT)
                  *p++ = '-';
                if (dp->flags & FLAG_SHOWSIGN)
index 027147d..c638158 100644 (file)
@@ -1,4 +1,4 @@
-# fprintf-posix.m4 serial 3
+# fprintf-posix.m4 serial 4
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,6 +12,7 @@ AC_DEFUN([gl_FUNC_FPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_POSITIONS])
+  AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   gl_cv_func_fprintf_posix=no
   case "$gl_cv_func_printf_sizes_c99" in
     *yes)
@@ -23,8 +24,12 @@ AC_DEFUN([gl_FUNC_FPRINTF_POSIX],
                 *yes)
                   case "$gl_cv_func_printf_positions" in
                     *yes)
-                      # fprintf exists and is already POSIX compliant.
-                      gl_cv_func_fprintf_posix=yes
+                      case "$gl_cv_func_printf_flag_grouping" in
+                        *yes)
+                          # fprintf exists and is already POSIX compliant.
+                          gl_cv_func_fprintf_posix=yes
+                          ;;
+                      esac
                       ;;
                   esac
                   ;;
@@ -38,6 +43,7 @@ AC_DEFUN([gl_FUNC_FPRINTF_POSIX],
   if test $gl_cv_func_fprintf_posix = no; then
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
+    gl_PREREQ_VASNPRINTF_FLAG_GROUPING
     gl_REPLACE_VASNPRINTF
     gl_REPLACE_FPRINTF
   fi
index 3387d84..e09c9d8 100644 (file)
@@ -1,4 +1,4 @@
-# printf.m4 serial 7
+# printf.m4 serial 8
 dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -284,6 +284,40 @@ changequote([,])dnl
     ])
 ])
 
+dnl Test whether the *printf family of functions supports POSIX/XSI format
+dnl strings with the ' flag for grouping of decimal digits. (POSIX:2001)
+dnl Result is gl_cv_func_printf_flag_grouping.
+
+AC_DEFUN([gl_PRINTF_FLAG_GROUPING],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports the grouping flag],
+    [gl_cv_func_printf_flag_grouping],
+    [
+      AC_TRY_RUN([
+#include <stdio.h>
+#include <string.h>
+static char buf[100];
+int main ()
+{
+  if (sprintf (buf, "%'d %d", 1234567, 99) < 0
+      || buf[strlen (buf) - 1] != '9')
+    return 1;
+  return 0;
+}], [gl_cv_func_printf_flag_grouping=yes], [gl_cv_func_printf_flag_grouping=no],
+      [
+changequote(,)dnl
+       case "$host_os" in
+         netbsd*)      gl_cv_func_printf_flag_grouping="guessing no";;
+         mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
+         *)            gl_cv_func_printf_flag_grouping="guessing yes";;
+       esac
+changequote([,])dnl
+      ])
+    ])
+])
+
 dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001)
 dnl Result is ac_cv_func_snprintf.
 
@@ -590,44 +624,46 @@ dnl 2 = gl_PRINTF_DIRECTIVE_A
 dnl 3 = gl_PRINTF_DIRECTIVE_F
 dnl 4 = gl_PRINTF_DIRECTIVE_N
 dnl 5 = gl_PRINTF_POSITIONS
-dnl 6 = gl_SNPRINTF_PRESENCE
-dnl 7 = gl_SNPRINTF_TRUNCATION_C99
-dnl 8 = gl_SNPRINTF_RETVAL_C99
-dnl 9 = gl_SNPRINTF_DIRECTIVE_N
-dnl 10 = gl_VSNPRINTF_ZEROSIZE_C99
+dnl 6 = gl_PRINTF_FLAG_GROUPING
+dnl 7 = gl_SNPRINTF_PRESENCE
+dnl 8 = gl_SNPRINTF_TRUNCATION_C99
+dnl 9 = gl_SNPRINTF_RETVAL_C99
+dnl 10 = gl_SNPRINTF_DIRECTIVE_N
+dnl 11 = gl_VSNPRINTF_ZEROSIZE_C99
 dnl
 dnl 1 = checking whether printf supports size specifiers as in C99...
 dnl 2 = checking whether printf supports the 'a' and 'A' directives...
 dnl 3 = checking whether printf supports the 'F' directive...
 dnl 4 = checking whether printf supports the 'n' directive...
 dnl 5 = checking whether printf supports POSIX/XSI format strings with positions...
-dnl 6 = checking for snprintf...
-dnl 7 = checking whether snprintf truncates the result as in C99...
-dnl 8 = checking whether snprintf returns a byte count as in C99...
-dnl 9 = checking whether snprintf fully supports the 'n' directive...
-dnl 10 = checking whether vsnprintf respects a zero size as in C99...
+dnl 6 = checking whether printf supports the grouping flag...
+dnl 7 = checking for snprintf...
+dnl 8 = checking whether snprintf truncates the result as in C99...
+dnl 9 = checking whether snprintf returns a byte count as in C99...
+dnl 10 = checking whether snprintf fully supports the 'n' directive...
+dnl 11 = checking whether vsnprintf respects a zero size as in C99...
 dnl
 dnl . = yes, # = no.
 dnl
-dnl                                        1  2  3  4  5  6  7  8  9 10
-dnl   glibc 2.5                            .  .  .  .  .  .  .  .  .  .
-dnl   glibc 2.3.6                          .  #  .  .  .  .  .  .  .  .
-dnl   FreeBSD 5.4, 6.1                     .  ?  .  .  .  .  .  .  .  .
-dnl   MacOS X 10.3.9                       .  #  .  .  .  .  .  .  .  .
-dnl   OpenBSD 3.9, 4.0                     .  #  ?  .  .  .  .  .  ?  ?
-dnl   Cygwin 2007                          .  #  #  .  .  .  .  .  .  ?
-dnl   Cygwin 2006                          #  #  #  .  .  .  .  .  .  ?
-dnl   Solaris 10                           .  #  .  .  .  .  .  .  .  .
-dnl   Solaris 2.6 ... 9                    #  #  #  .  .  .  .  .  .  .
-dnl   Solaris 2.5.1                        #  #  #  .  .  #  #  #  #  #
-dnl   AIX 5.2                              .  #  .  .  .  .  .  .  .  .
-dnl   AIX 4.3.2, 5.1                       #  #  #  .  .  .  .  .  .  .
-dnl   HP-UX 11.31                          .  #  .  .  .  .  .  #  #  .
-dnl   HP-UX 10.20, 11.00, 11.11, 11.23     #  #  #  .  .  .  .  #  #  #
-dnl   IRIX 6.5                             #  #  #  .  .  .  .  #  .  .
-dnl   OSF/1 5.1                            #  #  #  .  .  .  .  #  .  #
-dnl   OSF/1 4.0d                           #  #  #  .  .  #  #  #  #  #
-dnl   NetBSD 4.0                           .  ?  ?  .  .  .  .  .  ?  ?
-dnl   NetBSD 3.0                           .  #  #  .  #  .  .  .  .  .
-dnl   BeOS                                 #  #  #  .  #  .  .  .  .  .
-dnl   mingw                                #  #  #  .  #  .  #  #  #  .
+dnl                                        1  2  3  4  5  6  7  8  9 10 11
+dnl   glibc 2.5                            .  .  .  .  .  .  .  .  .  .  .
+dnl   glibc 2.3.6                          .  #  .  .  .  .  .  .  .  .  .
+dnl   FreeBSD 5.4, 6.1                     .  ?  .  .  .  .  .  .  .  .  .
+dnl   MacOS X 10.3.9                       .  #  .  .  .  .  .  .  .  .  .
+dnl   OpenBSD 3.9, 4.0                     .  #  ?  .  .  ?  .  .  .  ?  ?
+dnl   Cygwin 2007                          .  #  #  .  .  ?  .  .  .  .  ?
+dnl   Cygwin 2006                          #  #  #  .  .  ?  .  .  .  .  ?
+dnl   Solaris 10                           .  #  .  .  .  .  .  .  .  .  .
+dnl   Solaris 2.6 ... 9                    #  #  #  .  .  .  .  .  .  .  .
+dnl   Solaris 2.5.1                        #  #  #  .  .  .  #  #  #  #  #
+dnl   AIX 5.2                              .  #  .  .  .  .  .  .  .  .  .
+dnl   AIX 4.3.2, 5.1                       #  #  #  .  .  .  .  .  .  .  .
+dnl   HP-UX 11.31                          .  #  .  .  .  .  .  .  #  #  .
+dnl   HP-UX 10.20, 11.00, 11.11, 11.23     #  #  #  .  .  .  .  .  #  #  #
+dnl   IRIX 6.5                             #  #  #  .  .  .  .  .  #  .  .
+dnl   OSF/1 5.1                            #  #  #  .  .  .  .  .  #  .  #
+dnl   OSF/1 4.0d                           #  #  #  .  .  .  #  #  #  #  #
+dnl   NetBSD 4.0                           .  ?  ?  .  .  ?  .  .  .  ?  ?
+dnl   NetBSD 3.0                           .  #  #  .  #  #  .  .  .  .  .
+dnl   BeOS                                 #  #  #  .  #  .  .  .  .  .  .
+dnl   mingw                                #  #  #  .  #  #  .  #  #  #  .
index 9e9ef1d..6208adc 100644 (file)
@@ -1,4 +1,4 @@
-# snprintf-posix.m4 serial 4
+# snprintf-posix.m4 serial 5
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,6 +12,7 @@ AC_DEFUN([gl_FUNC_SNPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_POSITIONS])
+  AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   gl_cv_func_snprintf_posix=no
   AC_CHECK_FUNCS([snprintf])
   if test $ac_cv_func_snprintf = yes; then
@@ -29,17 +30,21 @@ AC_DEFUN([gl_FUNC_SNPRINTF_POSIX],
                   *yes)
                     case "$gl_cv_func_printf_positions" in
                       *yes)
-                        case "$gl_cv_func_snprintf_truncation_c99" in
+                        case "$gl_cv_func_printf_flag_grouping" in
                           *yes)
-                            case "$gl_cv_func_snprintf_retval_c99" in
+                            case "$gl_cv_func_snprintf_truncation_c99" in
                               *yes)
-                                case "$gl_cv_func_snprintf_directive_n" in
+                                case "$gl_cv_func_snprintf_retval_c99" in
                                   *yes)
-                                    case "$gl_cv_func_vsnprintf_zerosize_c99" in
+                                    case "$gl_cv_func_snprintf_directive_n" in
                                       *yes)
-                                        # snprintf exists and is already POSIX
-                                        # compliant.
-                                        gl_cv_func_snprintf_posix=yes
+                                        case "$gl_cv_func_vsnprintf_zerosize_c99" in
+                                          *yes)
+                                            # snprintf exists and is already
+                                            # POSIX compliant.
+                                            gl_cv_func_snprintf_posix=yes
+                                            ;;
+                                        esac
                                         ;;
                                     esac
                                     ;;
@@ -62,6 +67,7 @@ AC_DEFUN([gl_FUNC_SNPRINTF_POSIX],
   if test $gl_cv_func_snprintf_posix = no; then
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
+    gl_PREREQ_VASNPRINTF_FLAG_GROUPING
     gl_REPLACE_VASNPRINTF
     gl_REPLACE_SNPRINTF
   fi
index c0c1d4a..bb354d1 100644 (file)
@@ -1,4 +1,4 @@
-# sprintf-posix.m4 serial 3
+# sprintf-posix.m4 serial 4
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,6 +12,7 @@ AC_DEFUN([gl_FUNC_SPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_POSITIONS])
+  AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   gl_cv_func_sprintf_posix=no
   case "$gl_cv_func_printf_sizes_c99" in
     *yes)
@@ -23,8 +24,12 @@ AC_DEFUN([gl_FUNC_SPRINTF_POSIX],
                 *yes)
                   case "$gl_cv_func_printf_positions" in
                     *yes)
-                      # sprintf exists and is already POSIX compliant.
-                      gl_cv_func_sprintf_posix=yes
+                      case "$gl_cv_func_printf_flag_grouping" in
+                        *yes)
+                          # sprintf exists and is already POSIX compliant.
+                          gl_cv_func_sprintf_posix=yes
+                          ;;
+                      esac
                       ;;
                   esac
                   ;;
@@ -38,6 +43,7 @@ AC_DEFUN([gl_FUNC_SPRINTF_POSIX],
   if test $gl_cv_func_sprintf_posix = no; then
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
+    gl_PREREQ_VASNPRINTF_FLAG_GROUPING
     gl_REPLACE_VASNPRINTF
     gl_REPLACE_SPRINTF
   fi
index b570c1c..34eee29 100644 (file)
@@ -1,4 +1,4 @@
-# vasnprintf-posix.m4 serial 4
+# vasnprintf-posix.m4 serial 5
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,6 +12,7 @@ AC_DEFUN([gl_FUNC_VASNPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_POSITIONS])
+  AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   gl_cv_func_vasnprintf_posix=no
   AC_CHECK_FUNCS_ONCE([vasnprintf])
   case "$gl_cv_func_printf_sizes_c99" in
@@ -24,10 +25,14 @@ AC_DEFUN([gl_FUNC_VASNPRINTF_POSIX],
                 *yes)
                   case "$gl_cv_func_printf_positions" in
                     *yes)
-                      if test $ac_cv_func_vasnprintf = yes; then
-                        # vasnprintf exists and is already POSIX compliant.
-                        gl_cv_func_vasnprintf_posix=yes
-                      fi
+                      case "$gl_cv_func_printf_flag_grouping" in
+                        *yes)
+                          if test $ac_cv_func_vasnprintf = yes; then
+                            # vasnprintf exists and is already POSIX compliant.
+                            gl_cv_func_vasnprintf_posix=yes
+                          fi
+                          ;;
+                      esac
                       ;;
                   esac
                   ;;
@@ -41,6 +46,7 @@ AC_DEFUN([gl_FUNC_VASNPRINTF_POSIX],
   if test $gl_cv_func_vasnprintf_posix = no; then
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
+    gl_PREREQ_VASNPRINTF_FLAG_GROUPING
     gl_REPLACE_VASNPRINTF
   fi
 ])
index 79886e7..773c92f 100644 (file)
@@ -1,4 +1,4 @@
-# vasnprintf.m4 serial 13
+# vasnprintf.m4 serial 14
 dnl Copyright (C) 2002-2004, 2006-2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -90,6 +90,21 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
   esac
 ])
 
+# Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
+[
+  AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
+  case "$gl_cv_func_printf_flag_grouping" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], 1,
+        [Define if the vasnprintf implementation needs special code for the
+         ' flag.])
+      ;;
+  esac
+])
+
 # Prerequisites of lib/asnprintf.c.
 AC_DEFUN([gl_PREREQ_ASNPRINTF],
 [
index 46ffc34..4315163 100644 (file)
@@ -1,4 +1,4 @@
-# vasprintf-posix.m4 serial 4
+# vasprintf-posix.m4 serial 5
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,6 +12,7 @@ AC_DEFUN([gl_FUNC_VASPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_POSITIONS])
+  AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   gl_cv_func_vasprintf_posix=no
   AC_CHECK_FUNCS([vasprintf])
   case "$gl_cv_func_printf_sizes_c99" in
@@ -24,10 +25,14 @@ AC_DEFUN([gl_FUNC_VASPRINTF_POSIX],
                 *yes)
                   case "$gl_cv_func_printf_positions" in
                     *yes)
-                      if test $ac_cv_func_vasprintf = yes; then
-                        # vasprintf exists and is already POSIX compliant.
-                        gl_cv_func_vasprintf_posix=yes
-                      fi
+                      case "$gl_cv_func_printf_flag_grouping" in
+                        *yes)
+                          if test $ac_cv_func_vasprintf = yes; then
+                            # vasprintf exists and is already POSIX compliant.
+                            gl_cv_func_vasprintf_posix=yes
+                          fi
+                          ;;
+                      esac
                       ;;
                   esac
                   ;;
@@ -41,6 +46,7 @@ AC_DEFUN([gl_FUNC_VASPRINTF_POSIX],
   if test $gl_cv_func_vasprintf_posix = no; then
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
+    gl_PREREQ_VASNPRINTF_FLAG_GROUPING
     gl_REPLACE_VASNPRINTF
     gl_REPLACE_VASPRINTF
   fi
index c217eb2..669ae20 100644 (file)
@@ -1,4 +1,4 @@
-# vfprintf-posix.m4 serial 3
+# vfprintf-posix.m4 serial 4
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,6 +12,7 @@ AC_DEFUN([gl_FUNC_VFPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_POSITIONS])
+  AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   gl_cv_func_vfprintf_posix=no
   case "$gl_cv_func_printf_sizes_c99" in
     *yes)
@@ -23,8 +24,12 @@ AC_DEFUN([gl_FUNC_VFPRINTF_POSIX],
                 *yes)
                   case "$gl_cv_func_printf_positions" in
                     *yes)
-                      # vfprintf exists and is already POSIX compliant.
-                      gl_cv_func_vfprintf_posix=yes
+                      case "$gl_cv_func_printf_flag_grouping" in
+                        *yes)
+                          # vfprintf exists and is already POSIX compliant.
+                          gl_cv_func_vfprintf_posix=yes
+                          ;;
+                      esac
                       ;;
                   esac
                   ;;
@@ -38,6 +43,7 @@ AC_DEFUN([gl_FUNC_VFPRINTF_POSIX],
   if test $gl_cv_func_vfprintf_posix = no; then
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
+    gl_PREREQ_VASNPRINTF_FLAG_GROUPING
     gl_REPLACE_VASNPRINTF
     gl_REPLACE_VFPRINTF
   fi
index f2cb582..941cf51 100644 (file)
@@ -1,4 +1,4 @@
-# vsnprintf-posix.m4 serial 4
+# vsnprintf-posix.m4 serial 5
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,6 +12,7 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_POSITIONS])
+  AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   gl_cv_func_vsnprintf_posix=no
   AC_CHECK_FUNCS([vsnprintf])
   if test $ac_cv_func_vsnprintf = yes; then
@@ -30,17 +31,21 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_POSIX],
                   *yes)
                     case "$gl_cv_func_printf_positions" in
                       *yes)
-                        case "$gl_cv_func_snprintf_truncation_c99" in
+                        case "$gl_cv_func_printf_flag_grouping" in
                           *yes)
-                            case "$gl_cv_func_snprintf_retval_c99" in
+                            case "$gl_cv_func_snprintf_truncation_c99" in
                               *yes)
-                                case "$gl_cv_func_snprintf_directive_n" in
+                                case "$gl_cv_func_snprintf_retval_c99" in
                                   *yes)
-                                    case "$gl_cv_func_vsnprintf_zerosize_c99" in
+                                    case "$gl_cv_func_snprintf_directive_n" in
                                       *yes)
-                                        # vsnprintf exists and is already POSIX
-                                        # compliant.
-                                        gl_cv_func_vsnprintf_posix=yes
+                                        case "$gl_cv_func_vsnprintf_zerosize_c99" in
+                                          *yes)
+                                            # vsnprintf exists and is already
+                                            # POSIX compliant.
+                                            gl_cv_func_vsnprintf_posix=yes
+                                            ;;
+                                        esac
                                         ;;
                                     esac
                                     ;;
@@ -63,6 +68,7 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_POSIX],
   if test $gl_cv_func_vsnprintf_posix = no; then
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
+    gl_PREREQ_VASNPRINTF_FLAG_GROUPING
     gl_REPLACE_VASNPRINTF
     gl_REPLACE_VSNPRINTF
   fi
index 9c45ceb..626da1e 100644 (file)
@@ -1,4 +1,4 @@
-# vsprintf-posix.m4 serial 3
+# vsprintf-posix.m4 serial 4
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,6 +12,7 @@ AC_DEFUN([gl_FUNC_VSPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
   AC_REQUIRE([gl_PRINTF_POSITIONS])
+  AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
   gl_cv_func_vsprintf_posix=no
   case "$gl_cv_func_printf_sizes_c99" in
     *yes)
@@ -23,8 +24,12 @@ AC_DEFUN([gl_FUNC_VSPRINTF_POSIX],
                 *yes)
                   case "$gl_cv_func_printf_positions" in
                     *yes)
-                      # vsprintf exists and is already POSIX compliant.
-                      gl_cv_func_vsprintf_posix=yes
+                      case "$gl_cv_func_printf_flag_grouping" in
+                        *yes)
+                          # vsprintf exists and is already POSIX compliant.
+                          gl_cv_func_vsprintf_posix=yes
+                          ;;
+                      esac
                       ;;
                   esac
                   ;;
@@ -38,6 +43,7 @@ AC_DEFUN([gl_FUNC_VSPRINTF_POSIX],
   if test $gl_cv_func_vsprintf_posix = no; then
     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
+    gl_PREREQ_VASNPRINTF_FLAG_GROUPING
     gl_REPLACE_VASNPRINTF
     gl_REPLACE_VSPRINTF
   fi
index 36212dc..7b1370b 100644 (file)
@@ -1006,4 +1006,14 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
     ASSERT (strcmp (result, "55 33") == 0);
     ASSERT (retval == strlen (result));
   }
+
+  /* Test the support of the grouping flag.  */
+
+  {
+    char result[100];
+    int retval =
+      my_snprintf (result, sizeof (result), "%'d %d", 1234567, 99);
+    ASSERT (result[strlen (result) - 1] == '9');
+    ASSERT (retval == strlen (result));
+  }
 }
index fbb22dd..f6d70e6 100644 (file)
@@ -992,4 +992,14 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
     ASSERT (strcmp (result, "55 33") == 0);
     ASSERT (retval == strlen (result));
   }
+
+  /* Test the support of the grouping flag.  */
+
+  {
+    char result[1000];
+    int retval =
+      my_sprintf (result, "%'d %d", 1234567, 99);
+    ASSERT (result[strlen (result) - 1] == '9');
+    ASSERT (retval == strlen (result));
+  }
 }
index f08e1ad..4162d3b 100644 (file)
@@ -1236,6 +1236,18 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
     ASSERT (length == strlen (result));
     free (result);
   }
+
+  /* Test the support of the grouping flag.  */
+
+  {
+    size_t length;
+    char *result =
+      my_asnprintf (NULL, &length, "%'d %d", 1234567, 99);
+    ASSERT (result != NULL);
+    ASSERT (result[strlen (result) - 1] == '9');
+    ASSERT (length == strlen (result));
+    free (result);
+  }
 }
 
 static char *
index 40798ea..e26b8a5 100644 (file)
@@ -1217,6 +1217,18 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
     ASSERT (retval == strlen (result));
     free (result);
   }
+
+  /* Test the support of the grouping flag.  */
+
+  {
+    char *result;
+    int retval =
+      my_asprintf (&result, "%'d %d", 1234567, 99);
+    ASSERT (result != NULL);
+    ASSERT (result[strlen (result) - 1] == '9');
+    ASSERT (retval == strlen (result));
+    free (result);
+  }
 }
 
 static int