]> Savannah Git Hosting - gnulib.git/commitdiff
mbrtowc: Modernize autoconf test.
authorBruno Haible <bruno@clisp.org>
Sun, 24 Nov 2019 19:31:50 +0000 (20:31 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 24 Nov 2019 19:31:50 +0000 (20:31 +0100)
* 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.

ChangeLog
doc/posix-functions/mbrtowc.texi
m4/mbrtowc.m4

index 17907bd958ab5a3da39e58815f3b5d332eeb3d4f..d612dce92134c64c3fed977115bfb4b638906512 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-11-24  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        Fix errors in C++ mode on mingw.
index c3a413c00a5819406b997bd84d9a8f4c5a229cfc..4340c8f31c18dc0de8e8dd5455c0659fa7a65a56 100644 (file)
@@ -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
index 255e5b02a2a87ead91558ada3130d76c3648b336..16e166b458dfac48943fcf1a9296c64608172cb6 100644 (file)
@@ -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 <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+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
     ])
 ])