]> 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 22:03:56 +0000 (00:03 +0200)
* m4/locale-zh.m4 (gt_LOCALE_ZH_CN): Add a sanity check with mbrtowc.

ChangeLog
m4/locale-zh.m4

index 893510feb43f036b999fe1345dff71bc76782ca6..029d9786a92e72fca52ba95b874984fa0345c6f0 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 94c545906f2ef4615cb027af56b8c7d458fcce62..aad647e6cdd9552ef1a2508a98f963d32f1e055e 100644 (file)
@@ -1,5 +1,5 @@
-# locale-zh.m4 serial 16
-dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc.
+# locale-zh.m4 serial 16.1
+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,
 dnl with or without modifications, as long as this notice is preserved.
@@ -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
 }