summaryrefslogtreecommitdiff
path: root/tests/test-vasnwprintf-posix.c
Commit message (Collapse)AuthorAgeFilesLines
* vasnwprintf-posix tests: Avoid test failure on mingw.Bruno Haible2023-04-071-2/+2
| | | | | * tests/test-vasnwprintf-posix.c (test_function): For mingw, change two expected test results.
* vasnwprintf-posix: Fix behaviour in the C locale.Bruno Haible2023-04-011-0/+42
| | | | | | | | | | | | | | | | * lib/vasnprintf.c (VASNPRINTF): If NEED_WPRINTF_DIRECTIVE_C is set, implement the 'c' directive here. * m4/vasnprintf.m4 (gl_PREREQ_VASNWPRINTF): Invoke gl_MBRTOWC_C_LOCALE. If mbrtowc is buggy in the C locale, define NEED_WPRINTF_DIRECTIVE_C. * modules/vasnwprintf (Files): Add m4/mbrtowc.m4. * tests/test-vasnwprintf-posix.c (test_function): Add tests of %s and %c in the C locale. * doc/posix-functions/fwprintf.texi: Mention the C locale behaviour bug. * doc/posix-functions/swprintf.texi: Likewise. * doc/posix-functions/vfwprintf.texi: Likewise. * doc/posix-functions/vswprintf.texi: Likewise. * doc/posix-functions/vwprintf.texi: Likewise. * doc/posix-functions/wprintf.texi: Likewise.
* vasnprintf-posix: Fix crash in narrow %lc directive (regr. 2023-03-21).Bruno Haible2023-04-011-0/+29
| | | | | | | | | | | * lib/vasnprintf.c (VASNPRINTF): Negative results of local_wcrtomb can now occur; handle them. * tests/test-vasnprintf-posix.c (test_function): Test %lc directive with a wint_t argument that is not a valid wide character. * tests/test-snprintf-posix.h (test_function): Likewise. * tests/test-sprintf-posix.h (test_function): Likewise. * tests/test-vasnwprintf-posix.c (test_function): Likewise. * tests/test-vasprintf-posix.c (test_function): Likewise.
* *printf-posix: ISO C 23: Support size specifiers 'wN' and 'wfN'.Bruno Haible2023-03-241-0/+600
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/printf-args.h: Include <stdint.h>. (arg_type): Add TYPE_[U]INT8_T, ..., TYPE_[U]INT_FAST64_T and TYPE_COUNT_INT8_T_POINTER, ..., TYPE_COUNT_INT_FAST64_T_POINTER. (argument): Add the union members a_[u]int8_t, ..., a_[u]int_fast64_t and a_count_int8_t_pointer, ..., a_count_int_fast64_t_pointer. * lib/printf-args.c: Include <limits.h>. (PRINTF_FETCHARGS): Handle TYPE_[U]INT8_T, ..., TYPE_[U]INT_FAST64_T and TYPE_COUNT_INT8_T_POINTER, ..., TYPE_COUNT_INT_FAST64_T_POINTER. * lib/printf-parse.c (PRINTF_PARSE): Accept only one size specifier, not a sequence of size specifiers. Accept "wN" and "wfN", where N = 8, 16, 32, 64. * lib/vasnprintf.c (MAX_ROOM_NEEDED, VASNPRINTF): Handle the new TYPE_* values as well. * m4/printf.m4 (gl_PRINTF_SIZES_C23): New macro. * m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_IS_POSIX): Require gl_PRINTF_SIZES_C23. Test gl_cv_func_printf_sizes_c23. * m4/dprintf-posix.m4 (gl_FUNC_DPRINTF_IS_POSIX): Likewise. * m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_IS_POSIX): Likewise. * m4/obstack-printf-posix.m4 (gl_FUNC_OBSTACK_PRINTF_IS_POSIX): Likewise. * m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_IS_POSIX): Likewise. * m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_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. * tests/test-vasnprintf-posix.c (test_function): Add tests for size specifiers with %d, %u, %b, %o, %x. * tests/test-snprintf-posix.h (test_function): Likewise. * tests/test-sprintf-posix.h (test_function): Likewise. * tests/test-vasnwprintf-posix.c (test_function): Likewise. * tests/test-vasprintf-posix.c (test_function): Likewise. * modules/vasnprintf (Depends-on): Add limits-h. * modules/vasnwprintf (Depends-on): Add limits-h. * modules/c-vasnprintf (Depends-on): Add limits-h, stdint. * modules/unistdio/u-printf-args (Depends-on): Add stdint, limits-h. * doc/posix-functions/dprintf.texi: Mention the ISO C 23 size specifiers. * doc/posix-functions/fprintf.texi: Likewise. * doc/posix-functions/fwprintf.texi: Likewise. * doc/posix-functions/printf.texi: Likewise. * doc/posix-functions/snprintf.texi: Likewise. * doc/posix-functions/sprintf.texi: Likewise. * doc/posix-functions/swprintf.texi: Likewise. * doc/posix-functions/vdprintf.texi: Likewise. * doc/posix-functions/vfprintf.texi: Likewise. * doc/posix-functions/vfwprintf.texi: Likewise. * doc/posix-functions/vprintf.texi: Likewise. * doc/posix-functions/vsnprintf.texi: Likewise. * doc/posix-functions/vsprintf.texi: Likewise. * doc/posix-functions/vswprintf.texi: Likewise. * doc/posix-functions/vwprintf.texi: Likewise. * doc/posix-functions/wprintf.texi: Likewise.
* *printf-posix: Fix implementation of %b directive.Bruno Haible2023-03-221-0/+374
| | | | | | | | | | | | | | * lib/vasnprintf.c (VASNPRINTF): In the %b directive implementation, fix the precision handling, and ignore the '0' flag when a width and a precision are both present. * tests/test-snprintf-posix.h (test_function): Add test cases for the %x directive and more test cases for the %b directive. * tests/test-sprintf-posix.h (test_function): Likewise. * tests/test-vasnprintf-posix.c (test_function): Likewise. * tests/test-vasnwprintf-posix.c (test_function): Likewise. * tests/test-vasprintf-posix.c (test_function): Likewise. * modules/vasnwprintf-posix-tests (Files): Add m4/musl.m4. (configure.ac): Invoke gl_MUSL_LIBC.
* vasnwprintf: Fix for older platforms without swprintf.Bruno Haible2023-03-211-0/+38
| | | | | | | | | * lib/vasnprintf.c (VASNPRINTF): In the %lc handling, ignore the precision. Convert the snprintf result to a wchar_t[] not by mbsrtowcs, but by a loop that does not stop at NUL characters. * tests/test-vasnwprintf-posix.c (test_function): Add more tests for the %c and %lc directives. * modules/vasnwprintf (Depends-on): Add mbrtowc. Remove mbsrtowcs.
* *printf-posix: ISO C 23: Add %b directive for binary output of integers.Bruno Haible2023-03-171-0/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/printf-parse.c (PRINTF_PARSE): Recognize the 'b' directive. * lib/printf-parse.h: Update comment. * lib/wprintf-parse.h: Likewise. * lib/vasnprintf.c (MAX_ROOM_NEEDED, VASNPRINTF): Add support for the 'b' directive. * m4/printf.m4 (gl_PRINTF_DIRECTIVE_B): New macro. * m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF_DIRECTIVE_B): New macro. (gl_PREREQ_VASNPRINTF_WITH_EXTRAS): Invoke it. * m4/vasnwprintf-posix.m4 (gl_FUNC_VASNWPRINTF_POSIX): Invoke gl_PREREQ_VASNPRINTF_DIRECTIVE_B. * m4/dprintf-posix.m4 (gl_FUNC_DPRINTF_POSIX): Require gl_PRINTF_DIRECTIVE_B and test its result. Invoke gl_PREREQ_VASNPRINTF_DIRECTIVE_B. * m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_POSIX): Likewise. * m4/obstack-printf-posix.m4 (gl_FUNC_OBSTACK_PRINTF_POSIX): Likewise. * m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_POSIX): Likewise. * m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_POSIX): Likewise. * m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_POSIX): Likewise. * m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_POSIX): Likewise. * m4/vdprintf-posix.m4 (gl_FUNC_VDPRINTF_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): Add some tests of the %b directive. * tests/test-sprintf-posix.h (test_function): Likewise. * tests/test-vasnprintf-posix.c (test_function): Likewise. * tests/test-vasnwprintf-posix.c (test_function): Likewise. * tests/test-vasprintf-posix.c (test_function): Likewise. * doc/glibc-functions/asprintf.texi: Mention the 'b' directive. * doc/glibc-functions/obstack_printf.texi: Likewise. * doc/glibc-functions/obstack_vprintf.texi: Likewise. * doc/glibc-functions/vasprintf.texi: Likewise. * doc/posix-functions/dprintf.texi: Likewise. * doc/posix-functions/fprintf.texi: Likewise. * doc/posix-functions/fwprintf.texi: Likewise. * doc/posix-functions/printf.texi: Likewise. * doc/posix-functions/snprintf.texi: Likewise. * doc/posix-functions/sprintf.texi: Likewise. * doc/posix-functions/swprintf.texi: Likewise. * doc/posix-functions/vdprintf.texi: Likewise. * doc/posix-functions/vfprintf.texi: Likewise. * doc/posix-functions/vfwprintf.texi: Likewise. * doc/posix-functions/vprintf.texi: Likewise. * doc/posix-functions/vsnprintf.texi: Likewise. * doc/posix-functions/vsprintf.texi: Likewise. * doc/posix-functions/vswprintf.texi: Likewise. * doc/posix-functions/vwprintf.texi: Likewise. * doc/posix-functions/wprintf.texi: Likewise.
* vasnwprintf-posix: Add tests.Bruno Haible2023-03-171-0/+4029
* tests/test-vasnwprintf-posix.c: New file, based on tests/test-vasnprintf-posix.c. * tests/test-vasnwprintf-posix2.sh: New file, based on tests/test-vasnprintf-posix2.sh. * tests/test-vasnwprintf-posix2.c: New file, based on tests/test-vasnprintf-posix2.c. * tests/test-vasnwprintf-posix3.c: New file, based on tests/test-vasnprintf-posix3.c. * modules/vasnwprintf-posix-tests: New file, based on modules/vasnprintf-posix-tests.