re-mark 1.29b-2 as not yet uploaded (merge madness!)
[debian/tar] / m4 / mbrtowc.m4
1 # mbrtowc.m4 serial 26
2 dnl Copyright (C) 2001-2002, 2004-2005, 2008-2015 Free Software Foundation,
3 dnl 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_MBRTOWC],
9 [
10   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
11
12   AC_REQUIRE([AC_TYPE_MBSTATE_T])
13   gl_MBSTATE_T_BROKEN
14
15   AC_CHECK_FUNCS_ONCE([mbrtowc])
16   if test $ac_cv_func_mbrtowc = no; then
17     HAVE_MBRTOWC=0
18     AC_CHECK_DECLS([mbrtowc],,, [[
19 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
20    <wchar.h>.
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
29       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
31       dnl replacement.
32       REPLACE_MBRTOWC=1
33     fi
34   else
35     if test $REPLACE_MBSTATE_T = 1; then
36       REPLACE_MBRTOWC=1
37     else
38       gl_MBRTOWC_NULL_ARG1
39       gl_MBRTOWC_NULL_ARG2
40       gl_MBRTOWC_RETVAL
41       gl_MBRTOWC_NUL_RETVAL
42       gl_MBRTOWC_EMPTY_INPUT
43       case "$gl_cv_func_mbrtowc_null_arg1" in
44         *yes) ;;
45         *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1],
46              [Define if the mbrtowc function has the NULL pwc argument bug.])
47            REPLACE_MBRTOWC=1
48            ;;
49       esac
50       case "$gl_cv_func_mbrtowc_null_arg2" in
51         *yes) ;;
52         *) AC_DEFINE([MBRTOWC_NULL_ARG2_BUG], [1],
53              [Define if the mbrtowc function has the NULL string argument bug.])
54            REPLACE_MBRTOWC=1
55            ;;
56       esac
57       case "$gl_cv_func_mbrtowc_retval" in
58         *yes) ;;
59         *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1],
60              [Define if the mbrtowc function returns a wrong return value.])
61            REPLACE_MBRTOWC=1
62            ;;
63       esac
64       case "$gl_cv_func_mbrtowc_nul_retval" in
65         *yes) ;;
66         *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1],
67              [Define if the mbrtowc function does not return 0 for a NUL character.])
68            REPLACE_MBRTOWC=1
69            ;;
70       esac
71       case "$gl_cv_func_mbrtowc_empty_input" in
72         *yes) ;;
73         *) AC_DEFINE([MBRTOWC_EMPTY_INPUT_BUG], [1],
74              [Define if the mbrtowc function does not return (size_t) -2
75               for empty input.])
76            REPLACE_MBRTOWC=1
77            ;;
78       esac
79     fi
80   fi
81 ])
82
83 dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
84 dnl redefines the semantics of the given mbstate_t type.
85 dnl Result is REPLACE_MBSTATE_T.
86 dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to
87 dnl avoid inconsistencies.
88
89 AC_DEFUN([gl_MBSTATE_T_BROKEN],
90 [
91   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
92
93   AC_REQUIRE([AC_TYPE_MBSTATE_T])
94   AC_CHECK_FUNCS_ONCE([mbsinit])
95   AC_CHECK_FUNCS_ONCE([mbrtowc])
96   if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then
97     gl_MBRTOWC_INCOMPLETE_STATE
98     gl_MBRTOWC_SANITYCHECK
99     REPLACE_MBSTATE_T=0
100     case "$gl_cv_func_mbrtowc_incomplete_state" in
101       *yes) ;;
102       *) REPLACE_MBSTATE_T=1 ;;
103     esac
104     case "$gl_cv_func_mbrtowc_sanitycheck" in
105       *yes) ;;
106       *) REPLACE_MBSTATE_T=1 ;;
107     esac
108   else
109     REPLACE_MBSTATE_T=1
110   fi
111 ])
112
113 dnl Test whether mbrtowc puts the state into non-initial state when parsing an
114 dnl incomplete multibyte character.
115 dnl Result is gl_cv_func_mbrtowc_incomplete_state.
116
117 AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
118 [
119   AC_REQUIRE([AC_PROG_CC])
120   AC_REQUIRE([gt_LOCALE_JA])
121   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
122   AC_CACHE_CHECK([whether mbrtowc handles incomplete characters],
123     [gl_cv_func_mbrtowc_incomplete_state],
124     [
125       dnl Initial guess, used when cross-compiling or when no suitable locale
126       dnl is present.
127 changequote(,)dnl
128       case "$host_os" in
129                      # Guess no on AIX and OSF/1.
130         aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
131                      # Guess yes otherwise.
132         *)           gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
133       esac
134 changequote([,])dnl
135       if test $LOCALE_JA != none; then
136         AC_RUN_IFELSE(
137           [AC_LANG_SOURCE([[
138 #include <locale.h>
139 #include <string.h>
140 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
141    <wchar.h>.
142    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
143    included before <wchar.h>.  */
144 #include <stddef.h>
145 #include <stdio.h>
146 #include <time.h>
147 #include <wchar.h>
148 int main ()
149 {
150   if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
151     {
152       const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
153       mbstate_t state;
154       wchar_t wc;
155
156       memset (&state, '\0', sizeof (mbstate_t));
157       if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
158         if (mbsinit (&state))
159           return 1;
160     }
161   return 0;
162 }]])],
163           [gl_cv_func_mbrtowc_incomplete_state=yes],
164           [gl_cv_func_mbrtowc_incomplete_state=no],
165           [:])
166       fi
167     ])
168 ])
169
170 dnl Test whether mbrtowc works not worse than mbtowc.
171 dnl Result is gl_cv_func_mbrtowc_sanitycheck.
172
173 AC_DEFUN([gl_MBRTOWC_SANITYCHECK],
174 [
175   AC_REQUIRE([AC_PROG_CC])
176   AC_REQUIRE([gt_LOCALE_ZH_CN])
177   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
178   AC_CACHE_CHECK([whether mbrtowc works as well as mbtowc],
179     [gl_cv_func_mbrtowc_sanitycheck],
180     [
181       dnl Initial guess, used when cross-compiling or when no suitable locale
182       dnl is present.
183 changequote(,)dnl
184       case "$host_os" in
185                     # Guess no on Solaris 8.
186         solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;;
187                     # Guess yes otherwise.
188         *)          gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;;
189       esac
190 changequote([,])dnl
191       if test $LOCALE_ZH_CN != none; then
192         AC_RUN_IFELSE(
193           [AC_LANG_SOURCE([[
194 #include <locale.h>
195 #include <stdlib.h>
196 #include <string.h>
197 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
198    <wchar.h>.
199    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
200    included before <wchar.h>.  */
201 #include <stddef.h>
202 #include <stdio.h>
203 #include <time.h>
204 #include <wchar.h>
205 int main ()
206 {
207   /* This fails on Solaris 8:
208      mbrtowc returns 2, and sets wc to 0x00F0.
209      mbtowc returns 4 (correct) and sets wc to 0x5EDC.  */
210   if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
211     {
212       char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
213       mbstate_t state;
214       wchar_t wc;
215
216       memset (&state, '\0', sizeof (mbstate_t));
217       if (mbrtowc (&wc, input + 3, 6, &state) != 4
218           && mbtowc (&wc, input + 3, 6) == 4)
219         return 1;
220     }
221   return 0;
222 }]])],
223           [gl_cv_func_mbrtowc_sanitycheck=yes],
224           [gl_cv_func_mbrtowc_sanitycheck=no],
225           [:])
226       fi
227     ])
228 ])
229
230 dnl Test whether mbrtowc supports a NULL pwc argument correctly.
231 dnl Result is gl_cv_func_mbrtowc_null_arg1.
232
233 AC_DEFUN([gl_MBRTOWC_NULL_ARG1],
234 [
235   AC_REQUIRE([AC_PROG_CC])
236   AC_REQUIRE([gt_LOCALE_FR_UTF8])
237   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
238   AC_CACHE_CHECK([whether mbrtowc handles a NULL pwc argument],
239     [gl_cv_func_mbrtowc_null_arg1],
240     [
241       dnl Initial guess, used when cross-compiling or when no suitable locale
242       dnl is present.
243 changequote(,)dnl
244       case "$host_os" in
245                   # Guess no on Solaris.
246         solaris*) gl_cv_func_mbrtowc_null_arg1="guessing no" ;;
247                   # Guess yes otherwise.
248         *)        gl_cv_func_mbrtowc_null_arg1="guessing yes" ;;
249       esac
250 changequote([,])dnl
251       if test $LOCALE_FR_UTF8 != none; then
252         AC_RUN_IFELSE(
253           [AC_LANG_SOURCE([[
254 #include <locale.h>
255 #include <stdlib.h>
256 #include <string.h>
257 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
258    <wchar.h>.
259    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
260    included before <wchar.h>.  */
261 #include <stddef.h>
262 #include <stdio.h>
263 #include <time.h>
264 #include <wchar.h>
265 int main ()
266 {
267   int result = 0;
268
269   if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
270     {
271       char input[] = "\303\237er";
272       mbstate_t state;
273       wchar_t wc;
274       size_t ret;
275
276       memset (&state, '\0', sizeof (mbstate_t));
277       wc = (wchar_t) 0xBADFACE;
278       ret = mbrtowc (&wc, input, 5, &state);
279       if (ret != 2)
280         result |= 1;
281       if (!mbsinit (&state))
282         result |= 2;
283
284       memset (&state, '\0', sizeof (mbstate_t));
285       ret = mbrtowc (NULL, input, 5, &state);
286       if (ret != 2) /* Solaris 7 fails here: ret is -1.  */
287         result |= 4;
288       if (!mbsinit (&state))
289         result |= 8;
290     }
291   return result;
292 }]])],
293           [gl_cv_func_mbrtowc_null_arg1=yes],
294           [gl_cv_func_mbrtowc_null_arg1=no],
295           [:])
296       fi
297     ])
298 ])
299
300 dnl Test whether mbrtowc supports a NULL string argument correctly.
301 dnl Result is gl_cv_func_mbrtowc_null_arg2.
302
303 AC_DEFUN([gl_MBRTOWC_NULL_ARG2],
304 [
305   AC_REQUIRE([AC_PROG_CC])
306   AC_REQUIRE([gt_LOCALE_FR_UTF8])
307   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
308   AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument],
309     [gl_cv_func_mbrtowc_null_arg2],
310     [
311       dnl Initial guess, used when cross-compiling or when no suitable locale
312       dnl is present.
313 changequote(,)dnl
314       case "$host_os" in
315               # Guess no on OSF/1.
316         osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;;
317               # Guess yes otherwise.
318         *)    gl_cv_func_mbrtowc_null_arg2="guessing yes" ;;
319       esac
320 changequote([,])dnl
321       if test $LOCALE_FR_UTF8 != none; then
322         AC_RUN_IFELSE(
323           [AC_LANG_SOURCE([[
324 #include <locale.h>
325 #include <string.h>
326 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
327    <wchar.h>.
328    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
329    included before <wchar.h>.  */
330 #include <stddef.h>
331 #include <stdio.h>
332 #include <time.h>
333 #include <wchar.h>
334 int main ()
335 {
336   if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
337     {
338       mbstate_t state;
339       wchar_t wc;
340       int ret;
341
342       memset (&state, '\0', sizeof (mbstate_t));
343       wc = (wchar_t) 0xBADFACE;
344       mbrtowc (&wc, NULL, 5, &state);
345       /* Check that wc was not modified.  */
346       if (wc != (wchar_t) 0xBADFACE)
347         return 1;
348     }
349   return 0;
350 }]])],
351           [gl_cv_func_mbrtowc_null_arg2=yes],
352           [gl_cv_func_mbrtowc_null_arg2=no],
353           [:])
354       fi
355     ])
356 ])
357
358 dnl Test whether mbrtowc, when parsing the end of a multibyte character,
359 dnl correctly returns the number of bytes that were needed to complete the
360 dnl character (not the total number of bytes of the multibyte character).
361 dnl Result is gl_cv_func_mbrtowc_retval.
362
363 AC_DEFUN([gl_MBRTOWC_RETVAL],
364 [
365   AC_REQUIRE([AC_PROG_CC])
366   AC_REQUIRE([gt_LOCALE_FR_UTF8])
367   AC_REQUIRE([gt_LOCALE_JA])
368   AC_REQUIRE([AC_CANONICAL_HOST])
369   AC_CACHE_CHECK([whether mbrtowc has a correct return value],
370     [gl_cv_func_mbrtowc_retval],
371     [
372       dnl Initial guess, used when cross-compiling or when no suitable locale
373       dnl is present.
374 changequote(,)dnl
375       case "$host_os" in
376                                    # Guess no on HP-UX, Solaris, native Windows.
377         hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;;
378                                    # Guess yes otherwise.
379         *)                         gl_cv_func_mbrtowc_retval="guessing yes" ;;
380       esac
381 changequote([,])dnl
382       if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \
383          || { case "$host_os" in mingw*) true;; *) false;; esac; }; then
384         AC_RUN_IFELSE(
385           [AC_LANG_SOURCE([[
386 #include <locale.h>
387 #include <string.h>
388 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
389    <wchar.h>.
390    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
391    included before <wchar.h>.  */
392 #include <stddef.h>
393 #include <stdio.h>
394 #include <time.h>
395 #include <wchar.h>
396 int main ()
397 {
398   int result = 0;
399   int found_some_locale = 0;
400   /* This fails on Solaris.  */
401   if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
402     {
403       char input[] = "B\303\274\303\237er"; /* "Büßer" */
404       mbstate_t state;
405       wchar_t wc;
406
407       memset (&state, '\0', sizeof (mbstate_t));
408       if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
409         {
410           input[1] = '\0';
411           if (mbrtowc (&wc, input + 2, 5, &state) != 1)
412             result |= 1;
413         }
414       found_some_locale = 1;
415     }
416   /* This fails on HP-UX 11.11.  */
417   if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
418     {
419       char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
420       mbstate_t state;
421       wchar_t wc;
422
423       memset (&state, '\0', sizeof (mbstate_t));
424       if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
425         {
426           input[1] = '\0';
427           if (mbrtowc (&wc, input + 2, 5, &state) != 2)
428             result |= 2;
429         }
430       found_some_locale = 1;
431     }
432   /* This fails on native Windows.  */
433   if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL)
434     {
435       char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */
436       mbstate_t state;
437       wchar_t wc;
438
439       memset (&state, '\0', sizeof (mbstate_t));
440       if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
441         {
442           input[3] = '\0';
443           if (mbrtowc (&wc, input + 4, 4, &state) != 1)
444             result |= 4;
445         }
446       found_some_locale = 1;
447     }
448   if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL)
449     {
450       char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */
451       mbstate_t state;
452       wchar_t wc;
453
454       memset (&state, '\0', sizeof (mbstate_t));
455       if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
456         {
457           input[3] = '\0';
458           if (mbrtowc (&wc, input + 4, 4, &state) != 1)
459             result |= 8;
460         }
461       found_some_locale = 1;
462     }
463   if (setlocale (LC_ALL, "Chinese_China.936") != NULL)
464     {
465       char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */
466       mbstate_t state;
467       wchar_t wc;
468
469       memset (&state, '\0', sizeof (mbstate_t));
470       if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
471         {
472           input[3] = '\0';
473           if (mbrtowc (&wc, input + 4, 4, &state) != 1)
474             result |= 16;
475         }
476       found_some_locale = 1;
477     }
478   return (found_some_locale ? result : 77);
479 }]])],
480           [gl_cv_func_mbrtowc_retval=yes],
481           [if test $? != 77; then
482              gl_cv_func_mbrtowc_retval=no
483            fi
484           ],
485           [:])
486       fi
487     ])
488 ])
489
490 dnl Test whether mbrtowc, when parsing a NUL character, correctly returns 0.
491 dnl Result is gl_cv_func_mbrtowc_nul_retval.
492
493 AC_DEFUN([gl_MBRTOWC_NUL_RETVAL],
494 [
495   AC_REQUIRE([AC_PROG_CC])
496   AC_REQUIRE([gt_LOCALE_ZH_CN])
497   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
498   AC_CACHE_CHECK([whether mbrtowc returns 0 when parsing a NUL character],
499     [gl_cv_func_mbrtowc_nul_retval],
500     [
501       dnl Initial guess, used when cross-compiling or when no suitable locale
502       dnl is present.
503 changequote(,)dnl
504       case "$host_os" in
505                        # Guess no on Solaris 8 and 9.
506         solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;;
507                        # Guess yes otherwise.
508         *)             gl_cv_func_mbrtowc_nul_retval="guessing yes" ;;
509       esac
510 changequote([,])dnl
511       if test $LOCALE_ZH_CN != none; then
512         AC_RUN_IFELSE(
513           [AC_LANG_SOURCE([[
514 #include <locale.h>
515 #include <string.h>
516 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
517    <wchar.h>.
518    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
519    included before <wchar.h>.  */
520 #include <stddef.h>
521 #include <stdio.h>
522 #include <time.h>
523 #include <wchar.h>
524 int main ()
525 {
526   /* This fails on Solaris 8 and 9.  */
527   if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
528     {
529       mbstate_t state;
530       wchar_t wc;
531
532       memset (&state, '\0', sizeof (mbstate_t));
533       if (mbrtowc (&wc, "", 1, &state) != 0)
534         return 1;
535     }
536   return 0;
537 }]])],
538           [gl_cv_func_mbrtowc_nul_retval=yes],
539           [gl_cv_func_mbrtowc_nul_retval=no],
540           [:])
541       fi
542     ])
543 ])
544
545 dnl Test whether mbrtowc returns the correct value on empty input.
546
547 AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT],
548 [
549   AC_REQUIRE([AC_PROG_CC])
550   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
551   AC_CACHE_CHECK([whether mbrtowc works on empty input],
552     [gl_cv_func_mbrtowc_empty_input],
553     [
554       dnl Initial guess, used when cross-compiling or when no suitable locale
555       dnl is present.
556 changequote(,)dnl
557       case "$host_os" in
558                      # Guess no on AIX and glibc systems.
559         aix* | *-gnu*)
560                     gl_cv_func_mbrtowc_empty_input="guessing no" ;;
561         *)          gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
562       esac
563 changequote([,])dnl
564       AC_RUN_IFELSE(
565         [AC_LANG_SOURCE([[
566            #include <wchar.h>
567            static wchar_t wc;
568            static mbstate_t mbs;
569            int
570            main (void)
571            {
572              return mbrtowc (&wc, "", 0, &mbs) == (size_t) -2;
573            }]])],
574         [gl_cv_func_mbrtowc_empty_input=no],
575         [gl_cv_func_mbrtowc_empty_input=yes],
576         [:])
577     ])
578 ])
579
580 # Prerequisites of lib/mbrtowc.c.
581 AC_DEFUN([gl_PREREQ_MBRTOWC], [
582   :
583 ])
584
585
586 dnl From Paul Eggert
587
588 dnl This is an override of an autoconf macro.
589
590 AC_DEFUN([AC_FUNC_MBRTOWC],
591 [
592   dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
593   AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
594     gl_cv_func_mbrtowc,
595     [AC_LINK_IFELSE(
596        [AC_LANG_PROGRAM(
597             [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
598                  included before <wchar.h>.
599                  BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
600                  must be included before <wchar.h>.  */
601               #include <stddef.h>
602               #include <stdio.h>
603               #include <time.h>
604               #include <wchar.h>]],
605             [[wchar_t wc;
606               char const s[] = "";
607               size_t n = 1;
608               mbstate_t state;
609               return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
610        gl_cv_func_mbrtowc=yes,
611        gl_cv_func_mbrtowc=no)])
612   if test $gl_cv_func_mbrtowc = yes; then
613     AC_DEFINE([HAVE_MBRTOWC], [1],
614       [Define to 1 if mbrtowc and mbstate_t are properly declared.])
615   fi
616 ])