+2020-01-02 Bruno Haible <bruno@clisp.org>
+
+ mbrtowc: Don't replace mbstate_t on MSVC.
+ * m4/mbrtowc.m4 (gl_MBSTATE_T_BROKEN): Require AC_CANONICAL_HOST. Ignore
+ a missing mbsinit function on native Windows.
+ * m4/wcrtomb.m4 (gl_FUNC_WCRTOMB): Strengthen the test, to detect an
+ MSVC bug.
+ * doc/posix-functions/wcrtomb.texi: Mention the MSVC bug.
+
2020-01-02 Bruno Haible <bruno@clisp.org>
setlocale-null: Avoid crashing the MSVC linker.
@item
This function returns 0 when the first argument is NULL in some locales on some platforms:
Solaris 11.3.
+@item
+This function does not ignore the second argument when the first argument is NULL on some platforms:
+MSVC 14.
@end itemize
Portability problems not fixed by Gnulib:
-# mbrtowc.m4 serial 34 -*- coding: utf-8 -*-
+# mbrtowc.m4 serial 35 -*- coding: utf-8 -*-
dnl Copyright (C) 2001-2002, 2004-2005, 2008-2020 Free Software Foundation,
dnl Inc.
dnl This file is free software; the Free Software Foundation
AC_DEFUN([gl_MBSTATE_T_BROKEN],
[
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_TYPE_MBSTATE_T])
AC_CHECK_FUNCS_ONCE([mbsinit])
AC_CHECK_FUNCS_ONCE([mbrtowc])
- if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then
+ dnl On native Windows, we know exactly how mbsinit() behaves and don't need
+ dnl to override it, even if - like on MSVC - mbsinit() is only defined as
+ dnl an inline function, not as a global function.
+ if case "$host_os" in
+ mingw*) true ;;
+ *) test $ac_cv_func_mbsinit = yes ;;
+ esac \
+ && test $ac_cv_func_mbrtowc = yes; then
gl_MBRTOWC_INCOMPLETE_STATE
gl_MBRTOWC_SANITYCHECK
REPLACE_MBSTATE_T=0
-# wcrtomb.m4 serial 14
+# wcrtomb.m4 serial 15
dnl Copyright (C) 2008-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl is present.
changequote(,)dnl
case "$host_os" in
- # Guess no on AIX 4, OSF/1 and Solaris.
- aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;;
- # Guess yes on native Windows.
- mingw*) gl_cv_func_wcrtomb_retval="guessing yes" ;;
- # Guess yes otherwise.
- *) gl_cv_func_wcrtomb_retval="guessing yes" ;;
+ # Guess no on AIX 4, OSF/1, Solaris, native Windows.
+ aix4* | osf* | solaris* | mingw*) gl_cv_func_wcrtomb_retval="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_wcrtomb_retval="guessing yes" ;;
esac
changequote([,])dnl
if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
#include <stdio.h>
#include <time.h>
#include <wchar.h>
+#include <stdlib.h>
int main ()
{
int result = 0;
{
if (wcrtomb (NULL, 0, NULL) != 1)
result |= 2;
+ {
+ wchar_t wc = (wchar_t) 0xBADFACE;
+ if (mbtowc (&wc, "\303\274", 2) == 2)
+ if (wcrtomb (NULL, wc, NULL) != 1)
+ result |= 2;
+ }
}
if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
{