Mercurial > hg > octave-nkf > gnulib-hg
changeset 14345:38e1a5ec714d
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 13 Feb 2011 18:17:22 +0100 |
parents | 5cdebc45677d |
children | dceb65f713b5 |
files | ChangeLog doc/posix-functions/mbsinit.texi lib/mbsinit.c m4/mbsinit.m4 |
diffstat | 4 files changed, 34 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +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.
--- a/doc/posix-functions/mbsinit.texi +++ b/doc/posix-functions/mbsinit.texi @@ -11,6 +11,9 @@ @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:
--- a/lib/mbsinit.c +++ b/lib/mbsinit.c @@ -22,6 +22,18 @@ #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 @@ -45,3 +57,5 @@ return pstate == NULL || pstate[0] == 0; } + +#endif
--- a/m4/mbsinit.m4 +++ b/m4/mbsinit.m4 @@ -1,4 +1,4 @@ -# 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, @@ -7,6 +7,7 @@ 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 @@ -17,6 +18,13 @@ 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