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 67d2feaa14c350122dc270660a6dfe16283486e3..3bae344b787220831df699776e98050af697238d 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 86ea0bff4d86dd2fbe7e8feed114d284a2adb0b3..476c31cab391d5a0515156f3e68c17c720502832 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 e2f1fa4695792429c47a5fc11c2eb76a6744777f..f794c8011745fa66f1d692d7c7c31aa3a40fd2e9 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 688e88de2accfb44084c43c285c6fada739d24c0..5a41a67d99ad883d46f12c92bface62b95ed4412 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 c38a7902718b2cc90b5a08b8bdb5cfb31d187248..0760dd5dcba7362962d61c90af261133af34f548 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 1fc3c9277941d1deb72e0f39fb25a19df21ca191..d5eeef276cac513e39824bea020772c67d1fd0f4 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 d9ee5c6fae6a763d6d8aa790c356f0b957bee7b5..430dab2034d41b983e9c6327dbb806e0c566bb9e 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 6c8590787d52d91b17c5338ca1d19bbc5eaf39ea..3e6171672c2a606ce81a0a98c6c7f704b8816cf7 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 a9bfe727e06ac3cb34929c0628cea9d6e101540b..6ec8e1bbc77dcaa55c375d72e5fc1b46093e212e 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 e11f1e998306151821a900287727e9832fcd55ab..205200b65f1f04189ece8ab697c60421cb8966af 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 027147da69c84cbd97370f819339c38890747fe0..c63815805561f27338f83255a9fc59a0590eaf9b 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 3387d84675a2e14017d88a061cc942a2812bf908..e09c9d88049ca1e930ef43576e9a18d67fa2d57e 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 9e9ef1dfe8c387d47e4d801a5eea9cb9ce7a8d2b..6208adcd408506fb18fbe5e58969e2d3323c1839 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 c0c1d4aa15f1ff8e4c2140ac28b6d0838b459e20..bb354d1ef0bdf537991a839c5d8088337a368239 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 b570c1c8a4280173d9f5e319e55b992a92caf35d..34eee29c8a37d54734256eff69fac5292b597616 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 79886e75f4ac0c26214fbebc349c62cb619b849a..773c92f961759d5d477141dd0efd7b9bbcaeae63 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 46ffc34f455395ef5acf4226ed3f0af6409ad43f..43151632e6ff09f93cb3354c73bcb6ad290c483d 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 c217eb21f7d4f0c58ed4160735ed77b8b5f770af..669ae2008681f01ba3896d4e9f7417fe342055bd 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 f2cb58232babea0f2eb584060b08e1654eb253ed..941cf515b545780e46602c3af666d87ddb3332cf 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 9c45ceba3151fa8cf12a2fc23b21b7c84b1d1172..626da1eef62e484aad5ad78efa9a2e0df33032d9 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 36212dceeb6e56e925c806c7ae9b2835a1f09f3c..7b1370b88cbafddc1a75e198b34a3370d04aaf71 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 fbb22ddcd058832eb562440442b8f2c9c1efbbc4..f6d70e617cd044abde5f3b8b20199783dbf32cdf 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 f08e1ad99ff1ce0cee841688e69e35f0e8dcc143..4162d3b531307119dc2fa1619bc99313365ac945 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 40798ea2bb6bdb9fa574e8f2933811a92a6aac74..e26b8a5d0ae9daf10b132ece57dbb38a040ffff9 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