diff options
author | Lorenz <12514511+RincewindsHat@users.noreply.github.com> | 2023-03-11 10:34:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-11 10:34:47 (GMT) |
commit | 75342b53853a898bdd93c7d3da9374115bab6b6d (patch) | |
tree | 0c0af2b796bcdd8ddd42187beb5badb420db8dea /gl/m4/mbrtowc.m4 | |
parent | 6bbe0b7b0f609ecab831dec9be7690842bf0a0fc (diff) | |
parent | 357787868b5201ec3e874e7a225b1c944cbbdb4d (diff) | |
download | monitoring-plugins-75342b53853a898bdd93c7d3da9374115bab6b6d.tar.gz |
Merge branch 'master' into patch-1refs/pull/1842/head
Diffstat (limited to 'gl/m4/mbrtowc.m4')
-rw-r--r-- | gl/m4/mbrtowc.m4 | 358 |
1 files changed, 288 insertions, 70 deletions
diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4 index 4c9f388..bb39304 100644 --- a/gl/m4/mbrtowc.m4 +++ b/gl/m4/mbrtowc.m4 | |||
@@ -1,5 +1,5 @@ | |||
1 | # mbrtowc.m4 serial 25 | 1 | # mbrtowc.m4 serial 38 -*- coding: utf-8 -*- |
2 | dnl Copyright (C) 2001-2002, 2004-2005, 2008-2013 Free Software Foundation, | 2 | dnl Copyright (C) 2001-2002, 2004-2005, 2008-2023 Free Software Foundation, |
3 | dnl Inc. | 3 | dnl Inc. |
4 | dnl This file is free software; the Free Software Foundation | 4 | dnl This file is free software; the Free Software Foundation |
5 | dnl gives unlimited permission to copy and/or distribute it, | 5 | dnl gives unlimited permission to copy and/or distribute it, |
@@ -8,6 +8,8 @@ dnl with or without modifications, as long as this notice is preserved. | |||
8 | AC_DEFUN([gl_FUNC_MBRTOWC], | 8 | AC_DEFUN([gl_FUNC_MBRTOWC], |
9 | [ | 9 | [ |
10 | AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) | 10 | AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) |
11 | AC_REQUIRE([gl_PTHREADLIB]) | ||
12 | AC_CHECK_HEADERS_ONCE([threads.h]) | ||
11 | 13 | ||
12 | AC_REQUIRE([AC_TYPE_MBSTATE_T]) | 14 | AC_REQUIRE([AC_TYPE_MBSTATE_T]) |
13 | gl_MBSTATE_T_BROKEN | 15 | gl_MBSTATE_T_BROKEN |
@@ -16,15 +18,8 @@ AC_DEFUN([gl_FUNC_MBRTOWC], | |||
16 | if test $ac_cv_func_mbrtowc = no; then | 18 | if test $ac_cv_func_mbrtowc = no; then |
17 | HAVE_MBRTOWC=0 | 19 | HAVE_MBRTOWC=0 |
18 | AC_CHECK_DECLS([mbrtowc],,, [[ | 20 | AC_CHECK_DECLS([mbrtowc],,, [[ |
19 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | 21 | #include <wchar.h> |
20 | <wchar.h>. | 22 | ]]) |
21 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | ||
22 | included before <wchar.h>. */ | ||
23 | #include <stddef.h> | ||
24 | #include <stdio.h> | ||
25 | #include <time.h> | ||
26 | #include <wchar.h> | ||
27 | ]]) | ||
28 | if test $ac_cv_have_decl_mbrtowc = yes; then | 23 | if test $ac_cv_have_decl_mbrtowc = yes; then |
29 | dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although | 24 | dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although |
30 | dnl it does not have the function. Avoid a collision with gnulib's | 25 | dnl it does not have the function. Avoid a collision with gnulib's |
@@ -39,6 +34,9 @@ AC_DEFUN([gl_FUNC_MBRTOWC], | |||
39 | gl_MBRTOWC_NULL_ARG2 | 34 | gl_MBRTOWC_NULL_ARG2 |
40 | gl_MBRTOWC_RETVAL | 35 | gl_MBRTOWC_RETVAL |
41 | gl_MBRTOWC_NUL_RETVAL | 36 | gl_MBRTOWC_NUL_RETVAL |
37 | gl_MBRTOWC_STORES_INCOMPLETE | ||
38 | gl_MBRTOWC_EMPTY_INPUT | ||
39 | gl_MBRTOWC_C_LOCALE | ||
42 | case "$gl_cv_func_mbrtowc_null_arg1" in | 40 | case "$gl_cv_func_mbrtowc_null_arg1" in |
43 | *yes) ;; | 41 | *yes) ;; |
44 | *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1], | 42 | *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1], |
@@ -67,8 +65,47 @@ AC_DEFUN([gl_FUNC_MBRTOWC], | |||
67 | REPLACE_MBRTOWC=1 | 65 | REPLACE_MBRTOWC=1 |
68 | ;; | 66 | ;; |
69 | esac | 67 | esac |
68 | case "$gl_cv_func_mbrtowc_stores_incomplete" in | ||
69 | *no) ;; | ||
70 | *) AC_DEFINE([MBRTOWC_STORES_INCOMPLETE_BUG], [1], | ||
71 | [Define if the mbrtowc function stores a wide character when reporting incomplete input.]) | ||
72 | REPLACE_MBRTOWC=1 | ||
73 | ;; | ||
74 | esac | ||
75 | case "$gl_cv_func_mbrtowc_empty_input" in | ||
76 | *yes) ;; | ||
77 | *) AC_DEFINE([MBRTOWC_EMPTY_INPUT_BUG], [1], | ||
78 | [Define if the mbrtowc function does not return (size_t) -2 | ||
79 | for empty input.]) | ||
80 | REPLACE_MBRTOWC=1 | ||
81 | ;; | ||
82 | esac | ||
83 | case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in | ||
84 | *yes) ;; | ||
85 | *) AC_DEFINE([MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ], [1], | ||
86 | [Define if the mbrtowc function may signal encoding errors in the C locale.]) | ||
87 | REPLACE_MBRTOWC=1 | ||
88 | ;; | ||
89 | esac | ||
70 | fi | 90 | fi |
71 | fi | 91 | fi |
92 | if test $REPLACE_MBSTATE_T = 1; then | ||
93 | case "$host_os" in | ||
94 | mingw*) LIB_MBRTOWC= ;; | ||
95 | *) | ||
96 | gl_WEAK_SYMBOLS | ||
97 | case "$gl_cv_have_weak" in | ||
98 | *yes) LIB_MBRTOWC= ;; | ||
99 | *) LIB_MBRTOWC="$LIBPTHREAD" ;; | ||
100 | esac | ||
101 | ;; | ||
102 | esac | ||
103 | else | ||
104 | LIB_MBRTOWC= | ||
105 | fi | ||
106 | dnl LIB_MBRTOWC is expected to be '-pthread' or '-lpthread' on AIX | ||
107 | dnl with gcc or xlc, and empty otherwise. | ||
108 | AC_SUBST([LIB_MBRTOWC]) | ||
72 | ]) | 109 | ]) |
73 | 110 | ||
74 | dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that | 111 | dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that |
@@ -80,11 +117,19 @@ dnl avoid inconsistencies. | |||
80 | AC_DEFUN([gl_MBSTATE_T_BROKEN], | 117 | AC_DEFUN([gl_MBSTATE_T_BROKEN], |
81 | [ | 118 | [ |
82 | AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) | 119 | AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) |
120 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
83 | 121 | ||
84 | AC_REQUIRE([AC_TYPE_MBSTATE_T]) | 122 | AC_REQUIRE([AC_TYPE_MBSTATE_T]) |
85 | AC_CHECK_FUNCS_ONCE([mbsinit]) | 123 | AC_CHECK_FUNCS_ONCE([mbsinit]) |
86 | AC_CHECK_FUNCS_ONCE([mbrtowc]) | 124 | AC_CHECK_FUNCS_ONCE([mbrtowc]) |
87 | if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then | 125 | dnl On native Windows, we know exactly how mbsinit() behaves and don't need |
126 | dnl to override it, even if - like on MSVC - mbsinit() is only defined as | ||
127 | dnl an inline function, not as a global function. | ||
128 | if case "$host_os" in | ||
129 | mingw*) true ;; | ||
130 | *) test $ac_cv_func_mbsinit = yes ;; | ||
131 | esac \ | ||
132 | && test $ac_cv_func_mbrtowc = yes; then | ||
88 | gl_MBRTOWC_INCOMPLETE_STATE | 133 | gl_MBRTOWC_INCOMPLETE_STATE |
89 | gl_MBRTOWC_SANITYCHECK | 134 | gl_MBRTOWC_SANITYCHECK |
90 | REPLACE_MBSTATE_T=0 | 135 | REPLACE_MBSTATE_T=0 |
@@ -109,6 +154,7 @@ AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE], | |||
109 | [ | 154 | [ |
110 | AC_REQUIRE([AC_PROG_CC]) | 155 | AC_REQUIRE([AC_PROG_CC]) |
111 | AC_REQUIRE([gt_LOCALE_JA]) | 156 | AC_REQUIRE([gt_LOCALE_JA]) |
157 | AC_REQUIRE([gt_LOCALE_FR_UTF8]) | ||
112 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | 158 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
113 | AC_CACHE_CHECK([whether mbrtowc handles incomplete characters], | 159 | AC_CACHE_CHECK([whether mbrtowc handles incomplete characters], |
114 | [gl_cv_func_mbrtowc_incomplete_state], | 160 | [gl_cv_func_mbrtowc_incomplete_state], |
@@ -128,13 +174,6 @@ changequote([,])dnl | |||
128 | [AC_LANG_SOURCE([[ | 174 | [AC_LANG_SOURCE([[ |
129 | #include <locale.h> | 175 | #include <locale.h> |
130 | #include <string.h> | 176 | #include <string.h> |
131 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | ||
132 | <wchar.h>. | ||
133 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | ||
134 | included before <wchar.h>. */ | ||
135 | #include <stddef.h> | ||
136 | #include <stdio.h> | ||
137 | #include <time.h> | ||
138 | #include <wchar.h> | 177 | #include <wchar.h> |
139 | int main () | 178 | int main () |
140 | { | 179 | { |
@@ -147,13 +186,39 @@ int main () | |||
147 | memset (&state, '\0', sizeof (mbstate_t)); | 186 | memset (&state, '\0', sizeof (mbstate_t)); |
148 | if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) | 187 | if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) |
149 | if (mbsinit (&state)) | 188 | if (mbsinit (&state)) |
150 | return 1; | 189 | return 2; |
190 | } | ||
191 | return 0; | ||
192 | }]])], | ||
193 | [gl_cv_func_mbrtowc_incomplete_state=yes], | ||
194 | [gl_cv_func_mbrtowc_incomplete_state=no], | ||
195 | [:]) | ||
196 | else | ||
197 | if test $LOCALE_FR_UTF8 != none; then | ||
198 | AC_RUN_IFELSE( | ||
199 | [AC_LANG_SOURCE([[ | ||
200 | #include <locale.h> | ||
201 | #include <string.h> | ||
202 | #include <wchar.h> | ||
203 | int main () | ||
204 | { | ||
205 | if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) | ||
206 | { | ||
207 | const char input[] = "B\303\274\303\237er"; /* "Büßer" */ | ||
208 | mbstate_t state; | ||
209 | wchar_t wc; | ||
210 | |||
211 | memset (&state, '\0', sizeof (mbstate_t)); | ||
212 | if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) | ||
213 | if (mbsinit (&state)) | ||
214 | return 2; | ||
151 | } | 215 | } |
152 | return 0; | 216 | return 0; |
153 | }]])], | 217 | }]])], |
154 | [gl_cv_func_mbrtowc_incomplete_state=yes], | 218 | [gl_cv_func_mbrtowc_incomplete_state=yes], |
155 | [gl_cv_func_mbrtowc_incomplete_state=no], | 219 | [gl_cv_func_mbrtowc_incomplete_state=no], |
156 | [:]) | 220 | [:]) |
221 | fi | ||
157 | fi | 222 | fi |
158 | ]) | 223 | ]) |
159 | ]) | 224 | ]) |
@@ -185,13 +250,6 @@ changequote([,])dnl | |||
185 | #include <locale.h> | 250 | #include <locale.h> |
186 | #include <stdlib.h> | 251 | #include <stdlib.h> |
187 | #include <string.h> | 252 | #include <string.h> |
188 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | ||
189 | <wchar.h>. | ||
190 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | ||
191 | included before <wchar.h>. */ | ||
192 | #include <stddef.h> | ||
193 | #include <stdio.h> | ||
194 | #include <time.h> | ||
195 | #include <wchar.h> | 253 | #include <wchar.h> |
196 | int main () | 254 | int main () |
197 | { | 255 | { |
@@ -207,7 +265,7 @@ int main () | |||
207 | memset (&state, '\0', sizeof (mbstate_t)); | 265 | memset (&state, '\0', sizeof (mbstate_t)); |
208 | if (mbrtowc (&wc, input + 3, 6, &state) != 4 | 266 | if (mbrtowc (&wc, input + 3, 6, &state) != 4 |
209 | && mbtowc (&wc, input + 3, 6) == 4) | 267 | && mbtowc (&wc, input + 3, 6) == 4) |
210 | return 1; | 268 | return 2; |
211 | } | 269 | } |
212 | return 0; | 270 | return 0; |
213 | }]])], | 271 | }]])], |
@@ -245,13 +303,6 @@ changequote([,])dnl | |||
245 | #include <locale.h> | 303 | #include <locale.h> |
246 | #include <stdlib.h> | 304 | #include <stdlib.h> |
247 | #include <string.h> | 305 | #include <string.h> |
248 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | ||
249 | <wchar.h>. | ||
250 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | ||
251 | included before <wchar.h>. */ | ||
252 | #include <stddef.h> | ||
253 | #include <stdio.h> | ||
254 | #include <time.h> | ||
255 | #include <wchar.h> | 306 | #include <wchar.h> |
256 | int main () | 307 | int main () |
257 | { | 308 | { |
@@ -314,13 +365,6 @@ changequote([,])dnl | |||
314 | [AC_LANG_SOURCE([[ | 365 | [AC_LANG_SOURCE([[ |
315 | #include <locale.h> | 366 | #include <locale.h> |
316 | #include <string.h> | 367 | #include <string.h> |
317 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | ||
318 | <wchar.h>. | ||
319 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | ||
320 | included before <wchar.h>. */ | ||
321 | #include <stddef.h> | ||
322 | #include <stdio.h> | ||
323 | #include <time.h> | ||
324 | #include <wchar.h> | 368 | #include <wchar.h> |
325 | int main () | 369 | int main () |
326 | { | 370 | { |
@@ -335,7 +379,7 @@ int main () | |||
335 | mbrtowc (&wc, NULL, 5, &state); | 379 | mbrtowc (&wc, NULL, 5, &state); |
336 | /* Check that wc was not modified. */ | 380 | /* Check that wc was not modified. */ |
337 | if (wc != (wchar_t) 0xBADFACE) | 381 | if (wc != (wchar_t) 0xBADFACE) |
338 | return 1; | 382 | return 2; |
339 | } | 383 | } |
340 | return 0; | 384 | return 0; |
341 | }]])], | 385 | }]])], |
@@ -376,13 +420,6 @@ changequote([,])dnl | |||
376 | [AC_LANG_SOURCE([[ | 420 | [AC_LANG_SOURCE([[ |
377 | #include <locale.h> | 421 | #include <locale.h> |
378 | #include <string.h> | 422 | #include <string.h> |
379 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | ||
380 | <wchar.h>. | ||
381 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | ||
382 | included before <wchar.h>. */ | ||
383 | #include <stddef.h> | ||
384 | #include <stdio.h> | ||
385 | #include <time.h> | ||
386 | #include <wchar.h> | 423 | #include <wchar.h> |
387 | int main () | 424 | int main () |
388 | { | 425 | { |
@@ -504,13 +541,6 @@ changequote([,])dnl | |||
504 | [AC_LANG_SOURCE([[ | 541 | [AC_LANG_SOURCE([[ |
505 | #include <locale.h> | 542 | #include <locale.h> |
506 | #include <string.h> | 543 | #include <string.h> |
507 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | ||
508 | <wchar.h>. | ||
509 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | ||
510 | included before <wchar.h>. */ | ||
511 | #include <stddef.h> | ||
512 | #include <stdio.h> | ||
513 | #include <time.h> | ||
514 | #include <wchar.h> | 544 | #include <wchar.h> |
515 | int main () | 545 | int main () |
516 | { | 546 | { |
@@ -522,7 +552,7 @@ int main () | |||
522 | 552 | ||
523 | memset (&state, '\0', sizeof (mbstate_t)); | 553 | memset (&state, '\0', sizeof (mbstate_t)); |
524 | if (mbrtowc (&wc, "", 1, &state) != 0) | 554 | if (mbrtowc (&wc, "", 1, &state) != 0) |
525 | return 1; | 555 | return 2; |
526 | } | 556 | } |
527 | return 0; | 557 | return 0; |
528 | }]])], | 558 | }]])], |
@@ -533,11 +563,206 @@ int main () | |||
533 | ]) | 563 | ]) |
534 | ]) | 564 | ]) |
535 | 565 | ||
536 | # Prerequisites of lib/mbrtowc.c. | 566 | dnl Test whether mbrtowc stores a wide character when reporting incomplete |
567 | dnl input. | ||
568 | |||
569 | AC_DEFUN([gl_MBRTOWC_STORES_INCOMPLETE], | ||
570 | [ | ||
571 | AC_REQUIRE([AC_PROG_CC]) | ||
572 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | ||
573 | AC_CACHE_CHECK([whether mbrtowc stores incomplete characters], | ||
574 | [gl_cv_func_mbrtowc_stores_incomplete], | ||
575 | [ | ||
576 | dnl Initial guess, used when cross-compiling or when no suitable locale | ||
577 | dnl is present. | ||
578 | changequote(,)dnl | ||
579 | case "$host_os" in | ||
580 | # Guess yes on native Windows. | ||
581 | mingw*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;; | ||
582 | *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;; | ||
583 | esac | ||
584 | changequote([,])dnl | ||
585 | case "$host_os" in | ||
586 | mingw*) | ||
587 | AC_RUN_IFELSE( | ||
588 | [AC_LANG_SOURCE([[ | ||
589 | #include <locale.h> | ||
590 | #include <string.h> | ||
591 | #include <wchar.h> | ||
592 | int main () | ||
593 | { | ||
594 | int result = 0; | ||
595 | if (setlocale (LC_ALL, "French_France.65001") != NULL) | ||
596 | { | ||
597 | wchar_t wc = (wchar_t) 0xBADFACE; | ||
598 | mbstate_t state; | ||
599 | |||
600 | memset (&state, '\0', sizeof (mbstate_t)); | ||
601 | if (mbrtowc (&wc, "\303", 1, &state) == (size_t)(-2) | ||
602 | && wc != (wchar_t) 0xBADFACE) | ||
603 | result |= 1; | ||
604 | } | ||
605 | if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL) | ||
606 | { | ||
607 | wchar_t wc = (wchar_t) 0xBADFACE; | ||
608 | mbstate_t state; | ||
609 | |||
610 | memset (&state, '\0', sizeof (mbstate_t)); | ||
611 | if (mbrtowc (&wc, "\226", 1, &state) == (size_t)(-2) | ||
612 | && wc != (wchar_t) 0xBADFACE) | ||
613 | result |= 2; | ||
614 | } | ||
615 | if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL) | ||
616 | { | ||
617 | wchar_t wc = (wchar_t) 0xBADFACE; | ||
618 | mbstate_t state; | ||
619 | |||
620 | memset (&state, '\0', sizeof (mbstate_t)); | ||
621 | if (mbrtowc (&wc, "\245", 1, &state) == (size_t)(-2) | ||
622 | && wc != (wchar_t) 0xBADFACE) | ||
623 | result |= 4; | ||
624 | } | ||
625 | if (setlocale (LC_ALL, "Chinese_China.936") != NULL) | ||
626 | { | ||
627 | wchar_t wc = (wchar_t) 0xBADFACE; | ||
628 | mbstate_t state; | ||
629 | |||
630 | memset (&state, '\0', sizeof (mbstate_t)); | ||
631 | if (mbrtowc (&wc, "\261", 1, &state) == (size_t)(-2) | ||
632 | && wc != (wchar_t) 0xBADFACE) | ||
633 | result |= 8; | ||
634 | } | ||
635 | return result; | ||
636 | }]])], | ||
637 | [gl_cv_func_mbrtowc_stores_incomplete=no], | ||
638 | [gl_cv_func_mbrtowc_stores_incomplete=yes], | ||
639 | [:]) | ||
640 | ;; | ||
641 | *) | ||
642 | AC_REQUIRE([gt_LOCALE_FR_UTF8]) | ||
643 | if test $LOCALE_FR_UTF8 != none; then | ||
644 | AC_RUN_IFELSE( | ||
645 | [AC_LANG_SOURCE([[ | ||
646 | #include <locale.h> | ||
647 | #include <string.h> | ||
648 | #include <wchar.h> | ||
649 | int main () | ||
650 | { | ||
651 | if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) | ||
652 | { | ||
653 | wchar_t wc = (wchar_t) 0xBADFACE; | ||
654 | mbstate_t state; | ||
655 | |||
656 | memset (&state, '\0', sizeof (mbstate_t)); | ||
657 | if (mbrtowc (&wc, "\303", 1, &state) == (size_t)(-2) | ||
658 | && wc != (wchar_t) 0xBADFACE) | ||
659 | return 1; | ||
660 | } | ||
661 | return 0; | ||
662 | }]])], | ||
663 | [gl_cv_func_mbrtowc_stores_incomplete=no], | ||
664 | [gl_cv_func_mbrtowc_stores_incomplete=yes], | ||
665 | [:]) | ||
666 | fi | ||
667 | ;; | ||
668 | esac | ||
669 | ]) | ||
670 | ]) | ||
671 | |||
672 | dnl Test whether mbrtowc returns the correct value on empty input. | ||
673 | |||
674 | AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT], | ||
675 | [ | ||
676 | AC_REQUIRE([AC_PROG_CC]) | ||
677 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | ||
678 | AC_CACHE_CHECK([whether mbrtowc works on empty input], | ||
679 | [gl_cv_func_mbrtowc_empty_input], | ||
680 | [ | ||
681 | dnl Initial guess, used when cross-compiling or when no suitable locale | ||
682 | dnl is present. | ||
683 | changequote(,)dnl | ||
684 | case "$host_os" in | ||
685 | # Guess no on AIX and glibc systems. | ||
686 | aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; | ||
687 | # Guess yes on native Windows. | ||
688 | mingw*) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; | ||
689 | *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; | ||
690 | esac | ||
691 | changequote([,])dnl | ||
692 | AC_RUN_IFELSE( | ||
693 | [AC_LANG_SOURCE([[ | ||
694 | #include <wchar.h> | ||
695 | static wchar_t wc; | ||
696 | static mbstate_t mbs; | ||
697 | int | ||
698 | main (void) | ||
699 | { | ||
700 | return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2; | ||
701 | }]])], | ||
702 | [gl_cv_func_mbrtowc_empty_input=yes], | ||
703 | [gl_cv_func_mbrtowc_empty_input=no], | ||
704 | [:]) | ||
705 | ]) | ||
706 | ]) | ||
707 | |||
708 | dnl Test whether mbrtowc reports encoding errors in the C locale. | ||
709 | dnl Although POSIX was never intended to allow this, the GNU C Library | ||
710 | dnl and other implementations do it. See: | ||
711 | dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932 | ||
712 | |||
713 | AC_DEFUN([gl_MBRTOWC_C_LOCALE], | ||
714 | [ | ||
715 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | ||
716 | AC_CACHE_CHECK([whether the C locale is free of encoding errors], | ||
717 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ], | ||
718 | [ | ||
719 | dnl Initial guess, used when cross-compiling or when no suitable locale | ||
720 | dnl is present. | ||
721 | gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal" | ||
722 | |||
723 | AC_RUN_IFELSE( | ||
724 | [AC_LANG_PROGRAM( | ||
725 | [[#include <limits.h> | ||
726 | #include <locale.h> | ||
727 | #include <wchar.h> | ||
728 | ]], [[ | ||
729 | int i; | ||
730 | char *locale = setlocale (LC_ALL, "C"); | ||
731 | if (! locale) | ||
732 | return 2; | ||
733 | for (i = CHAR_MIN; i <= CHAR_MAX; i++) | ||
734 | { | ||
735 | char c = i; | ||
736 | wchar_t wc; | ||
737 | mbstate_t mbs = { 0, }; | ||
738 | size_t ss = mbrtowc (&wc, &c, 1, &mbs); | ||
739 | if (1 < ss) | ||
740 | return 3; | ||
741 | } | ||
742 | return 0; | ||
743 | ]])], | ||
744 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes], | ||
745 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no], | ||
746 | [case "$host_os" in | ||
747 | # Guess yes on native Windows. | ||
748 | mingw*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;; | ||
749 | esac | ||
750 | ]) | ||
751 | ]) | ||
752 | ]) | ||
753 | |||
754 | # Prerequisites of lib/mbrtowc.c and lib/lc-charset-dispatch.c. | ||
537 | AC_DEFUN([gl_PREREQ_MBRTOWC], [ | 755 | AC_DEFUN([gl_PREREQ_MBRTOWC], [ |
756 | AC_REQUIRE([AC_C_INLINE]) | ||
538 | : | 757 | : |
539 | ]) | 758 | ]) |
540 | 759 | ||
760 | # Prerequisites of lib/mbtowc-lock.c. | ||
761 | AC_DEFUN([gl_PREREQ_MBTOWC_LOCK], | ||
762 | [ | ||
763 | gl_VISIBILITY | ||
764 | ]) | ||
765 | |||
541 | 766 | ||
542 | dnl From Paul Eggert | 767 | dnl From Paul Eggert |
543 | 768 | ||
@@ -547,24 +772,17 @@ AC_DEFUN([AC_FUNC_MBRTOWC], | |||
547 | [ | 772 | [ |
548 | dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60. | 773 | dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60. |
549 | AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared], | 774 | AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared], |
550 | gl_cv_func_mbrtowc, | 775 | [gl_cv_func_mbrtowc], |
551 | [AC_LINK_IFELSE( | 776 | [AC_LINK_IFELSE( |
552 | [AC_LANG_PROGRAM( | 777 | [AC_LANG_PROGRAM( |
553 | [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be | 778 | [[#include <wchar.h>]], |
554 | included before <wchar.h>. | ||
555 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> | ||
556 | must be included before <wchar.h>. */ | ||
557 | #include <stddef.h> | ||
558 | #include <stdio.h> | ||
559 | #include <time.h> | ||
560 | #include <wchar.h>]], | ||
561 | [[wchar_t wc; | 779 | [[wchar_t wc; |
562 | char const s[] = ""; | 780 | char const s[] = ""; |
563 | size_t n = 1; | 781 | size_t n = 1; |
564 | mbstate_t state; | 782 | mbstate_t state; |
565 | return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])], | 783 | return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])], |
566 | gl_cv_func_mbrtowc=yes, | 784 | [gl_cv_func_mbrtowc=yes], |
567 | gl_cv_func_mbrtowc=no)]) | 785 | [gl_cv_func_mbrtowc=no])]) |
568 | if test $gl_cv_func_mbrtowc = yes; then | 786 | if test $gl_cv_func_mbrtowc = yes; then |
569 | AC_DEFINE([HAVE_MBRTOWC], [1], | 787 | AC_DEFINE([HAVE_MBRTOWC], [1], |
570 | [Define to 1 if mbrtowc and mbstate_t are properly declared.]) | 788 | [Define to 1 if mbrtowc and mbstate_t are properly declared.]) |