Paul Eggert wrote:
> I seem to have jumped the gun on this one; sorry about that. I did the first
> step of your plan by reverting the lib/ and tests/ part of the patch.
OK.
The next step, a test suite enhancement to tests/test-c32rtomb.c, is attached,
based on your added comments
On some platforms, when Gnulib's @code{mbrtoc32} module is used,
in the C locale @code{mbrtoc32} translates bytes in the range 0x80--0xFF
to @code{char32_t} values in the range 0xDF80--0xDFFF,
but when those @code{char32_t} values are given to this function
it fails with @code{EILSEQ} instead of translating them back:
and <https://lists.gnu.org/archive/html/sed-devel/2026-09/msg00005.html>.
Is that what you need for GNU sed?
Currently it fails on: glibc, OpenBSD, Cygwin, mingw, MSVC. (Which is a little
more than the platforms from
<https://lists.gnu.org/archive/html/bug-gnulib/2026-08/msg00308.html>.)
Bruno
diff --git a/tests/test-c32rtomb.c b/tests/test-c32rtomb.c
index 20cbc85baf..b3b4ddc963 100644
--- a/tests/test-c32rtomb.c
+++ b/tests/test-c32rtomb.c
@@ -116,6 +116,23 @@ main (int argc, char *argv[])
{
case '1':
/* C locale; tested above. */
+#if !defined __ANDROID__
+ /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the
+ "C" locale. Furthermore, when you attempt to set the "C" or "POSIX"
+ locale via setlocale(), what you get is a "C" locale with UTF-8
+ encoding, that is, effectively the "C.UTF-8" locale. */
+ /* Check that c32rtomb does the inverse of mbrtoc32, in the C locale.
+ Recall that POSIX:2024 says about mbrtoc32:
+ "In the POSIX locale an [EILSEQ] error cannot occur since all
+ byte values are valid characters."
+ Above we have only tested the ISO C "basic character set". */
+ for (int c = 0; c < 0x100; c++)
+ {
+ ret = c32rtomb (buf, btoc32 (c), NULL);
+ ASSERT (ret == 1);
+ ASSERT (buf[0] == (char) c);
+ }
+#endif
return test_exit_status;
case '2':