2N/Adnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
2N/Adnl This file is free software; the Free Software Foundation
2N/Adnl gives unlimited permission to copy
and/or distribute it,
2N/Adnl with or without modifications, as long as this notice is preserved.
2N/AAC_DEFUN([gl_FUNC_MBSRTOWCS],
2N/A AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
2N/A AC_REQUIRE([AC_TYPE_MBSTATE_T])
2N/A AC_CHECK_FUNCS_ONCE([mbsrtowcs])
2N/A if test $ac_cv_func_mbsrtowcs = no; then
2N/A if test $REPLACE_MBSTATE_T = 1; then
2N/A case "$gl_cv_func_mbsrtowcs_works" in
2N/A *) REPLACE_MBSRTOWCS=1 ;;
2N/A if test $HAVE_MBSRTOWCS = 0 || test $REPLACE_MBSRTOWCS = 1; then
2N/A AC_LIBOBJ([mbsrtowcs])
2N/A AC_LIBOBJ([mbsrtowcs-state])
2N/Adnl Test whether mbsrtowcs works.
2N/Adnl Result is gl_cv_func_mbsrtowcs_works.
2N/AAC_DEFUN([gl_MBSRTOWCS_WORKS],
2N/A AC_REQUIRE([AC_PROG_CC])
2N/A AC_REQUIRE([gt_LOCALE_FR_UTF8])
2N/A AC_REQUIRE([gt_LOCALE_JA])
2N/A AC_REQUIRE([gt_LOCALE_ZH_CN])
2N/A AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2N/A AC_CACHE_CHECK([whether mbsrtowcs works],
2N/A [gl_cv_func_mbsrtowcs_works],
2N/A dnl Initial guess, used when cross-compiling or when no suitable locale
2N/A # Guess no on HP-UX and Solaris.
2N/A hpux* | solaris*) gl_cv_func_mbsrtowcs_works="guessing no" ;;
2N/A # Guess yes otherwise.
2N/A *) gl_cv_func_mbsrtowcs_works="guessing yes" ;;
2N/A if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
2N/A /* Test whether the function works when started with a conversion state
2N/A in non-initial state. This fails on HP-UX 11.11 and Solaris 10. */
2N/A if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
2N/A const char input[] = "B\303\274\303\237er";
2N/A memset (&state, '\0', sizeof (mbstate_t));
2N/A if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2))
2N/A if (!mbsinit (&state))
2N/A const char *src = input + 2;
2N/A if (mbsrtowcs (NULL, &src, 10, &state) != 4)
2N/A if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
2N/A const char input[] = "<\306\374\313\334\270\354>";
2N/A memset (&state, '\0', sizeof (mbstate_t));
2N/A if (mbrtowc (NULL, input + 3, 1, &state) == (size_t)(-2))
2N/A if (!mbsinit (&state))
2N/A const char *src = input + 4;
2N/A if (mbsrtowcs (NULL, &src, 10, &state) != 3)
2N/A if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
2N/A const char input[] = "B\250\271\201\060\211\070er";
2N/A memset (&state, '\0', sizeof (mbstate_t));
2N/A if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2))
2N/A if (!mbsinit (&state))
2N/A const char *src = input + 2;
2N/A if (mbsrtowcs (NULL, &src, 10, &state) != 4)
2N/A [gl_cv_func_mbsrtowcs_works=yes],
2N/A [gl_cv_func_mbsrtowcs_works=no],
2N/AAC_DEFUN([gl_PREREQ_MBSRTOWCS], [