2 dnl Copyright (C) 2008-2010 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_WCRTOMB],
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
11 AC_REQUIRE([AC_TYPE_MBSTATE_T])
14 AC_CHECK_FUNCS_ONCE([wcrtomb])
15 if test $ac_cv_func_wcrtomb = no; then
18 if test $REPLACE_MBSTATE_T = 1; then
21 dnl On AIX 4.3, OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes
22 dnl returns 0 instead of 1.
23 AC_REQUIRE([AC_PROG_CC])
24 AC_REQUIRE([gt_LOCALE_FR])
25 AC_REQUIRE([gt_LOCALE_FR_UTF8])
26 AC_REQUIRE([gt_LOCALE_JA])
27 AC_REQUIRE([gt_LOCALE_ZH_CN])
28 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
29 AC_CACHE_CHECK([whether wcrtomb return value is correct],
30 [gl_cv_func_wcrtomb_retval],
32 dnl Initial guess, used when cross-compiling or when no suitable locale
36 # Guess no on AIX 4, OSF/1 and Solaris.
37 aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;;
38 # Guess yes otherwise.
39 *) gl_cv_func_wcrtomb_retval="guessing yes" ;;
42 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
51 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
53 if (wcrtomb (NULL, 0, NULL) != 1)
56 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
58 if (wcrtomb (NULL, 0, NULL) != 1)
61 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
63 if (wcrtomb (NULL, 0, NULL) != 1)
66 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
68 if (wcrtomb (NULL, 0, NULL) != 1)
73 [gl_cv_func_wcrtomb_retval=yes],
74 [gl_cv_func_wcrtomb_retval=no],
78 case "$gl_cv_func_wcrtomb_retval" in
80 *) REPLACE_WCRTOMB=1 ;;
84 if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then
91 # Prerequisites of lib/wcrtomb.c.
92 AC_DEFUN([gl_PREREQ_WCRTOMB], [