From 11fe27f76c63c14b6f88c815b656f3f72d37ea41 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 30 Mar 2023 13:25:20 +0200 Subject: btowc: Fix behaviour in the C locale. * lib/btowc.c: Include (btowc): Use mbrtowc instead of mbtowc when possible. * m4/btowc.m4 (gl_FUNC_BTOWC): Test for the mingw bug in the C locale. Invoke gl_MBRTOWC_C_LOCALE. If mbrtowc is buggy in the C locale, override also btowc. (gl_PREREQ_BTOWC): Test whether mbrtowc exists. * modules/btowc (Files): Add m4/mbrtowc.m4. (Depends-on): Add mbrtowc. * tests/test-btowc.c (main): Add a test of the C locale, based on tests/test-mbrtowc.c. * tests/test-btowc3.sh: New file, based on tests/test-mbrtowc5.sh. * modules/btowc-tests (Files): Add it. (Makefile.am): Test it. * doc/posix-functions/btowc.texi: Mention the two C locale behaviour bugs and that they are worked around. --- doc/posix-functions/btowc.texi | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/posix-functions/btowc.texi b/doc/posix-functions/btowc.texi index fa1ea9b503..f4ca5d450a 100644 --- a/doc/posix-functions/btowc.texi +++ b/doc/posix-functions/btowc.texi @@ -17,6 +17,14 @@ Cygwin 1.7.2. @item This function does not return WEOF for an EOF argument on some platforms: IRIX 6.5. +@item +In the C or POSIX locales, this function is not consistent with +Gnulib's @code{mbrtowc} and can return @code{WEOF}: +glibc 2.35, MirOS BSD #10. +@item +In the C or POSIX locales, this function is not consistent with @code{mbrtowc} +on some platforms: +mingw. @end itemize Portability problems not fixed by Gnulib: @@ -27,8 +35,4 @@ therefore cannot accommodate all Unicode characters. However, the Gnulib function @code{btoc32}, provided by Gnulib module @code{btoc32}, operates on 32-bit wide characters and therefore does not have this limitation. -@item -In the C or POSIX locales, this function is not consistent with -Gnulib's @code{mbrtowc} and can return @code{WEOF}: -glibc 2.23, MirOS BSD #10. @end itemize -- cgit v1.2.1