* lib/mbrtowc.c (rpl_mbrtowc): Enable the s==NULL test also on platforms
that define only MBRTOWC_NUL_RETVAL_BUG or
MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ.
+2026-06-06 Bruno Haible <bruno@clisp.org>
+
+ mbrtowc: Fix handling of s==NULL on all possible platforms.
+ * lib/mbrtowc.c (rpl_mbrtowc): Enable the s==NULL test also on platforms
+ that define only MBRTOWC_NUL_RETVAL_BUG or
+ MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ.
+
2026-06-02 Bruno Haible <bruno@clisp.org>
mbrtowc: Work around a NetBSD bug in UTF-8 locales, part 2.
size_t
rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
-# if (MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG || MBRTOWC_INVALID_UTF8_BUG \
- || (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2))
+ /* It's simpler to handle the case s == NULL upfront, than to worry about
+ this case later, before every test of pwc and n. */
if (s == NULL)
{
pwc = NULL;
s = "";
n = 1;
}
-# endif
# if (MBRTOWC_EMPTY_INPUT_BUG || MBRTOWC_INVALID_UTF8_BUG \
|| (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2 && !__UCLIBC__))