On 2026-09-01 05:38, Bruno Haible wrote in
<https://lists.gnu.org/r/sed-devel/2026-09/msg00002.html>:
2026-08-24T10:11:31.8275686Z FAIL: testsuite/invalid-mb-seq-UMR.sh
2026-08-31T15:35:29.5572908Z FAIL: testsuite/invalid-mb-seq-UMR.sh
2026-09-01T00:13:34.7881099Z FAIL: testsuite/invalid-mb-seq-UMR.sh
Thanks, I reproduced that on FreeBSD and tracked it down to what appears to be
a longstanding bug in FreeBSD's EUC decoder, something not likely to be fixed
any time soon I suppose. Not sure it's worth working around in Gnulib, or in
altering the sed test cases to skip them on buggy platforms, given that hardly
anybody uses non-UTF-8 multibyte locales on FreeBSD or other platforms that
have the bug. It's worth documenting at least, though, so I installed the
attached to Gnulib.
From 9b87a88f3842b91d8141d60e8ec0e66bf3f554bc Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Fri, 11 Sep 2026 14:51:38 -0700
Subject: [PATCH] doc: document FreeBSD etc issues with EUC
Problem inferred from a bug report by Bruno Haible in:
https://lists.gnu.org/r/sed-devel/2026-09/msg00002.html
---
ChangeLog | 6 ++++++
doc/posix-functions/c16rtomb.texi | 5 +++++
doc/posix-functions/c32rtomb.texi | 5 +++++
doc/posix-functions/fgetwc.texi | 5 +++++
doc/posix-functions/fgetws.texi | 5 +++++
doc/posix-functions/fputwc.texi | 5 +++++
doc/posix-functions/fputws.texi | 5 +++++
doc/posix-functions/mblen.texi | 5 +++++
doc/posix-functions/mbrlen.texi | 5 +++++
doc/posix-functions/mbrtoc16.texi | 5 +++++
doc/posix-functions/mbrtoc32.texi | 5 +++++
doc/posix-functions/mbrtowc.texi | 5 +++++
doc/posix-functions/mbsnrtowcs.texi | 5 +++++
doc/posix-functions/mbsrtowcs.texi | 5 +++++
doc/posix-functions/mbstowcs.texi | 5 +++++
doc/posix-functions/mbtowc.texi | 5 +++++
doc/posix-functions/ungetwc.texi | 5 +++++
doc/posix-functions/wcrtomb.texi | 5 +++++
doc/posix-functions/wcsnrtombs.texi | 5 +++++
doc/posix-functions/wcsrtombs.texi | 5 +++++
doc/posix-functions/wcstombs.texi | 5 +++++
doc/posix-functions/wctomb.texi | 5 +++++
22 files changed, 111 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 879ab6120e..d39ab65d84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-09-11 Paul Eggert <[email protected]>
+
+ doc: document FreeBSD etc issues with EUC
+ Problem inferred from a bug report by Bruno Haible in:
+ https://lists.gnu.org/r/sed-devel/2026-09/msg00002.html
+
2026-09-10 Bruno Haible <[email protected]>
fenv-exceptions-state-c99: Fix for mingw 14 (regression yesterday).
diff --git a/doc/posix-functions/c16rtomb.texi b/doc/posix-functions/c16rtomb.texi
index 59ae3774e1..a07a78771d 100644
--- a/doc/posix-functions/c16rtomb.texi
+++ b/doc/posix-functions/c16rtomb.texi
@@ -17,4 +17,9 @@ Portability problems not fixed by Gnulib:
@item
This function is missing on most non-glibc platforms:
glibc 2.15, macOS 14, FreeBSD 6.4, NetBSD 10.0, OpenBSD 7.3, Minix 3.1.8, AIX 7.1, HP-UX 11.31, Solaris 11.3, Cygwin 3.4.x, mingw, MSVC 9, Android 4.4.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid character
+to an invalid byte sequence instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6.
@end itemize
diff --git a/doc/posix-functions/c32rtomb.texi b/doc/posix-functions/c32rtomb.texi
index 761793fada..782df8ebeb 100644
--- a/doc/posix-functions/c32rtomb.texi
+++ b/doc/posix-functions/c32rtomb.texi
@@ -22,6 +22,11 @@ AIX 7.2.
Portability problems not fixed by Gnulib:
@itemize
@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid character
+to an invalid byte sequence instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6.
+@item
This function is only defined as an inline function on some platforms:
Haiku 2020.
@end itemize
diff --git a/doc/posix-functions/fgetwc.texi b/doc/posix-functions/fgetwc.texi
index c0243fe698..c7ff90f65a 100644
--- a/doc/posix-functions/fgetwc.texi
+++ b/doc/posix-functions/fgetwc.texi
@@ -18,4 +18,9 @@ Minix 3.1.8, Cygwin 1.5.x.
@item
On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
accommodate all Unicode characters.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid byte sequence
+instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
diff --git a/doc/posix-functions/fgetws.texi b/doc/posix-functions/fgetws.texi
index 0aec07332e..987c0bc57a 100644
--- a/doc/posix-functions/fgetws.texi
+++ b/doc/posix-functions/fgetws.texi
@@ -18,4 +18,9 @@ Minix 3.1.8, Cygwin 1.5.x.
@item
On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
accommodate all Unicode characters.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid byte sequence
+instead of returning a null pointer:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
diff --git a/doc/posix-functions/fputwc.texi b/doc/posix-functions/fputwc.texi
index bc062d9302..778f20830f 100644
--- a/doc/posix-functions/fputwc.texi
+++ b/doc/posix-functions/fputwc.texi
@@ -18,4 +18,9 @@ Minix 3.1.8, Cygwin 1.5.x.
@item
On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
accommodate all Unicode characters.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid character
+to an invalid byte sequence instead of returning @code{WEOF}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
diff --git a/doc/posix-functions/fputws.texi b/doc/posix-functions/fputws.texi
index 0113853fc8..c9b39e2f38 100644
--- a/doc/posix-functions/fputws.texi
+++ b/doc/posix-functions/fputws.texi
@@ -19,6 +19,11 @@ Minix 3.1.8, Cygwin 1.5.x.
On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
accommodate all Unicode characters.
@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid character
+to an invalid byte sequence instead of returning @code{-1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
+@item
On some platforms, this function does not set @code{errno} or the
stream error indicator on attempts to write to a read-only stream:
Cygwin 1.7.9.
diff --git a/doc/posix-functions/mblen.texi b/doc/posix-functions/mblen.texi
index 5638e4e935..b177f96007 100644
--- a/doc/posix-functions/mblen.texi
+++ b/doc/posix-functions/mblen.texi
@@ -15,4 +15,9 @@ Portability problems not fixed by Gnulib:
@item
This function is missing on some platforms:
Android 7.1.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly return the length of an invalid byte sequence
+instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
diff --git a/doc/posix-functions/mbrlen.texi b/doc/posix-functions/mbrlen.texi
index 46eb18b146..71f0500a42 100644
--- a/doc/posix-functions/mbrlen.texi
+++ b/doc/posix-functions/mbrlen.texi
@@ -47,4 +47,9 @@ Solaris 9.
Portability problems not fixed by Gnulib:
@itemize
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly return the length of an invalid byte sequence
+instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
diff --git a/doc/posix-functions/mbrtoc16.texi b/doc/posix-functions/mbrtoc16.texi
index c359a34d93..c243a0e5fe 100644
--- a/doc/posix-functions/mbrtoc16.texi
+++ b/doc/posix-functions/mbrtoc16.texi
@@ -61,4 +61,9 @@ cannot be used to determine whether the function is ready to return
another @code{char16_t} value. To do so, instead call @code{mbrtoc16}
again, with an appropriately incremented @code{const char *} argument
and an appropriately decremented @code{size_t} argument.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid byte sequence
+instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6.
@end itemize
diff --git a/doc/posix-functions/mbrtoc32.texi b/doc/posix-functions/mbrtoc32.texi
index 72a373b3e6..cbb12e27a5 100644
--- a/doc/posix-functions/mbrtoc32.texi
+++ b/doc/posix-functions/mbrtoc32.texi
@@ -72,6 +72,11 @@ glibc 2.36.
Portability problems not fixed by Gnulib:
@itemize
@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid byte sequence
+instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6.
+@item
This function is only defined as an inline function on some platforms:
Haiku 2020.
@end itemize
diff --git a/doc/posix-functions/mbrtowc.texi b/doc/posix-functions/mbrtowc.texi
index 5bfcff0f3d..e19e0c90e3 100644
--- a/doc/posix-functions/mbrtowc.texi
+++ b/doc/posix-functions/mbrtowc.texi
@@ -67,6 +67,11 @@ However, the ISO C11 function @code{mbrtoc32}, provided by Gnulib module
@code{mbrtoc32}, operates on 32-bit wide characters and therefore does not have
this limitation.
@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid byte sequence
+instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
+@item
This function does not work with a copied @code{mbstate_t} on some platforms:
@c https://dev.haiku-os.org/ticket/19899
Haiku.
diff --git a/doc/posix-functions/mbsnrtowcs.texi b/doc/posix-functions/mbsnrtowcs.texi
index 543f7b4187..74677ca351 100644
--- a/doc/posix-functions/mbsnrtowcs.texi
+++ b/doc/posix-functions/mbsnrtowcs.texi
@@ -33,6 +33,11 @@ However, the Gnulib function @code{mbsnrtoc32s}, provided by Gnulib module
@code{mbsnrtoc32s}, operates on 32-bit wide characters and therefore does not
have this limitation.
@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid byte sequence
+instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
+@item
The specification is not clear about whether this function should update the
conversion state when the first argument (the destination pointer) is NULL.
The glibc, Mac OS X, FreeBSD implementations do update the state in this case.
diff --git a/doc/posix-functions/mbsrtowcs.texi b/doc/posix-functions/mbsrtowcs.texi
index 3967a33bf5..5cb4fc14cd 100644
--- a/doc/posix-functions/mbsrtowcs.texi
+++ b/doc/posix-functions/mbsrtowcs.texi
@@ -36,6 +36,11 @@ However, the Gnulib function @code{mbsrtoc32s}, provided by Gnulib module
@code{mbsrtoc32s}, operates on 32-bit wide characters and therefore does not
have this limitation.
@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid byte sequence
+instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
+@item
The specification is not clear about whether this function should update the
conversion state when the first argument (the destination pointer) is NULL.
The glibc implementation does not update the state in this case; the macOS
diff --git a/doc/posix-functions/mbstowcs.texi b/doc/posix-functions/mbstowcs.texi
index 24f9a717a7..07672f010c 100644
--- a/doc/posix-functions/mbstowcs.texi
+++ b/doc/posix-functions/mbstowcs.texi
@@ -26,4 +26,9 @@ therefore cannot accommodate all Unicode characters.
However, the Gnulib function @code{mbstoc32s}, provided by Gnulib module
@code{mbstoc32s}, operates on 32-bit wide characters and therefore does not
have this limitation.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid byte sequence
+instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
diff --git a/doc/posix-functions/mbtowc.texi b/doc/posix-functions/mbtowc.texi
index 5874d5a9b4..c716377c2d 100644
--- a/doc/posix-functions/mbtowc.texi
+++ b/doc/posix-functions/mbtowc.texi
@@ -28,4 +28,9 @@ glibc 2.8 (see @url{https://sourceware.org/PR9674}).
@item
On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
accommodate all Unicode characters.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid byte sequence
+instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
diff --git a/doc/posix-functions/ungetwc.texi b/doc/posix-functions/ungetwc.texi
index 1ffaed04ae..e3811fabd9 100644
--- a/doc/posix-functions/ungetwc.texi
+++ b/doc/posix-functions/ungetwc.texi
@@ -18,4 +18,9 @@ Minix 3.1.8, Cygwin 1.5.x.
@item
On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
accommodate all Unicode characters.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly unget an invalid character
+instead of returning @code{WEOF}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
diff --git a/doc/posix-functions/wcrtomb.texi b/doc/posix-functions/wcrtomb.texi
index 9499c7c77f..3b3af21ed8 100644
--- a/doc/posix-functions/wcrtomb.texi
+++ b/doc/posix-functions/wcrtomb.texi
@@ -36,4 +36,9 @@ therefore cannot accommodate all Unicode characters.
However, the ISO C11 function @code{c32rtomb}, provided by Gnulib module
@code{c32rtomb}, operates on 32-bit wide characters and therefore does not have
this limitation.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid character
+to an invalid byte sequence instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
diff --git a/doc/posix-functions/wcsnrtombs.texi b/doc/posix-functions/wcsnrtombs.texi
index e3f488a854..e8f58fd15c 100644
--- a/doc/posix-functions/wcsnrtombs.texi
+++ b/doc/posix-functions/wcsnrtombs.texi
@@ -31,4 +31,9 @@ therefore cannot accommodate all Unicode characters.
However, the Gnulib function @code{c32snrtombs}, provided by Gnulib module
@code{c32snrtombs}, operates on 32-bit wide characters and therefore does not
have this limitation.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid character
+to an invalid byte sequence instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
diff --git a/doc/posix-functions/wcsrtombs.texi b/doc/posix-functions/wcsrtombs.texi
index af5c3be49e..4392c84461 100644
--- a/doc/posix-functions/wcsrtombs.texi
+++ b/doc/posix-functions/wcsrtombs.texi
@@ -29,4 +29,9 @@ therefore cannot accommodate all Unicode characters.
However, the Gnulib function @code{c32srtombs}, provided by Gnulib module
@code{c32srtombs}, operates on 32-bit wide characters and therefore does not
have this limitation.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid character
+to an invalid byte sequence instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
diff --git a/doc/posix-functions/wcstombs.texi b/doc/posix-functions/wcstombs.texi
index 12952159d4..9c17ed1640 100644
--- a/doc/posix-functions/wcstombs.texi
+++ b/doc/posix-functions/wcstombs.texi
@@ -19,4 +19,9 @@ therefore cannot accommodate all Unicode characters.
However, the Gnulib function @code{c32stombs}, provided by Gnulib module
@code{c32stombs}, operates on 32-bit wide characters and therefore does not
have this limitation.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid byte sequence
+instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
diff --git a/doc/posix-functions/wctomb.texi b/doc/posix-functions/wctomb.texi
index 69bcae8053..34be754129 100644
--- a/doc/posix-functions/wctomb.texi
+++ b/doc/posix-functions/wctomb.texi
@@ -19,4 +19,9 @@ Android 4.4.
@item
On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot
accommodate all Unicode characters.
+@item
+On some platforms, when using a multibyte encoding other than UTF-8,
+this function may incorrectly convert an invalid character
+to an invalid byte sequence instead of returning @code{(size_t) -1}:
+FreeBSD 15, NetBSD 11, DragonFly BSD 6, OS X 10.9.
@end itemize
--
2.53.0