+2024-09-01 Bruno Haible <bruno@clisp.org>
+
+ Fix mbscasestr test failure on native Windows with MSVC.
+ * lib/c32to-impl.h (FUNC): On native Windows, ignore the system's
+ towlower/towupper function entirely.
+ * tests/test-c32tolower.c (main): On native Windows, reenable test that
+ previously failed.
+ * tests/test-c32toupper.c (main): Likewise. Disable two other tests on
+ native Windows.
+ * doc/posix-functions/towlower.texi: Mention bug in the native Windows
+ UTF-8 locale.
+ * doc/posix-functions/towupper.texi: Likewise.
+
2024-08-31 Bruno Haible <bruno@clisp.org>
tests: Avoid some test failures on Android.
@code{c32tolower}, operates on 32-bit wide characters and therefore does not
have this limitation.
@item
+On native Windows, in an UTF-8 locale, this function does not even do
+the simple expected mappings, such as from 0x00C9 to 0x00E9.
+@item
This function returns wrong values even for the ASCII characters
in a zh_CN.GB18030 locale on some platforms:
@c https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57339
@code{c32toupper}, operates on 32-bit wide characters and therefore does not
have this limitation.
@item
+On native Windows, in an UTF-8 locale, this function does not even do
+the simple expected mappings, such as from 0x00E9 to 0x00C9.
+@item
This function returns wrong values even for the ASCII characters
in a zh_CN.GB18030 locale on some platforms:
@c https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57339
/* The wchar_t encoding is UTF-16.
The char32_t encoding is UCS-4. */
+# if defined _WIN32 && !defined __CYGWIN__
+ /* On native Windows, in the UTF-8 locale, towlower and towupper are
+ lacking (at least) the mappings for ISO-8859-1 characters, such as
+ 0x00C9 <-> 0x00E9. Since it is expensive to test whether the locale
+ encoding is UTF-8, ignore the system's WCHAR_FUNC altogether. */
+ if (wc != WEOF)
+ return UCS_FUNC (wc);
+ else
+ return wc;
+# else
if (wc == WEOF || wc == (wchar_t) wc)
/* wc is in the range for the tow* functions. */
return WCHAR_FUNC (wc);
else
return UCS_FUNC (wc);
+# endif
#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */
/* char32_t and wchar_t are equivalent. */
mb = for_character ("\302\265", 2);
ASSERT (mb.nbytes == 2);
ASSERT (memcmp (mb.buf, "\302\265", 2) == 0);
- #if !(defined _WIN32 && !defined __CYGWIN__)
/* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */
mb = for_character ("\303\211", 2);
ASSERT (mb.nbytes == 2);
ASSERT (memcmp (mb.buf, "\303\251", 2) == 0);
- #endif
/* U+00DF LATIN SMALL LETTER SHARP S */
mb = for_character ("\303\237", 2);
ASSERT (mb.nbytes == 2);
mb = for_character ("\262", 1);
ASSERT (mb.nbytes == 1);
ASSERT (memcmp (mb.buf, "\262", 1) == 0);
- #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ || defined __sun || defined __CYGWIN__)
+ #if !(defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__))
/* U+00B5 MICRO SIGN */
mb = for_character ("\265", 1);
ASSERT (mb.nbytes == 1);
mb = for_character ("\302\262", 2);
ASSERT (mb.nbytes == 2);
ASSERT (memcmp (mb.buf, "\302\262", 2) == 0);
- #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __OpenBSD__ || defined _AIX || defined __sun || defined __CYGWIN__ || defined __ANDROID__)
+ #if !(defined __GLIBC__ || defined MUSL_LIBC || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __OpenBSD__ || defined _AIX || defined __sun || defined __CYGWIN__ || (defined _WIN32 && !defined __CYGWIN__) || defined __ANDROID__)
/* U+00B5 MICRO SIGN */
mb = for_character ("\302\265", 2);
ASSERT (mb.nbytes == 2);
ASSERT (mb.nbytes == 2);
ASSERT (memcmp (mb.buf, "\303\237", 2) == 0);
#endif
- #if !(defined _WIN32 && !defined __CYGWIN__)
/* U+00E9 LATIN SMALL LETTER E WITH ACUTE */
mb = for_character ("\303\251", 2);
ASSERT (mb.nbytes == 2);
mb = for_character ("\303\277", 2);
ASSERT (mb.nbytes == 2);
ASSERT (memcmp (mb.buf, "\305\270", 2) == 0);
- #endif
/* U+0141 LATIN CAPITAL LETTER L WITH STROKE */
mb = for_character ("\305\201", 2);
ASSERT (mb.nbytes == 2);