]> Savannah Git Hosting - gnulib.git/commitdiff
tests: Don't test on the broken NetBSD 10.0 zh_CN.GB18030 locale.
authorBruno Haible <bruno@clisp.org>
Mon, 27 May 2024 11:13:38 +0000 (13:13 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 31 May 2024 15:43:34 +0000 (17:43 +0200)
* m4/locale-zh.m4 (gt_LOCALE_ZH_CN): Add a sanity check with mbrtowc.

ChangeLog
m4/locale-zh.m4

index 30d0dde75f915727703fc698c8a34b4036a8835e..24d97c021edb9fd424da6550f6cded487c53a117 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-05-27  Bruno Haible  <bruno@clisp.org>
+
+       tests: Don't test on the broken NetBSD 10.0 zh_CN.GB18030 locale.
+       * m4/locale-zh.m4 (gt_LOCALE_ZH_CN): Add a sanity check with mbrtowc.
+
 2024-05-25  Bruno Haible  <bruno@clisp.org>
 
        euidaccess: Fix test failure on native Windows.
index f1a58c63606d36a03ffc91e583326438efcc9b1d..030bffa924c5adbbd7f22fdd04657bf058cb6899 100644 (file)
@@ -1,4 +1,4 @@
-# locale-zh.m4 serial 18
+# locale-zh.m4 serial 19
 dnl Copyright (C) 2003, 2005-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -21,6 +21,7 @@ AC_DEFUN_ONCE([gt_LOCALE_ZH_CN],
 #endif
 #include <stdlib.h>
 #include <string.h>
+#include <wchar.h>
 struct tm t;
 char buf[16];
 int main ()
@@ -79,6 +80,19 @@ int main ()
      single wide character.  This excludes the GB2312 and GBK encodings.  */
   if (mblen ("\203\062\332\066", 5) != 4)
     return 1;
+  /* Check whether mbrtowc accept this character one byte at a time.
+     This excludes NetBSD 10.0.  */
+  if (sizeof (wchar_t) > 2)
+    {
+      wchar_t wc;
+      mbstate_t state;
+      memset (&state, 0, sizeof (state));
+      if (!(mbrtowc (&wc, "\203", 1, &state) == (size_t)(-2)
+            && mbrtowc (&wc, "\062", 1, &state) == (size_t)(-2)
+            && mbrtowc (&wc, "\332", 1, &state) == (size_t)(-2)
+            && mbrtowc (&wc, "\066", 1, &state) == 1))
+        return 1;
+    }
   return 0;
 #endif
 }