diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-10-31 15:27:12 (GMT) |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-10-31 15:27:12 (GMT) |
commit | 5be04ec2ceb1df77afbca4fcbf9e92a712612d6f (patch) | |
tree | 2b2e1c71dffae827c8e45cd4cccc375093d03486 /gl/m4/iswxdigit.m4 | |
parent | 6d1d1dac32841d5ca6ee51bb09b30a6c604b17e2 (diff) | |
download | monitoring-plugins-5be04ec2ceb1df77afbca4fcbf9e92a712612d6f.tar.gz |
Sync with the latest Gnulib code (d4ec02b3cc)refs/pull/2037/head
Diffstat (limited to 'gl/m4/iswxdigit.m4')
-rw-r--r-- | gl/m4/iswxdigit.m4 | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/gl/m4/iswxdigit.m4 b/gl/m4/iswxdigit.m4 new file mode 100644 index 0000000..6085bf6 --- /dev/null +++ b/gl/m4/iswxdigit.m4 | |||
@@ -0,0 +1,111 @@ | |||
1 | # iswxdigit.m4 | ||
2 | # serial 7 | ||
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. | ||
7 | |||
8 | AC_DEFUN([gl_FUNC_ISWXDIGIT], | ||
9 | [ | ||
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]) | ||
16 | |||
17 | if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then | ||
18 | dnl <wctype.h> redefines iswxdigit already. | ||
19 | REPLACE_ISWXDIGIT="$REPLACE_ISWCNTRL" | ||
20 | else | ||
21 | AC_CACHE_CHECK([whether iswxdigit is ISO C compliant], | ||
22 | [gl_cv_func_iswxdigit_works], | ||
23 | [ | ||
24 | dnl Initial guess, used when cross-compiling or when no suitable locale | ||
25 | dnl is present. | ||
26 | changequote(,)dnl | ||
27 | case "$host_os" in | ||
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" ;; | ||
33 | esac | ||
34 | changequote([,])dnl | ||
35 | if test $LOCALE_JA != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_ZH_CN != none; then | ||
36 | AC_RUN_IFELSE( | ||
37 | [AC_LANG_SOURCE([[ | ||
38 | #include <locale.h> | ||
39 | #include <stdlib.h> | ||
40 | #include <string.h> | ||
41 | #include <wchar.h> | ||
42 | #include <wctype.h> | ||
43 | |||
44 | /* Returns the value of iswxdigit for the multibyte character s[0..n-1]. */ | ||
45 | static int | ||
46 | for_character (const char *s, size_t n) | ||
47 | { | ||
48 | mbstate_t state; | ||
49 | wchar_t wc; | ||
50 | size_t ret; | ||
51 | |||
52 | memset (&state, '\0', sizeof (mbstate_t)); | ||
53 | wc = (wchar_t) 0xBADFACE; | ||
54 | ret = mbrtowc (&wc, s, n, &state); | ||
55 | if (ret != n) | ||
56 | abort (); | ||
57 | |||
58 | return iswxdigit (wc); | ||
59 | } | ||
60 | |||
61 | int | ||
62 | main (int argc, char *argv[]) | ||
63 | { | ||
64 | int is; | ||
65 | int result = 0; | ||
66 | |||
67 | if (strcmp ("$LOCALE_JA", "none") != 0 | ||
68 | && setlocale (LC_ALL, "$LOCALE_JA") != NULL) | ||
69 | { | ||
70 | /* This fails on NetBSD 10.0. */ | ||
71 | /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */ | ||
72 | is = for_character ("\243\301", 2); | ||
73 | if (!(is == 0)) | ||
74 | result |= 1; | ||
75 | } | ||
76 | if (strcmp ("$LOCALE_FR_UTF8", "none") != 0 | ||
77 | && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) | ||
78 | { | ||
79 | /* This fails on FreeBSD 13.0. */ | ||
80 | /* U+0663 ARABIC-INDIC DIGIT THREE */ | ||
81 | is = for_character ("\331\243", 2); | ||
82 | if (!(is == 0)) | ||
83 | result |= 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); | ||
87 | if (!(is == 0)) | ||
88 | result |= 4; | ||
89 | } | ||
90 | if (strcmp ("$LOCALE_ZH_CN", "none") != 0 | ||
91 | && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) | ||
92 | { | ||
93 | /* This fails on Solaris 10, Solaris 11.4. */ | ||
94 | /* U+FF11 FULLWIDTH DIGIT ONE */ | ||
95 | is = for_character ("\243\261", 2); | ||
96 | if (!(is == 0)) | ||
97 | result |= 8; | ||
98 | } | ||
99 | return result; | ||
100 | }]])], | ||
101 | [gl_cv_func_iswxdigit_works=yes], | ||
102 | [gl_cv_func_iswxdigit_works=no], | ||
103 | [:]) | ||
104 | fi | ||
105 | ]) | ||
106 | case "$gl_cv_func_iswxdigit_works" in | ||
107 | *yes) ;; | ||
108 | *) REPLACE_ISWXDIGIT=1 ;; | ||
109 | esac | ||
110 | fi | ||
111 | ]) | ||