Branch
Hash :
f7a63a90
Author :
Date :
2025-04-12T00:09:23
vasnprintf: Work around two grouping bugs on many platforms. * m4/printf.m4 (gl_PRINTF_FLAG_GROUPING_INT_PRECISION): New macro. (gl_PRINTF_FLAG_GROUPING_MULTIBYTE): New macro. * m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_IS_POSIX): Require gl_PRINTF_FLAG_GROUPING_INT_PRECISION, gl_PRINTF_FLAG_GROUPING_MULTIBYTE. Test gl_cv_func_printf_flag_grouping_int_precision, gl_cv_func_printf_flag_grouping_multibyte. * m4/dprintf-posix.m4 (gl_FUNC_DPRINTF_IS_POSIX): Likewise. * m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_IS_POSIX): Likewise. * m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_IS_POSIX): Likewise. * m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_IS_POSIX): Likewise. * m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_IS_POSIX): Likewise. * m4/vdprintf-posix.m4 (gl_FUNC_VDPRINTF_IS_POSIX): Likewise. * m4/vfprintf-posix.m4 (gl_FUNC_VFPRINTF_IS_POSIX): Likewise. * m4/vsnprintf-posix.m4 (gl_FUNC_VSNPRINTF_IS_POSIX): Likewise. * m4/vsprintf-posix.m4 (gl_FUNC_VSPRINTF_IS_POSIX): Likewise. * m4/obstack-printf-posix.m4 (gl_FUNC_OBSTACK_PRINTF_IS_POSIX): Likewise. * m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF_FLAG_GROUPING): Require gl_PRINTF_FLAG_GROUPING_INT_PRECISION, gl_PRINTF_FLAG_GROUPING_MULTIBYTE. Test gl_cv_func_printf_flag_grouping_int_precision, gl_cv_func_printf_flag_grouping_multibyte. Define the C macro NEED_PRINTF_FLAG_GROUPING_INT. * lib/vasnprintf.c (thousands_separator_char): New function. (THOUSEP_CHAR_MAXLEN): New macro. (thousands_separator_wchar): New function. (THOUSEP_WCHAR_MAXLEN): New macro. (MAX_ROOM_NEEDED): Improve the room estimate for FLAG_GROUP. (VASNPRINTF): Add code for emitting thousands separators in the %f, %F, %g, %G implementations and in the code relies the system's sprintf/snprintf/swprintf function. Test NEED_PRINTF_FLAG_GROUPING and NEED_PRINTF_FLAG_GROUPING_INT where needed. * tests/test-vasnprintf-posix2.c (main): Add tests of the grouping flag. * tests/test-vasnwprintf-posix2.c (main): Likewise. * tests/test-vasnprintf-posix2.sh: Test in both French locales, not only in one of them. * tests/test-vasnwprintf-posix2.sh: Likewise. * modules/vasnprintf-posix-tests (Depends-on): Add localeconv. * modules/vasnwprintf-posix-tests (Depends-on): Likewise. * doc/posix-functions/fprintf.texi: Mention the grouping bug with precision on integers and the grouping bug with a multibyte thousands separator. * doc/posix-functions/vfprintf.texi: Likewise. * doc/posix-functions/printf.texi: Likewise. * doc/posix-functions/vprintf.texi: Likewise. * doc/posix-functions/sprintf.texi: Likewise. * doc/posix-functions/vsprintf.texi: Likewise. * doc/posix-functions/snprintf.texi: Likewise. * doc/posix-functions/vsnprintf.texi: Likewise. * doc/posix-functions/dprintf.texi: Likewise. * doc/posix-functions/vdprintf.texi: Likewise. * doc/posix-functions/fwprintf.texi: Likewise. * doc/posix-functions/vfwprintf.texi: Likewise. * doc/posix-functions/wprintf.texi: Likewise. * doc/posix-functions/vwprintf.texi: Likewise. * doc/posix-functions/swprintf.texi: Likewise. * doc/posix-functions/vswprintf.texi: Likewise. * doc/posix-functions/asprintf.texi: Likewise. * doc/posix-functions/vasprintf.texi: Likewise. * doc/glibc-functions/obstack_printf.texi: Likewise. * doc/glibc-functions/obstack_vprintf.texi: Likewise.
#!/bin/sh
# Test whether a french locale is installed.
: "${LOCALE_FR=fr_FR}"
: "${LOCALE_FR_UTF8=fr_FR.UTF-8}"
if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
if test -f /usr/bin/localedef; then
echo "Skipping test: no french locale is installed"
else
echo "Skipping test: no french locale is supported"
fi
exit 77
fi
if $LC_NUMERIC_IMPLEMENTED; then
:
else
echo "Skipping test: LC_NUMERIC category of locales is not implemented"
exit 77
fi
if test $LOCALE_FR != none; then
LC_ALL=$LOCALE_FR ${CHECKER} ./test-vasnwprintf-posix2${EXEEXT} || exit 1
fi
if test $LOCALE_FR_UTF8 != none; then
LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-vasnwprintf-posix2${EXEEXT} || exit 1
fi
exit 0