On CentOS 6 (glibc 2.12) I see this test failure:
FAIL: test-mbrtoc32-regular =========================== ../../gltests/test-mbrtoc32-regular.c:65: assertion 'mbsinit (&state)' failed FAIL test-mbrtoc32-regular (exit status: 134) This patch fixes it, in the same way as for newer glibc versions. 2023-08-16 Bruno Haible <br...@clisp.org> mbrtoc32-regular: Make it work as expected on glibc 2.12. * lib/mbrtoc32.c (mbrtoc32): If necessary, clear the mbstate_t after mbrtowc() returned. diff --git a/lib/mbrtoc32.c b/lib/mbrtoc32.c index 558717d517..0933437a4b 100644 --- a/lib/mbrtoc32.c +++ b/lib/mbrtoc32.c @@ -255,6 +255,14 @@ mbrtoc32 (char32_t *pwc, const char *s, size_t n, mbstate_t *ps) /* char32_t and wchar_t are equivalent. Use mbrtowc(). */ wchar_t wc; size_t ret = mbrtowc (&wc, s, n, ps); + +# if GNULIB_MBRTOC32_REGULAR + /* Ensure that mbrtoc32 is regular. */ + if (ret < (size_t) -2 && ! mbsinit (ps)) + /* This occurs on glibc 2.12. */ + mbszero (ps); +# endif + # if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION if (ret < (size_t) -2 && wc != 0) {