X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fmbrtowc.m4;h=4c9f38861c62cdc2383dc81ffeabd621a2761a3c;hb=831b84c59ef413c57a36b67344467d66a8a2ba70;hp=8a579e04a583444c2f2455ada755a10889f2089d;hpb=777cb5e9cb12fd56d998f2eaa9348dd4e0078cac;p=gnulib.git diff --git a/m4/mbrtowc.m4 b/m4/mbrtowc.m4 index 8a579e04a..4c9f38861 100644 --- a/m4/mbrtowc.m4 +++ b/m4/mbrtowc.m4 @@ -1,5 +1,5 @@ -# mbrtowc.m4 serial 21 -dnl Copyright (C) 2001-2002, 2004-2005, 2008-2010 Free Software Foundation, +# mbrtowc.m4 serial 25 +dnl Copyright (C) 2001-2002, 2004-2005, 2008-2013 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -15,6 +15,22 @@ AC_DEFUN([gl_FUNC_MBRTOWC], AC_CHECK_FUNCS_ONCE([mbrtowc]) if test $ac_cv_func_mbrtowc = no; then HAVE_MBRTOWC=0 + AC_CHECK_DECLS([mbrtowc],,, [[ +/* Tru64 with Desktop Toolkit C has a bug: must be included before + . + BSD/OS 4.0.1 has a bug: , and must be + included before . */ +#include +#include +#include +#include +]]) + if test $ac_cv_have_decl_mbrtowc = yes; then + dnl On Minix 3.1.8, the system's declares mbrtowc() although + dnl it does not have the function. Avoid a collision with gnulib's + dnl replacement. + REPLACE_MBRTOWC=1 + fi else if test $REPLACE_MBSTATE_T = 1; then REPLACE_MBRTOWC=1 @@ -53,11 +69,6 @@ AC_DEFUN([gl_FUNC_MBRTOWC], esac fi fi - if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then - gl_REPLACE_WCHAR_H - AC_LIBOBJ([mbrtowc]) - gl_PREREQ_MBRTOWC - fi ]) dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that @@ -88,9 +99,6 @@ AC_DEFUN([gl_MBSTATE_T_BROKEN], else REPLACE_MBSTATE_T=1 fi - if test $REPLACE_MBSTATE_T = 1; then - gl_REPLACE_WCHAR_H - fi ]) dnl Test whether mbrtowc puts the state into non-initial state when parsing an @@ -348,7 +356,7 @@ AC_DEFUN([gl_MBRTOWC_RETVAL], AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([gt_LOCALE_FR_UTF8]) AC_REQUIRE([gt_LOCALE_JA]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_REQUIRE([AC_CANONICAL_HOST]) AC_CACHE_CHECK([whether mbrtowc has a correct return value], [gl_cv_func_mbrtowc_retval], [ @@ -356,13 +364,14 @@ AC_DEFUN([gl_MBRTOWC_RETVAL], dnl is present. changequote(,)dnl case "$host_os" in - # Guess no on HP-UX and Solaris. - hpux* | solaris*) gl_cv_func_mbrtowc_retval="guessing no" ;; - # Guess yes otherwise. - *) gl_cv_func_mbrtowc_retval="guessing yes" ;; + # Guess no on HP-UX, Solaris, native Windows. + hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_mbrtowc_retval="guessing yes" ;; esac changequote([,])dnl - if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none; then + if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \ + || { case "$host_os" in mingw*) true;; *) false;; esac; }; then AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include @@ -378,6 +387,7 @@ changequote([,])dnl int main () { int result = 0; + int found_some_locale = 0; /* This fails on Solaris. */ if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) { @@ -392,6 +402,7 @@ int main () if (mbrtowc (&wc, input + 2, 5, &state) != 1) result |= 1; } + found_some_locale = 1; } /* This fails on HP-UX 11.11. */ if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) @@ -407,11 +418,61 @@ int main () if (mbrtowc (&wc, input + 2, 5, &state) != 2) result |= 2; } + found_some_locale = 1; } - return result; + /* This fails on native Windows. */ + if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL) + { + char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */ + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) + { + input[3] = '\0'; + if (mbrtowc (&wc, input + 4, 4, &state) != 1) + result |= 4; + } + found_some_locale = 1; + } + if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL) + { + char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */ + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) + { + input[3] = '\0'; + if (mbrtowc (&wc, input + 4, 4, &state) != 1) + result |= 8; + } + found_some_locale = 1; + } + if (setlocale (LC_ALL, "Chinese_China.936") != NULL) + { + char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */ + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) + { + input[3] = '\0'; + if (mbrtowc (&wc, input + 4, 4, &state) != 1) + result |= 16; + } + found_some_locale = 1; + } + return (found_some_locale ? result : 77); }]])], [gl_cv_func_mbrtowc_retval=yes], - [gl_cv_func_mbrtowc_retval=no], + [if test $? != 77; then + gl_cv_func_mbrtowc_retval=no + fi + ], [:]) fi ])