1 # mbrtowc.m4 serial 37 -*- coding: utf-8 -*-
2 dnl Copyright (C) 2001-2002, 2004-2005, 2008-2020 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,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_MBRTOWC],
10 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
11 AC_REQUIRE([gl_PTHREADLIB])
12 AC_CHECK_HEADERS_ONCE([threads.h])
14 AC_REQUIRE([AC_TYPE_MBSTATE_T])
17 AC_CHECK_FUNCS_ONCE([mbrtowc])
18 if test $ac_cv_func_mbrtowc = no; then
20 AC_CHECK_DECLS([mbrtowc],,, [[
21 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
23 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
24 included before <wchar.h>. */
30 if test $ac_cv_have_decl_mbrtowc = yes; then
31 dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although
32 dnl it does not have the function. Avoid a collision with gnulib's
37 if test $REPLACE_MBSTATE_T = 1; then
44 gl_MBRTOWC_STORES_INCOMPLETE
45 gl_MBRTOWC_EMPTY_INPUT
47 case "$gl_cv_func_mbrtowc_null_arg1" in
49 *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1],
50 [Define if the mbrtowc function has the NULL pwc argument bug.])
54 case "$gl_cv_func_mbrtowc_null_arg2" in
56 *) AC_DEFINE([MBRTOWC_NULL_ARG2_BUG], [1],
57 [Define if the mbrtowc function has the NULL string argument bug.])
61 case "$gl_cv_func_mbrtowc_retval" in
63 *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1],
64 [Define if the mbrtowc function returns a wrong return value.])
68 case "$gl_cv_func_mbrtowc_nul_retval" in
70 *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1],
71 [Define if the mbrtowc function does not return 0 for a NUL character.])
75 case "$gl_cv_func_mbrtowc_stores_incomplete" in
77 *) AC_DEFINE([MBRTOWC_STORES_INCOMPLETE_BUG], [1],
78 [Define if the mbrtowc function stores a wide character when reporting incomplete input.])
82 case "$gl_cv_func_mbrtowc_empty_input" in
84 *) AC_DEFINE([MBRTOWC_EMPTY_INPUT_BUG], [1],
85 [Define if the mbrtowc function does not return (size_t) -2
90 case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in
92 *) AC_DEFINE([MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ], [1],
93 [Define if the mbrtowc function may signal encoding errors in the C locale.])
99 if test $REPLACE_MBSTATE_T = 1; then
101 mingw*) LIB_MBRTOWC= ;;
104 case "$gl_cv_have_weak" in
105 *yes) LIB_MBRTOWC= ;;
106 *) LIB_MBRTOWC="$LIBPTHREAD" ;;
113 dnl LIB_MBRTOWC is expected to be '-pthread' or '-lpthread' on AIX
114 dnl with gcc or xlc, and empty otherwise.
115 AC_SUBST([LIB_MBRTOWC])
118 dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
119 dnl redefines the semantics of the given mbstate_t type.
120 dnl Result is REPLACE_MBSTATE_T.
121 dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to
122 dnl avoid inconsistencies.
124 AC_DEFUN([gl_MBSTATE_T_BROKEN],
126 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
127 AC_REQUIRE([AC_CANONICAL_HOST])
129 AC_REQUIRE([AC_TYPE_MBSTATE_T])
130 AC_CHECK_FUNCS_ONCE([mbsinit])
131 AC_CHECK_FUNCS_ONCE([mbrtowc])
132 dnl On native Windows, we know exactly how mbsinit() behaves and don't need
133 dnl to override it, even if - like on MSVC - mbsinit() is only defined as
134 dnl an inline function, not as a global function.
135 if case "$host_os" in
137 *) test $ac_cv_func_mbsinit = yes ;;
139 && test $ac_cv_func_mbrtowc = yes; then
140 gl_MBRTOWC_INCOMPLETE_STATE
141 gl_MBRTOWC_SANITYCHECK
143 case "$gl_cv_func_mbrtowc_incomplete_state" in
145 *) REPLACE_MBSTATE_T=1 ;;
147 case "$gl_cv_func_mbrtowc_sanitycheck" in
149 *) REPLACE_MBSTATE_T=1 ;;
156 dnl Test whether mbrtowc puts the state into non-initial state when parsing an
157 dnl incomplete multibyte character.
158 dnl Result is gl_cv_func_mbrtowc_incomplete_state.
160 AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
162 AC_REQUIRE([AC_PROG_CC])
163 AC_REQUIRE([gt_LOCALE_JA])
164 AC_REQUIRE([gt_LOCALE_FR_UTF8])
165 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
166 AC_CACHE_CHECK([whether mbrtowc handles incomplete characters],
167 [gl_cv_func_mbrtowc_incomplete_state],
169 dnl Initial guess, used when cross-compiling or when no suitable locale
173 # Guess no on AIX and OSF/1.
174 aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
175 # Guess yes otherwise.
176 *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
179 if test $LOCALE_JA != none; then
184 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
186 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
187 included before <wchar.h>. */
194 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
196 const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
200 memset (&state, '\0', sizeof (mbstate_t));
201 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
202 if (mbsinit (&state))
207 [gl_cv_func_mbrtowc_incomplete_state=yes],
208 [gl_cv_func_mbrtowc_incomplete_state=no],
211 if test $LOCALE_FR_UTF8 != none; then
216 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
218 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
219 included before <wchar.h>. */
226 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
228 const char input[] = "B\303\274\303\237er"; /* "Büßer" */
232 memset (&state, '\0', sizeof (mbstate_t));
233 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
234 if (mbsinit (&state))
239 [gl_cv_func_mbrtowc_incomplete_state=yes],
240 [gl_cv_func_mbrtowc_incomplete_state=no],
247 dnl Test whether mbrtowc works not worse than mbtowc.
248 dnl Result is gl_cv_func_mbrtowc_sanitycheck.
250 AC_DEFUN([gl_MBRTOWC_SANITYCHECK],
252 AC_REQUIRE([AC_PROG_CC])
253 AC_REQUIRE([gt_LOCALE_ZH_CN])
254 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
255 AC_CACHE_CHECK([whether mbrtowc works as well as mbtowc],
256 [gl_cv_func_mbrtowc_sanitycheck],
258 dnl Initial guess, used when cross-compiling or when no suitable locale
262 # Guess no on Solaris 8.
263 solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;;
264 # Guess yes otherwise.
265 *) gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;;
268 if test $LOCALE_ZH_CN != none; then
274 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
276 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
277 included before <wchar.h>. */
284 /* This fails on Solaris 8:
285 mbrtowc returns 2, and sets wc to 0x00F0.
286 mbtowc returns 4 (correct) and sets wc to 0x5EDC. */
287 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
289 char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
293 memset (&state, '\0', sizeof (mbstate_t));
294 if (mbrtowc (&wc, input + 3, 6, &state) != 4
295 && mbtowc (&wc, input + 3, 6) == 4)
300 [gl_cv_func_mbrtowc_sanitycheck=yes],
301 [gl_cv_func_mbrtowc_sanitycheck=no],
307 dnl Test whether mbrtowc supports a NULL pwc argument correctly.
308 dnl Result is gl_cv_func_mbrtowc_null_arg1.
310 AC_DEFUN([gl_MBRTOWC_NULL_ARG1],
312 AC_REQUIRE([AC_PROG_CC])
313 AC_REQUIRE([gt_LOCALE_FR_UTF8])
314 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
315 AC_CACHE_CHECK([whether mbrtowc handles a NULL pwc argument],
316 [gl_cv_func_mbrtowc_null_arg1],
318 dnl Initial guess, used when cross-compiling or when no suitable locale
322 # Guess no on Solaris.
323 solaris*) gl_cv_func_mbrtowc_null_arg1="guessing no" ;;
324 # Guess yes otherwise.
325 *) gl_cv_func_mbrtowc_null_arg1="guessing yes" ;;
328 if test $LOCALE_FR_UTF8 != none; then
334 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
336 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
337 included before <wchar.h>. */
346 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
348 char input[] = "\303\237er";
353 memset (&state, '\0', sizeof (mbstate_t));
354 wc = (wchar_t) 0xBADFACE;
355 ret = mbrtowc (&wc, input, 5, &state);
358 if (!mbsinit (&state))
361 memset (&state, '\0', sizeof (mbstate_t));
362 ret = mbrtowc (NULL, input, 5, &state);
363 if (ret != 2) /* Solaris 7 fails here: ret is -1. */
365 if (!mbsinit (&state))
370 [gl_cv_func_mbrtowc_null_arg1=yes],
371 [gl_cv_func_mbrtowc_null_arg1=no],
377 dnl Test whether mbrtowc supports a NULL string argument correctly.
378 dnl Result is gl_cv_func_mbrtowc_null_arg2.
380 AC_DEFUN([gl_MBRTOWC_NULL_ARG2],
382 AC_REQUIRE([AC_PROG_CC])
383 AC_REQUIRE([gt_LOCALE_FR_UTF8])
384 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
385 AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument],
386 [gl_cv_func_mbrtowc_null_arg2],
388 dnl Initial guess, used when cross-compiling or when no suitable locale
393 osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;;
394 # Guess yes otherwise.
395 *) gl_cv_func_mbrtowc_null_arg2="guessing yes" ;;
398 if test $LOCALE_FR_UTF8 != none; then
403 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
405 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
406 included before <wchar.h>. */
413 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
419 memset (&state, '\0', sizeof (mbstate_t));
420 wc = (wchar_t) 0xBADFACE;
421 mbrtowc (&wc, NULL, 5, &state);
422 /* Check that wc was not modified. */
423 if (wc != (wchar_t) 0xBADFACE)
428 [gl_cv_func_mbrtowc_null_arg2=yes],
429 [gl_cv_func_mbrtowc_null_arg2=no],
435 dnl Test whether mbrtowc, when parsing the end of a multibyte character,
436 dnl correctly returns the number of bytes that were needed to complete the
437 dnl character (not the total number of bytes of the multibyte character).
438 dnl Result is gl_cv_func_mbrtowc_retval.
440 AC_DEFUN([gl_MBRTOWC_RETVAL],
442 AC_REQUIRE([AC_PROG_CC])
443 AC_REQUIRE([gt_LOCALE_FR_UTF8])
444 AC_REQUIRE([gt_LOCALE_JA])
445 AC_REQUIRE([AC_CANONICAL_HOST])
446 AC_CACHE_CHECK([whether mbrtowc has a correct return value],
447 [gl_cv_func_mbrtowc_retval],
449 dnl Initial guess, used when cross-compiling or when no suitable locale
453 # Guess no on HP-UX, Solaris, native Windows.
454 hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;;
455 # Guess yes otherwise.
456 *) gl_cv_func_mbrtowc_retval="guessing yes" ;;
459 if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \
460 || { case "$host_os" in mingw*) true;; *) false;; esac; }; then
465 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
467 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
468 included before <wchar.h>. */
476 int found_some_locale = 0;
477 /* This fails on Solaris. */
478 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
480 char input[] = "B\303\274\303\237er"; /* "Büßer" */
484 memset (&state, '\0', sizeof (mbstate_t));
485 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
488 if (mbrtowc (&wc, input + 2, 5, &state) != 1)
491 found_some_locale = 1;
493 /* This fails on HP-UX 11.11. */
494 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
496 char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
500 memset (&state, '\0', sizeof (mbstate_t));
501 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
504 if (mbrtowc (&wc, input + 2, 5, &state) != 2)
507 found_some_locale = 1;
509 /* This fails on native Windows. */
510 if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL)
512 char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */
516 memset (&state, '\0', sizeof (mbstate_t));
517 if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
520 if (mbrtowc (&wc, input + 4, 4, &state) != 1)
523 found_some_locale = 1;
525 if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL)
527 char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */
531 memset (&state, '\0', sizeof (mbstate_t));
532 if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
535 if (mbrtowc (&wc, input + 4, 4, &state) != 1)
538 found_some_locale = 1;
540 if (setlocale (LC_ALL, "Chinese_China.936") != NULL)
542 char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */
546 memset (&state, '\0', sizeof (mbstate_t));
547 if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
550 if (mbrtowc (&wc, input + 4, 4, &state) != 1)
553 found_some_locale = 1;
555 return (found_some_locale ? result : 77);
557 [gl_cv_func_mbrtowc_retval=yes],
558 [if test $? != 77; then
559 gl_cv_func_mbrtowc_retval=no
567 dnl Test whether mbrtowc, when parsing a NUL character, correctly returns 0.
568 dnl Result is gl_cv_func_mbrtowc_nul_retval.
570 AC_DEFUN([gl_MBRTOWC_NUL_RETVAL],
572 AC_REQUIRE([AC_PROG_CC])
573 AC_REQUIRE([gt_LOCALE_ZH_CN])
574 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
575 AC_CACHE_CHECK([whether mbrtowc returns 0 when parsing a NUL character],
576 [gl_cv_func_mbrtowc_nul_retval],
578 dnl Initial guess, used when cross-compiling or when no suitable locale
582 # Guess no on Solaris 8 and 9.
583 solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;;
584 # Guess yes otherwise.
585 *) gl_cv_func_mbrtowc_nul_retval="guessing yes" ;;
588 if test $LOCALE_ZH_CN != none; then
593 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
595 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
596 included before <wchar.h>. */
603 /* This fails on Solaris 8 and 9. */
604 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
609 memset (&state, '\0', sizeof (mbstate_t));
610 if (mbrtowc (&wc, "", 1, &state) != 0)
615 [gl_cv_func_mbrtowc_nul_retval=yes],
616 [gl_cv_func_mbrtowc_nul_retval=no],
622 dnl Test whether mbrtowc stores a wide character when reporting incomplete
625 AC_DEFUN([gl_MBRTOWC_STORES_INCOMPLETE],
627 AC_REQUIRE([AC_PROG_CC])
628 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
629 AC_CACHE_CHECK([whether mbrtowc stores incomplete characters],
630 [gl_cv_func_mbrtowc_stores_incomplete],
632 dnl Initial guess, used when cross-compiling or when no suitable locale
636 # Guess yes on native Windows.
637 mingw*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;;
638 *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;;
647 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
649 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
650 included before <wchar.h>. */
658 if (setlocale (LC_ALL, "French_France.65001") != NULL)
660 wchar_t wc = (wchar_t) 0xBADFACE;
663 memset (&state, '\0', sizeof (mbstate_t));
664 if (mbrtowc (&wc, "\303", 1, &state) == (size_t)(-2)
665 && wc != (wchar_t) 0xBADFACE)
668 if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL)
670 wchar_t wc = (wchar_t) 0xBADFACE;
673 memset (&state, '\0', sizeof (mbstate_t));
674 if (mbrtowc (&wc, "\226", 1, &state) == (size_t)(-2)
675 && wc != (wchar_t) 0xBADFACE)
678 if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL)
680 wchar_t wc = (wchar_t) 0xBADFACE;
683 memset (&state, '\0', sizeof (mbstate_t));
684 if (mbrtowc (&wc, "\245", 1, &state) == (size_t)(-2)
685 && wc != (wchar_t) 0xBADFACE)
688 if (setlocale (LC_ALL, "Chinese_China.936") != NULL)
690 wchar_t wc = (wchar_t) 0xBADFACE;
693 memset (&state, '\0', sizeof (mbstate_t));
694 if (mbrtowc (&wc, "\261", 1, &state) == (size_t)(-2)
695 && wc != (wchar_t) 0xBADFACE)
700 [gl_cv_func_mbrtowc_stores_incomplete=no],
701 [gl_cv_func_mbrtowc_stores_incomplete=yes],
705 AC_REQUIRE([gt_LOCALE_FR_UTF8])
706 if test $LOCALE_FR_UTF8 != none; then
711 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
713 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
714 included before <wchar.h>. */
721 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
723 wchar_t wc = (wchar_t) 0xBADFACE;
726 memset (&state, '\0', sizeof (mbstate_t));
727 if (mbrtowc (&wc, "\303", 1, &state) == (size_t)(-2)
728 && wc != (wchar_t) 0xBADFACE)
733 [gl_cv_func_mbrtowc_stores_incomplete=no],
734 [gl_cv_func_mbrtowc_stores_incomplete=yes],
742 dnl Test whether mbrtowc returns the correct value on empty input.
744 AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT],
746 AC_REQUIRE([AC_PROG_CC])
747 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
748 AC_CACHE_CHECK([whether mbrtowc works on empty input],
749 [gl_cv_func_mbrtowc_empty_input],
751 dnl Initial guess, used when cross-compiling or when no suitable locale
755 # Guess no on AIX and glibc systems.
756 aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;;
757 # Guess yes on native Windows.
758 mingw*) gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
759 *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
766 static mbstate_t mbs;
770 return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2;
772 [gl_cv_func_mbrtowc_empty_input=yes],
773 [gl_cv_func_mbrtowc_empty_input=no],
778 dnl Test whether mbrtowc reports encoding errors in the C locale.
779 dnl Although POSIX was never intended to allow this, the GNU C Library
780 dnl and other implementations do it. See:
781 dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932
783 AC_DEFUN([gl_MBRTOWC_C_LOCALE],
785 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
786 AC_CACHE_CHECK([whether the C locale is free of encoding errors],
787 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ],
789 dnl Initial guess, used when cross-compiling or when no suitable locale
791 gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal"
795 [[#include <limits.h>
800 char *locale = setlocale (LC_ALL, "C");
803 for (i = CHAR_MIN; i <= CHAR_MAX; i++)
807 mbstate_t mbs = { 0, };
808 size_t ss = mbrtowc (&wc, &c, 1, &mbs);
814 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes],
815 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no],
817 # Guess yes on native Windows.
818 mingw*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;;
824 # Prerequisites of lib/mbrtowc.c and lib/lc-charset-dispatch.c.
825 AC_DEFUN([gl_PREREQ_MBRTOWC], [
826 AC_REQUIRE([AC_C_INLINE])
830 # Prerequisites of lib/mbtowc-lock.c.
831 AC_DEFUN([gl_PREREQ_MBTOWC_LOCK],
839 dnl This is an override of an autoconf macro.
841 AC_DEFUN([AC_FUNC_MBRTOWC],
843 dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
844 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
845 [gl_cv_func_mbrtowc],
848 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
849 included before <wchar.h>.
850 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
851 must be included before <wchar.h>. */
855 #include <wchar.h>]],
860 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
861 [gl_cv_func_mbrtowc=yes],
862 [gl_cv_func_mbrtowc=no])])
863 if test $gl_cv_func_mbrtowc = yes; then
864 AC_DEFINE([HAVE_MBRTOWC], [1],
865 [Define to 1 if mbrtowc and mbstate_t are properly declared.])