+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.
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.
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.
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
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.
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.
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.
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.
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
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.
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.
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)
-# 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,
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)
*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
;;
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
-# 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,
])
])
+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.
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 # # # . # # . # # # .
-# 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,
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
*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
;;
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
-# 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,
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)
*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
;;
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
-# 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,
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
*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
;;
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
])
-# 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,
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],
[
-# 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,
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
*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
;;
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
-# 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,
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)
*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
;;
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
-# 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,
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
*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
;;
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
-# 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,
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)
*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
;;
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
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));
+ }
}
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));
+ }
}
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 *
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