2 dnl Copyright (C) 2008-2020 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_WCTOB],
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
11 AC_CHECK_FUNCS_ONCE([wctob])
12 if test $ac_cv_func_wctob = no; then
18 dnl Solaris 9 has the wctob() function but it does not work.
19 dnl Cygwin 1.7.2 has the wctob() function but it clobbers caller-owned
20 dnl registers, see <https://cygwin.com/ml/cygwin/2010-05/msg00015.html>.
21 AC_REQUIRE([AC_PROG_CC])
22 AC_REQUIRE([gt_LOCALE_FR])
23 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
24 AC_CACHE_CHECK([whether wctob works],
25 [gl_cv_func_wctob_works],
27 dnl Initial guess, used when cross-compiling or when no suitable locale
31 # Guess no on Solaris <= 9 and Cygwin.
32 solaris2.[1-9] | solaris2.[1-9].* | cygwin*)
33 gl_cv_func_wctob_works="guessing no" ;;
34 # Guess no on native Windows.
36 gl_cv_func_wctob_works="guessing no" ;;
37 # Guess yes otherwise.
38 *) gl_cv_func_wctob_works="guessing yes" ;;
48 register long global __asm__ ("%ebx");
52 setlocale (LC_ALL, "en_US.UTF-8");
55 if (wctob (0x00FC) != -1)
57 if (global != 0x12345678)
62 [gl_cv_func_wctob_works=no],
66 if test "$gl_cv_func_wctob_works" != no && test $LOCALE_FR != none; then
74 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
78 if (mbtowc (&wc, "\374", 1) == 1)
79 if (wctob (wc) != (unsigned char) '\374')
84 [gl_cv_func_wctob_works=yes],
85 [gl_cv_func_wctob_works=no],
89 case "$gl_cv_func_wctob_works" in
93 if test $REPLACE_WCTOB = 0; then
95 dnl IRIX 6.5 has the wctob() function but does not declare it.
96 AC_CHECK_DECLS([wctob], [], [], [[
99 if test $ac_cv_have_decl_wctob != yes; then
106 # Prerequisites of lib/wctob.c.
107 AC_DEFUN([gl_PREREQ_WCTOB], [