From 9be236d67f3d78235c5cbe4381c5dd7b3cddb179 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 9 Jan 2020 01:47:17 +0100 Subject: mbrtoc32: Use the system's mbrtoc32 if it exists and basically works. * m4/mbrtoc32.m4 (gl_MBRTOC32_SANITYCHECK): New macro. (gl_FUNC_MBRTOC32): Require it. Set REPLACE_MBRTOC32 if mbrtoc32 exists but is not working. * lib/mbrtoc32.c: Include hard-locale.h, . (mbrtoc32): If the char32_t encoding and the wchar_t encoding may differ, use the system's mbrtoc32, adding workarounds. * modules/mbrtoc32 (Depends-on): Add hard-locale. * doc/posix-functions/mbrtoc32.texi: Mention the Solaris and native Windows problem. * lib/btoc32.c: Include , . (btoc32): If the char32_t encoding and the wchar_t encoding may differ, use mbrtoc32, not btowc. * modules/btoc32 (Depends-on): Add mbrtoc32. * lib/mbsrtoc32s.c (mbsrtoc32s): If the char32_t encoding and the wchar_t encoding may differ, use mbrtoc32, not mbsrtowcs. * modules/mbsrtoc32s (Depends-on): Update conditions. (configure.ac): Compile mbsrtoc32s-state.c unconditionally. * lib/mbsnrtoc32s.c (mbsnrtoc32s): If the char32_t encoding and the wchar_t encoding may differ, use mbrtoc32, not mbsnrtowcs. * modules/mbsnrtoc32s (Depends-on): Update conditions. (configure.ac): Compile mbsrtoc32s-state.c unconditionally. --- lib/mbsnrtoc32s.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/mbsnrtoc32s.c') diff --git a/lib/mbsnrtoc32s.c b/lib/mbsnrtoc32s.c index 7ba0415949..c0f6e1fb8d 100644 --- a/lib/mbsnrtoc32s.c +++ b/lib/mbsnrtoc32s.c @@ -22,7 +22,9 @@ #include -#if _GL_LARGE_CHAR32_T +#if (HAVE_WORKING_MBRTOC32 && !defined __GLIBC__) || _GL_LARGE_CHAR32_T +/* The char32_t encoding of a multibyte character may be different than its + wchar_t encoding, or char32_t is wider than wchar_t. */ /* For Cygwin >= 1.7 it would be possible to speed this up a bit by cutting the source into chunks, calling mbsnrtowcs on a chunk, then u16_to_u32 on -- cgit v1.2.1