From e4001304a22f18ea5161cb6cbea0ce3438485b9c Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 27 May 2024 13:13:38 +0200 Subject: [PATCH] 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. --- ChangeLog | 5 +++++ m4/locale-zh.m4 | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 30d0dde75f..24d97c021e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024-05-27 Bruno Haible + + 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 euidaccess: Fix test failure on native Windows. diff --git a/m4/locale-zh.m4 b/m4/locale-zh.m4 index f1a58c6360..030bffa924 100644 --- a/m4/locale-zh.m4 +++ b/m4/locale-zh.m4 @@ -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 #include +#include 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 } -- 2.39.5