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_BTOWC],
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
11 dnl Check whether <wchar.h> is usable at all, first. Otherwise the test
12 dnl program below may lead to an endless loop. See
13 dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>.
14 AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
16 AC_CHECK_FUNCS_ONCE([btowc])
17 if test $ac_cv_func_btowc = no; then
21 AC_REQUIRE([AC_PROG_CC])
22 AC_REQUIRE([gt_LOCALE_FR])
23 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
25 dnl Cygwin 1.7.2 btowc('\0') is WEOF, not 0.
26 AC_CACHE_CHECK([whether btowc(0) is correct],
27 [gl_cv_func_btowc_nul],
34 if (btowc ('\0') != 0)
38 [gl_cv_func_btowc_nul=yes],
39 [gl_cv_func_btowc_nul=no],
44 cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
45 # Guess yes on native Windows.
46 mingw*) gl_cv_func_btowc_nul="guessing yes" ;;
47 # Guess yes otherwise.
48 *) gl_cv_func_btowc_nul="guessing yes" ;;
54 dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
55 AC_CACHE_CHECK([whether btowc(EOF) is correct],
56 [gl_cv_func_btowc_eof],
58 dnl Initial guess, used when cross-compiling or when no suitable locale
63 irix*) gl_cv_func_btowc_eof="guessing no" ;;
64 # Guess yes on native Windows.
65 mingw*) gl_cv_func_btowc_eof="guessing yes" ;;
66 # Guess yes otherwise.
67 *) gl_cv_func_btowc_eof="guessing yes" ;;
70 if test $LOCALE_FR != none; then
78 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
80 if (btowc (EOF) != WEOF)
85 [gl_cv_func_btowc_eof=yes],
86 [gl_cv_func_btowc_eof=no],
91 case "$gl_cv_func_btowc_nul" in
95 case "$gl_cv_func_btowc_eof" in
102 # Prerequisites of lib/btowc.c.
103 AC_DEFUN([gl_PREREQ_BTOWC], [