1 # iswxdigit.m4 serial 3
2 dnl Copyright (C) 2020-2021 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_ISWXDIGIT],
9 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
10 AC_REQUIRE([gl_WCTYPE_H])
11 AC_REQUIRE([gt_LOCALE_JA])
12 AC_REQUIRE([gt_LOCALE_FR_UTF8])
13 AC_REQUIRE([gt_LOCALE_ZH_CN])
15 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
16 dnl <wctype.h> redefines iswxdigit already.
17 REPLACE_ISWXDIGIT="$REPLACE_ISWCNTRL"
19 AC_CACHE_CHECK([whether iswxdigit is ISO C compliant],
20 [gl_cv_func_iswxdigit_works],
22 dnl Initial guess, used when cross-compiling or when no suitable locale
26 # Guess no on FreeBSD, NetBSD, Solaris, native Windows.
27 freebsd* | dragonfly* | netbsd* | solaris* | mingw*)
28 gl_cv_func_iswxdigit_works="guessing no" ;;
29 # Guess yes otherwise.
30 *) gl_cv_func_iswxdigit_works="guessing yes" ;;
33 if test $LOCALE_JA != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_ZH_CN != none; then
42 /* Returns the value of iswxdigit for the multibyte character s[0..n-1]. */
44 for_character (const char *s, size_t n)
50 memset (&state, '\0', sizeof (mbstate_t));
51 wc = (wchar_t) 0xBADFACE;
52 ret = mbrtowc (&wc, s, n, &state);
56 return iswxdigit (wc);
60 main (int argc, char *argv[])
65 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
67 /* This fails on NetBSD 8.0. */
68 /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */
69 is = for_character ("\243\301", 2);
73 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
75 /* This fails on FreeBSD 13.0. */
76 /* U+0663 ARABIC-INDIC DIGIT THREE */
77 is = for_character ("\331\243", 2);
80 /* This fails on MSVC 14. */
81 /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */
82 is = for_character ("\357\274\241", 3);
86 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
88 /* This fails on Solaris 10, Solaris 11.4. */
89 /* U+FF11 FULLWIDTH DIGIT ONE */
90 is = for_character ("\243\261", 2);
96 [gl_cv_func_iswxdigit_works=yes],
97 [gl_cv_func_iswxdigit_works=no],
101 case "$gl_cv_func_iswxdigit_works" in
103 *) REPLACE_ISWXDIGIT=1 ;;