Paul Eggert wrote on 2026-05-25: > Thanks for reporting that. I installed the attached somewhat lengthier > patch into Gnulib; please take a look and give it a try.
In a testdir of mbrtowc and mbrlen, this patch causes test failures on CentOS 7 and MSVC. > diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c > index 59320cd51c..f533b554f3 100644 > --- a/lib/mbrtowc.c > +++ b/lib/mbrtowc.c > @@ -119,12 +119,13 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, > mbstate_t *ps) > } > # endif > > -# if MBRTOWC_EMPTY_INPUT_BUG || (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= > 2) > +# if (MBRTOC32_EMPTY_INPUT_BUG || _GL_SMALL_WCHAR_T \ > + || (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2 && !__UCLIBC__)) > if (n == 0) > return (size_t) -2; > # endif Why did you change the condition, to include MBRTOC32_EMPTY_INPUT_BUG which is not even defined for this file? And why did you add _GL_SMALL_WCHAR_T to the condition, without reason? I'm fixing this through the patch below. But I really wish that I would not need one hour of time in order to hunt down such blunders. Can you arrange somehow to make mistakes less frequently? Or can we as a group arrange to detect such mistakes by code review, instead of waiting for the CI to uncover the problems (because there are many kinds of mistakes that the CI will not uncover)? 2026-06-02 Bruno Haible <[email protected]> mbrtowc: Fix handling of n==0 on CentOS 7, MSVC (regr. 2026-05-25). * lib/mbrtowc.c (rpl_mbrtowc): Fix botched condition for the n==0 case. diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c index 48316a068a..116bb09fbd 100644 --- a/lib/mbrtowc.c +++ b/lib/mbrtowc.c @@ -120,7 +120,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) } # endif -# if (MBRTOC32_EMPTY_INPUT_BUG || MBRTOWC_INVALID_UTF8_BUG || _GL_SMALL_WCHAR_T \ +# if (MBRTOWC_EMPTY_INPUT_BUG || MBRTOWC_INVALID_UTF8_BUG \ || (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2 && !__UCLIBC__)) if (n == 0) return (size_t) -2;
