From: Bruno Haible Date: Sun, 24 Nov 2019 19:31:50 +0000 (+0100) Subject: mbrtowc: Modernize autoconf test. X-Git-Tag: v1.0~4572 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=42a045242f9d156becfb4d3fb63dcc607230369a;p=gnulib.git mbrtowc: Modernize autoconf test. * m4/mbrtowc.m4 (gl_MBRTOWC_INCOMPLETE_STATE): Require gt_LOCALE_FR_UTF8. If a traditional Japanese locale is not available, try a UTF-8 locale. * doc/posix-functions/mbrtowc.texi: Update info about AIX. --- diff --git a/ChangeLog b/ChangeLog index 17907bd958..d612dce921 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2019-11-24 Bruno Haible + + mbrtowc: Modernize autoconf test. + * m4/mbrtowc.m4 (gl_MBRTOWC_INCOMPLETE_STATE): Require + gt_LOCALE_FR_UTF8. If a traditional Japanese locale is not available, + try a UTF-8 locale. + * doc/posix-functions/mbrtowc.texi: Update info about AIX. + 2019-11-24 Bruno Haible Fix errors in C++ mode on mingw. diff --git a/doc/posix-functions/mbrtowc.texi b/doc/posix-functions/mbrtowc.texi index c3a413c00a..4340c8f31c 100644 --- a/doc/posix-functions/mbrtowc.texi +++ b/doc/posix-functions/mbrtowc.texi @@ -22,11 +22,11 @@ glibc 2.19. @item This function returns @code{(size_t) -1} instead of @code{(size_t) -2} when the input is empty: -AIX 5.1. +AIX 7.2. @item This function does not put the state into non-initial state when parsing an incomplete multibyte character on some platforms: -AIX 5.1. +AIX 7.2. @item This function returns the total number of bytes that make up the multibyte character, not the number of bytes that were needed to complete the multibyte diff --git a/m4/mbrtowc.m4 b/m4/mbrtowc.m4 index 255e5b02a2..16e166b458 100644 --- a/m4/mbrtowc.m4 +++ b/m4/mbrtowc.m4 @@ -1,4 +1,4 @@ -# mbrtowc.m4 serial 32 -*- coding: utf-8 -*- +# mbrtowc.m4 serial 33 -*- coding: utf-8 -*- dnl Copyright (C) 2001-2002, 2004-2005, 2008-2019 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -126,6 +126,7 @@ AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE], [ AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([gt_LOCALE_JA]) + AC_REQUIRE([gt_LOCALE_FR_UTF8]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([whether mbrtowc handles incomplete characters], [gl_cv_func_mbrtowc_incomplete_state], @@ -171,6 +172,39 @@ int main () [gl_cv_func_mbrtowc_incomplete_state=yes], [gl_cv_func_mbrtowc_incomplete_state=no], [:]) + else + if test $LOCALE_FR_UTF8 != none; then + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +/* Tru64 with Desktop Toolkit C has a bug: must be included before + . + BSD/OS 4.0.1 has a bug: , and must be + included before . */ +#include +#include +#include +#include +int main () +{ + if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) + { + const char input[] = "B\303\274\303\237er"; /* "Büßer" */ + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) + if (mbsinit (&state)) + return 2; + } + return 0; +}]])], + [gl_cv_func_mbrtowc_incomplete_state=yes], + [gl_cv_func_mbrtowc_incomplete_state=no], + [:]) + fi fi ]) ])