[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
*printf: support the ' flag
From: |
Bruno Haible |
Subject: |
*printf: support the ' flag |
Date: |
Sun, 6 May 2007 17:26:15 +0200 |
User-agent: |
KMail/1.5.4 |
This adds support for the grouping flag in the *printf functions, which is
missing in NetBSD 3.0 and mingw.
2007-05-06 Bruno Haible <address@hidden>
* 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.
*** doc/functions/fprintf.texi 1 May 2007 15:11:38 -0000 1.1
--- doc/functions/fprintf.texi 6 May 2007 14:46:04 -0000
***************
*** 23,36 ****
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.
@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.
--- 23,36 ----
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:
+ mingw.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
with zeroes) on some platforms:
FreeBSD 6.0.
*** doc/functions/printf.texi 1 May 2007 15:11:38 -0000 1.1
--- doc/functions/printf.texi 6 May 2007 14:46:04 -0000
***************
*** 23,36 ****
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.
@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.
--- 23,36 ----
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:
+ mingw.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
with zeroes) on some platforms:
FreeBSD 6.0.
*** doc/functions/snprintf.texi 1 May 2007 15:11:39 -0000 1.1
--- doc/functions/snprintf.texi 6 May 2007 14:46:04 -0000
***************
*** 31,36 ****
--- 31,39 ----
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:
+ mingw.
+ @item
This function does not truncate the result as specified in C99 on some
platforms:
mingw.
@item
***************
*** 48,56 ****
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.
--- 51,56 ----
*** doc/functions/sprintf.texi 1 May 2007 15:11:39 -0000 1.1
--- doc/functions/sprintf.texi 6 May 2007 14:46:04 -0000
***************
*** 23,36 ****
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.
@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.
--- 23,36 ----
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:
+ mingw.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
with zeroes) on some platforms:
FreeBSD 6.0.
*** doc/functions/vfprintf.texi 1 May 2007 15:11:39 -0000 1.1
--- doc/functions/vfprintf.texi 6 May 2007 14:46:04 -0000
***************
*** 23,36 ****
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.
@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.
--- 23,36 ----
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:
+ mingw.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
with zeroes) on some platforms:
FreeBSD 6.0.
*** doc/functions/vprintf.texi 1 May 2007 15:11:39 -0000 1.1
--- doc/functions/vprintf.texi 6 May 2007 14:46:04 -0000
***************
*** 23,36 ****
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.
@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.
--- 23,36 ----
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:
+ mingw.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
with zeroes) on some platforms:
FreeBSD 6.0.
*** doc/functions/vsnprintf.texi 1 May 2007 15:11:39 -0000 1.1
--- doc/functions/vsnprintf.texi 6 May 2007 14:46:04 -0000
***************
*** 31,36 ****
--- 31,39 ----
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:
+ mingw.
+ @item
This function does not truncate the result as specified in C99 on some
platforms:
mingw.
@item
***************
*** 48,56 ****
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.
--- 51,56 ----
*** doc/functions/vsprintf.texi 1 May 2007 15:11:39 -0000 1.1
--- doc/functions/vsprintf.texi 6 May 2007 14:46:05 -0000
***************
*** 23,36 ****
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.
@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.
--- 23,36 ----
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:
+ mingw.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
with zeroes) on some platforms:
FreeBSD 6.0.
*** lib/vasnprintf.c 11 Apr 2007 23:46:07 -0000 1.40
--- lib/vasnprintf.c 6 May 2007 14:46:05 -0000
***************
*** 1012,1019 ****
--- 1012,1025 ----
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)
*** m4/fprintf-posix.m4 11 Apr 2007 23:46:07 -0000 1.3
--- m4/fprintf-posix.m4 6 May 2007 14:46:05 -0000
***************
*** 1,4 ****
! # fprintf-posix.m4 serial 3
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,
--- 1,4 ----
! # 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,17 ****
--- 12,18 ----
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,30 ****
*yes)
case "$gl_cv_func_printf_positions" in
*yes)
! # fprintf exists and is already POSIX compliant.
! gl_cv_func_fprintf_posix=yes
;;
esac
;;
--- 24,35 ----
*yes)
case "$gl_cv_func_printf_positions" in
*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,43 ****
--- 43,49 ----
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
*** m4/printf.m4 29 Apr 2007 15:40:30 -0000 1.21
--- m4/printf.m4 6 May 2007 14:46:05 -0000
***************
*** 1,4 ****
! # printf.m4 serial 7
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,
--- 1,4 ----
! # 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,289 ****
--- 284,323 ----
])
])
+ 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,633 ****
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
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
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 # # # . # . # # # .
--- 624,669 ----
dnl 3 = gl_PRINTF_DIRECTIVE_F
dnl 4 = gl_PRINTF_DIRECTIVE_N
dnl 5 = gl_PRINTF_POSITIONS
! 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 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 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 # # # . # # . # # # .
*** m4/snprintf-posix.m4 29 Apr 2007 15:40:30 -0000 1.5
--- m4/snprintf-posix.m4 6 May 2007 14:46:05 -0000
***************
*** 1,4 ****
! # snprintf-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,
--- 1,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,17 ****
--- 12,18 ----
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,45 ****
*yes)
case "$gl_cv_func_printf_positions" in
*yes)
! case "$gl_cv_func_snprintf_truncation_c99" in
*yes)
! case "$gl_cv_func_snprintf_retval_c99" in
*yes)
! case "$gl_cv_func_snprintf_directive_n" in
*yes)
! case "$gl_cv_func_vsnprintf_zerosize_c99"
in
*yes)
! # snprintf exists and is already POSIX
! # compliant.
! gl_cv_func_snprintf_posix=yes
;;
esac
;;
--- 30,50 ----
*yes)
case "$gl_cv_func_printf_positions" in
*yes)
! case "$gl_cv_func_printf_flag_grouping" in
*yes)
! case "$gl_cv_func_snprintf_truncation_c99" in
*yes)
! case "$gl_cv_func_snprintf_retval_c99" in
*yes)
! case "$gl_cv_func_snprintf_directive_n" in
*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,67 ****
--- 67,73 ----
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
*** m4/sprintf-posix.m4 11 Apr 2007 23:46:07 -0000 1.4
--- m4/sprintf-posix.m4 6 May 2007 14:46:05 -0000
***************
*** 1,4 ****
! # sprintf-posix.m4 serial 3
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,
--- 1,4 ----
! # 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,17 ****
--- 12,18 ----
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,30 ****
*yes)
case "$gl_cv_func_printf_positions" in
*yes)
! # sprintf exists and is already POSIX compliant.
! gl_cv_func_sprintf_posix=yes
;;
esac
;;
--- 24,35 ----
*yes)
case "$gl_cv_func_printf_positions" in
*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,43 ****
--- 43,49 ----
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
*** m4/vasnprintf-posix.m4 11 Apr 2007 23:46:07 -0000 1.7
--- m4/vasnprintf-posix.m4 6 May 2007 14:46:05 -0000
***************
*** 1,4 ****
! # vasnprintf-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,
--- 1,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,17 ****
--- 12,18 ----
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,33 ****
*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
;;
esac
;;
--- 25,38 ----
*yes)
case "$gl_cv_func_printf_positions" in
*yes)
! 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,46 ****
--- 46,52 ----
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
])
*** m4/vasnprintf.m4 11 Apr 2007 23:46:07 -0000 1.20
--- m4/vasnprintf.m4 6 May 2007 14:46:05 -0000
***************
*** 1,4 ****
! # vasnprintf.m4 serial 13
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,
--- 1,4 ----
! # 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,95 ****
--- 90,110 ----
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],
[
*** m4/vasprintf-posix.m4 11 Apr 2007 23:46:07 -0000 1.5
--- m4/vasprintf-posix.m4 6 May 2007 14:46:05 -0000
***************
*** 1,4 ****
! # vasprintf-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,
--- 1,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,17 ****
--- 12,18 ----
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,33 ****
*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
;;
esac
;;
--- 25,38 ----
*yes)
case "$gl_cv_func_printf_positions" in
*yes)
! 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,46 ****
--- 46,52 ----
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
*** m4/vfprintf-posix.m4 11 Apr 2007 23:46:07 -0000 1.3
--- m4/vfprintf-posix.m4 6 May 2007 14:46:05 -0000
***************
*** 1,4 ****
! # vfprintf-posix.m4 serial 3
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,
--- 1,4 ----
! # 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,17 ****
--- 12,18 ----
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,30 ****
*yes)
case "$gl_cv_func_printf_positions" in
*yes)
! # vfprintf exists and is already POSIX compliant.
! gl_cv_func_vfprintf_posix=yes
;;
esac
;;
--- 24,35 ----
*yes)
case "$gl_cv_func_printf_positions" in
*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,43 ****
--- 43,49 ----
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
*** m4/vsnprintf-posix.m4 29 Apr 2007 15:40:30 -0000 1.5
--- m4/vsnprintf-posix.m4 6 May 2007 14:46:05 -0000
***************
*** 1,4 ****
! # vsnprintf-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,
--- 1,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,17 ****
--- 12,18 ----
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,46 ****
*yes)
case "$gl_cv_func_printf_positions" in
*yes)
! case "$gl_cv_func_snprintf_truncation_c99" in
*yes)
! case "$gl_cv_func_snprintf_retval_c99" in
*yes)
! case "$gl_cv_func_snprintf_directive_n" in
*yes)
! case "$gl_cv_func_vsnprintf_zerosize_c99"
in
*yes)
! # vsnprintf exists and is already
POSIX
! # compliant.
! gl_cv_func_vsnprintf_posix=yes
;;
esac
;;
--- 31,51 ----
*yes)
case "$gl_cv_func_printf_positions" in
*yes)
! case "$gl_cv_func_printf_flag_grouping" in
*yes)
! case "$gl_cv_func_snprintf_truncation_c99" in
*yes)
! case "$gl_cv_func_snprintf_retval_c99" in
*yes)
! case "$gl_cv_func_snprintf_directive_n" in
*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,68 ****
--- 68,74 ----
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
*** m4/vsprintf-posix.m4 11 Apr 2007 23:46:07 -0000 1.4
--- m4/vsprintf-posix.m4 6 May 2007 14:46:05 -0000
***************
*** 1,4 ****
! # vsprintf-posix.m4 serial 3
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,
--- 1,4 ----
! # 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,17 ****
--- 12,18 ----
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,30 ****
*yes)
case "$gl_cv_func_printf_positions" in
*yes)
! # vsprintf exists and is already POSIX compliant.
! gl_cv_func_vsprintf_posix=yes
;;
esac
;;
--- 24,35 ----
*yes)
case "$gl_cv_func_printf_positions" in
*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,43 ****
--- 43,49 ----
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
*** tests/test-snprintf-posix.h 13 Apr 2007 16:56:08 -0000 1.6
--- tests/test-snprintf-posix.h 6 May 2007 14:46:06 -0000
***************
*** 1006,1009 ****
--- 1006,1019 ----
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));
+ }
}
*** tests/test-sprintf-posix.h 13 Apr 2007 16:56:08 -0000 1.6
--- tests/test-sprintf-posix.h 6 May 2007 14:46:06 -0000
***************
*** 992,995 ****
--- 992,1005 ----
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));
+ }
}
*** tests/test-vasnprintf-posix.c 29 Apr 2007 09:15:13 -0000 1.9
--- tests/test-vasnprintf-posix.c 6 May 2007 14:46:06 -0000
***************
*** 1236,1241 ****
--- 1236,1253 ----
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 *
*** tests/test-vasprintf-posix.c 29 Apr 2007 09:15:13 -0000 1.9
--- tests/test-vasprintf-posix.c 6 May 2007 14:46:06 -0000
***************
*** 1217,1222 ****
--- 1217,1234 ----
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
- *printf: support the ' flag,
Bruno Haible <=