* m4/mbsinit.m4 (gl_FUNC_MBSINIT): Replace mbsinit also on mingw.
* lib/mbsinit.c (mbsinit): Provide an alternate definition for native
Windows.
* doc/posix-functions/mbsinit.texi: Mention the mingw bug.
+2011-02-13 Bruno Haible <bruno@clisp.org>
+
+ mbsinit: Work around mingw bug.
+ * m4/mbsinit.m4 (gl_FUNC_MBSINIT): Replace mbsinit also on mingw.
+ * lib/mbsinit.c (mbsinit): Provide an alternate definition for native
+ Windows.
+ * doc/posix-functions/mbsinit.texi: Mention the mingw bug.
+
2011-02-13 Bruno Haible <bruno@clisp.org>
mbsinit: Don't crash for a NULL argument.
@item
This function is missing on some platforms:
HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5.
+@item
+This function always returns 1, even in multibyte locales, on some platforms:
+mingw.
@end itemize
Portability problems not fixed by Gnulib:
#include "verify.h"
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+
+/* On native Windows, 'mbstate_t' is defined as 'int'. */
+
+int
+mbsinit (const mbstate_t *ps)
+{
+ return ps == NULL || *ps == 0;
+}
+
+#else
+
/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
and wcrtomb(), wcsrtombs().
We assume that
return pstate == NULL || pstate[0] == 0;
}
+
+#endif
-# mbsinit.m4 serial 4
+# mbsinit.m4 serial 5
dnl Copyright (C) 2008, 2010-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_DEFUN([gl_FUNC_MBSINIT],
[
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
else
if test $REPLACE_MBSTATE_T = 1; then
REPLACE_MBSINIT=1
+ else
+ dnl On mingw, mbsinit() always returns 1, which is inappropriate for
+ dnl states produced by mbrtowc() for an incomplete multibyte character
+ dnl in multibyte locales.
+ case "$host_os" in
+ mingw*) REPLACE_MBSINIT=1 ;;
+ esac
fi
fi
if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then