]> Savannah Git Hosting - gnulib.git/commit
vasnprintf: Work around two grouping bugs on many platforms.
authorBruno Haible <bruno@clisp.org>
Fri, 11 Apr 2025 22:09:23 +0000 (00:09 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 11 Apr 2025 22:09:23 +0000 (00:09 +0200)
commitf7a63a906ed956838b3e6d5545092cef264e0b6e
tree279f4dda43a2ceacd8815987fc94c8a01c322c9d
parentaef99bf93993103c35e967020385138a672f0f8d
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.
41 files changed:
ChangeLog
doc/glibc-functions/obstack_printf.texi
doc/glibc-functions/obstack_vprintf.texi
doc/posix-functions/asprintf.texi
doc/posix-functions/dprintf.texi
doc/posix-functions/fprintf.texi
doc/posix-functions/fwprintf.texi
doc/posix-functions/printf.texi
doc/posix-functions/snprintf.texi
doc/posix-functions/sprintf.texi
doc/posix-functions/swprintf.texi
doc/posix-functions/vasprintf.texi
doc/posix-functions/vdprintf.texi
doc/posix-functions/vfprintf.texi
doc/posix-functions/vfwprintf.texi
doc/posix-functions/vprintf.texi
doc/posix-functions/vsnprintf.texi
doc/posix-functions/vsprintf.texi
doc/posix-functions/vswprintf.texi
doc/posix-functions/vwprintf.texi
doc/posix-functions/wprintf.texi
lib/vasnprintf.c
m4/dprintf-posix.m4
m4/fprintf-posix.m4
m4/obstack-printf-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/vdprintf-posix.m4
m4/vfprintf-posix.m4
m4/vsnprintf-posix.m4
m4/vsprintf-posix.m4
modules/vasnprintf-posix-tests
modules/vasnwprintf-posix-tests
tests/test-vasnprintf-posix2.c
tests/test-vasnprintf-posix2.sh
tests/test-vasnwprintf-posix2.c
tests/test-vasnwprintf-posix2.sh