1 # iswxdigit.m4 serial 1
2 dnl Copyright (C) 2020 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
39 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
41 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
42 included before <wchar.h>. */
49 /* Returns the value of iswxdigit for the multibyte character s[0..n-1]. */
51 for_character (const char *s, size_t n)
57 memset (&state, '\0', sizeof (mbstate_t));
58 wc = (wchar_t) 0xBADFACE;
59 ret = mbrtowc (&wc, s, n, &state);
63 return iswxdigit (wc);
67 main (int argc, char *argv[])
72 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
74 /* This fails on NetBSD 8.0. */
75 /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */
76 is = for_character ("\243\301", 2);
80 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
82 /* This fails on FreeBSD 12. */
83 /* U+0663 ARABIC-INDIC DIGIT THREE */
84 is = for_character ("\331\243", 2);
87 /* This fails on MSVC 14. */
88 /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */
89 is = for_character ("\357\274\241", 3);
93 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
95 /* This fails on Solaris 10, Solaris 11.4. */
96 /* U+FF11 FULLWIDTH DIGIT ONE */
97 is = for_character ("\243\261", 2);
103 [gl_cv_func_iswxdigit_works=yes],
104 [gl_cv_func_iswxdigit_works=no],
108 case "$gl_cv_func_iswxdigit_works" in
110 *) REPLACE_ISWXDIGIT=1 ;;