3 dnl Copyright (C) 2020-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_ISWXDIGIT],
10 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
11 AC_REQUIRE([gl_WCTYPE_H])
12 AC_REQUIRE([gt_LOCALE_JA])
13 AC_REQUIRE([gt_LOCALE_FR_UTF8])
14 AC_REQUIRE([gt_LOCALE_ZH_CN])
15 AC_REQUIRE([AC_CANONICAL_HOST])
17 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
18 dnl <wctype.h> redefines iswxdigit already.
19 REPLACE_ISWXDIGIT="$REPLACE_ISWCNTRL"
21 AC_CACHE_CHECK([whether iswxdigit is ISO C compliant],
22 [gl_cv_func_iswxdigit_works],
24 dnl Initial guess, used when cross-compiling or when no suitable locale
28 # Guess no on FreeBSD, NetBSD, Solaris, native Windows.
29 freebsd* | dragonfly* | netbsd* | solaris* | mingw* | windows*)
30 gl_cv_func_iswxdigit_works="guessing no" ;;
31 # Guess yes otherwise.
32 *) gl_cv_func_iswxdigit_works="guessing yes" ;;
35 if test $LOCALE_JA != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_ZH_CN != none; then
44 /* Returns the value of iswxdigit for the multibyte character s[0..n-1]. */
46 for_character (const char *s, size_t n)
52 memset (&state, '\0', sizeof (mbstate_t));
53 wc = (wchar_t) 0xBADFACE;
54 ret = mbrtowc (&wc, s, n, &state);
58 return iswxdigit (wc);
62 main (int argc, char *argv[])
67 if (strcmp ("$LOCALE_JA", "none") != 0
68 && setlocale (LC_ALL, "$LOCALE_JA") != NULL)
70 /* This fails on NetBSD 10.0. */
71 /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */
72 is = for_character ("\243\301", 2);
76 if (strcmp ("$LOCALE_FR_UTF8", "none") != 0
77 && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
79 /* This fails on FreeBSD 13.0. */
80 /* U+0663 ARABIC-INDIC DIGIT THREE */
81 is = for_character ("\331\243", 2);
84 /* This fails on NetBSD 10.0, MSVC 14. */
85 /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */
86 is = for_character ("\357\274\241", 3);
90 if (strcmp ("$LOCALE_ZH_CN", "none") != 0
91 && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
93 /* This fails on Solaris 10, Solaris 11.4. */
94 /* U+FF11 FULLWIDTH DIGIT ONE */
95 is = for_character ("\243\261", 2);
101 [gl_cv_func_iswxdigit_works=yes],
102 [gl_cv_func_iswxdigit_works=no],
106 case "$gl_cv_func_iswxdigit_works" in
108 *) REPLACE_ISWXDIGIT=1 ;;