bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mbrtowc: modernize autoconf test


From: Bruno Haible
Subject: mbrtowc: modernize autoconf test
Date: Mon, 25 Nov 2019 20:50:34 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; )

On AIX 7, one of the autoconf tests for mbrtowc resorts to guessing, because
it cannot find traditional locales. This patch uses an UTF-8 locale instead,
when no traditional locale can be found. Thus, it turns out that AIX 7.2
still has the same bugs as AIX 5.1 in this area.


2019-11-24  Bruno Haible  <address@hidden>

        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/doc/posix-functions/mbrtowc.texi b/doc/posix-functions/mbrtowc.texi
index c3a413c..4340c8f 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 255e5b0..16e166b 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 <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
     ])
 ])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]