From c8a1f21d3476a1d11bf6306827d61842893c7b0f Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 2 Jan 2020 23:12:57 +0100 Subject: mbrtowc: Fix test failures on MSVC (regression by previous commit). * m4/mbrtowc.m4 (gl_MBRTOWC_STORES_INCOMPLETE): New macro. (gl_FUNC_MBRTOWC): Invoke it. Define MBRTOWC_STORES_INCOMPLETE_BUG. * lib/mbrtowc.c (rpl_mbrtowc): Add workaround for MBRTOWC_STORES_INCOMPLETE_BUG. * doc/posix-functions/mbrtowc.texi: Mention the MSVC bug. --- lib/mbrtowc.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/mbrtowc.c') diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c index 9cc9f5d026..1cdd1af204 100644 --- a/lib/mbrtowc.c +++ b/lib/mbrtowc.c @@ -524,7 +524,13 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) } # endif +# if MBRTOWC_STORES_INCOMPLETE_BUG + ret = mbrtowc (&wc, s, n, ps); + if (ret < (size_t) -2 && pwc != NULL) + *pwc = wc; +# else ret = mbrtowc (pwc, s, n, ps); +# endif # if MBRTOWC_NUL_RETVAL_BUG if (ret < (size_t) -2 && !*pwc) -- cgit v1.2.1