Mercurial > hg > octave-nkf > gnulib-hg
changeset 8803:6c1d98929550
Work around lack of support of grouping flag.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 06 May 2007 15:29:04 +0000 |
parents | c5a6db81842b |
children | 6ce313658b4d |
files | 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 |
diffstat | 24 files changed, 275 insertions(+), 96 deletions(-) [+] |
line wrap: on
line diff
--- 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.
--- a/doc/functions/fprintf.texi +++ b/doc/functions/fprintf.texi @@ -23,14 +23,14 @@ 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.
--- a/doc/functions/printf.texi +++ b/doc/functions/printf.texi @@ -23,14 +23,14 @@ 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.
--- a/doc/functions/snprintf.texi +++ b/doc/functions/snprintf.texi @@ -31,6 +31,9 @@ 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 @@ 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.
--- a/doc/functions/sprintf.texi +++ b/doc/functions/sprintf.texi @@ -23,14 +23,14 @@ 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.
--- a/doc/functions/vfprintf.texi +++ b/doc/functions/vfprintf.texi @@ -23,14 +23,14 @@ 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.
--- a/doc/functions/vprintf.texi +++ b/doc/functions/vprintf.texi @@ -23,14 +23,14 @@ 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.
--- a/doc/functions/vsnprintf.texi +++ b/doc/functions/vsnprintf.texi @@ -31,6 +31,9 @@ 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 @@ 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.
--- a/doc/functions/vsprintf.texi +++ b/doc/functions/vsprintf.texi @@ -23,14 +23,14 @@ 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.
--- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -1012,8 +1012,14 @@ 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)
--- a/m4/fprintf-posix.m4 +++ b/m4/fprintf-posix.m4 @@ -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_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 @@ *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 @@ 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
--- a/m4/printf.m4 +++ b/m4/printf.m4 @@ -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 @@ ]) ]) +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 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 # # # . # # . # # # .
--- a/m4/snprintf-posix.m4 +++ b/m4/snprintf-posix.m4 @@ -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_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 @@ *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 @@ 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
--- a/m4/sprintf-posix.m4 +++ b/m4/sprintf-posix.m4 @@ -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_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 @@ *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 @@ 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
--- a/m4/vasnprintf-posix.m4 +++ b/m4/vasnprintf-posix.m4 @@ -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_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 @@ *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 @@ 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 ])
--- a/m4/vasnprintf.m4 +++ b/m4/vasnprintf.m4 @@ -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 @@ 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], [
--- a/m4/vasprintf-posix.m4 +++ b/m4/vasprintf-posix.m4 @@ -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_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 @@ *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 @@ 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
--- a/m4/vfprintf-posix.m4 +++ b/m4/vfprintf-posix.m4 @@ -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_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 @@ *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 @@ 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
--- a/m4/vsnprintf-posix.m4 +++ b/m4/vsnprintf-posix.m4 @@ -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_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 @@ *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 @@ 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
--- a/m4/vsprintf-posix.m4 +++ b/m4/vsprintf-posix.m4 @@ -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_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 @@ *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 @@ 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
--- a/tests/test-snprintf-posix.h +++ b/tests/test-snprintf-posix.h @@ -1006,4 +1006,14 @@ 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)); + } }
--- a/tests/test-sprintf-posix.h +++ b/tests/test-sprintf-posix.h @@ -992,4 +992,14 @@ 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)); + } }
--- a/tests/test-vasnprintf-posix.c +++ b/tests/test-vasnprintf-posix.c @@ -1236,6 +1236,18 @@ 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 *
--- a/tests/test-vasprintf-posix.c +++ b/tests/test-vasprintf-posix.c @@ -1217,6 +1217,18 @@ 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