1 # wctype_h.m4 serial 21
3 dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
5 dnl Copyright (C) 2006-2018 Free Software Foundation, Inc.
6 dnl This file is free software; the Free Software Foundation
7 dnl gives unlimited permission to copy and/or distribute it,
8 dnl with or without modifications, as long as this notice is preserved.
10 dnl Written by Paul Eggert.
12 AC_DEFUN([gl_WCTYPE_H],
14 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
15 AC_REQUIRE([AC_PROG_CC])
16 AC_REQUIRE([AC_CANONICAL_HOST])
17 AC_CHECK_FUNCS_ONCE([iswcntrl])
18 if test $ac_cv_func_iswcntrl = yes; then
23 AC_SUBST([HAVE_ISWCNTRL])
25 AC_REQUIRE([gt_TYPE_WINT_T])
26 if test $gt_cv_c_wint_t = yes; then
31 AC_SUBST([HAVE_WINT_T])
33 AC_REQUIRE([gl_TYPE_WINT_T_PREREQ])
35 gl_CHECK_NEXT_HEADERS([wctype.h])
36 if test $ac_cv_header_wctype_h = yes; then
37 if test $ac_cv_func_iswcntrl = yes; then
38 dnl Linux libc5 has an iswprint function that returns 0 for all arguments.
39 dnl The other functions are likely broken in the same way.
40 AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works],
44 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
45 included before <wchar.h>.
46 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
47 must be included before <wchar.h>. */
53 int main () { return iswprint ('x') == 0; }
55 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
56 [dnl Guess no on Linux libc5, yes otherwise.
57 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
58 #if __GNU_LIBRARY__ == 1
59 Linux libc5 i18n is broken.
61 [gl_cv_func_iswcntrl_works="guessing yes"],
62 [gl_cv_func_iswcntrl_works="guessing no"])
70 AC_SUBST([HAVE_WCTYPE_H])
72 case "$gl_cv_func_iswcntrl_works" in
73 *yes) REPLACE_ISWCNTRL=0 ;;
74 *) REPLACE_ISWCNTRL=1 ;;
76 AC_SUBST([REPLACE_ISWCNTRL])
78 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
79 dnl Redefine all of iswcntrl, ..., iswxdigit in <wctype.h>.
83 if test $REPLACE_ISWCNTRL = 1; then
86 AC_CHECK_FUNCS([towlower])
87 if test $ac_cv_func_towlower = yes; then
90 AC_CHECK_DECLS([towlower],,,
91 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
92 included before <wchar.h>.
93 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
94 must be included before <wchar.h>. */
103 if test $ac_cv_have_decl_towlower = yes; then
104 dnl On Minix 3.1.8, the system's <wctype.h> declares towlower() and
105 dnl towupper() although it does not have the functions. Avoid a
106 dnl collision with gnulib's replacement.
113 AC_SUBST([REPLACE_TOWLOWER])
115 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_TOWLOWER = 1; then
116 dnl Redefine towlower, towupper in <wctype.h>.
120 dnl We assume that the wctype() and iswctype() functions exist if and only
121 dnl if the type wctype_t is defined in <wchar.h> or in <wctype.h> if that
123 dnl HP-UX 11.00 declares all these in <wchar.h> and lacks <wctype.h>.
124 AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t],
127 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
128 included before <wchar.h>.
129 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
130 must be included before <wchar.h>. */
141 [gl_cv_type_wctype_t=yes],
142 [gl_cv_type_wctype_t=no])
144 if test $gl_cv_type_wctype_t = no; then
148 dnl We assume that the wctrans() and towctrans() functions exist if and only
149 dnl if the type wctrans_t is defined in <wctype.h>.
150 AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t],
153 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
154 included before <wchar.h>.
155 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
156 must be included before <wchar.h>. */
165 [gl_cv_type_wctrans_t=yes],
166 [gl_cv_type_wctrans_t=no])
168 if test $gl_cv_type_wctrans_t = no; then
172 dnl Check for declarations of anything we want to poison if the
173 dnl corresponding gnulib module is not in use.
174 gl_WARN_ON_USE_PREPARE([[
175 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
177 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
178 included before <wchar.h>. */
179 #if !(defined __GLIBC__ && !defined __UCLIBC__)
187 [wctype iswctype wctrans towctrans
191 AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
193 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
194 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
195 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
196 dnl Define it also as a C macro, for the benefit of the unit tests.
197 gl_MODULE_INDICATOR_FOR_TESTS([$1])
200 AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
202 GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK])
203 GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE])
204 GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE])
205 GNULIB_WCTRANS=0; AC_SUBST([GNULIB_WCTRANS])
206 GNULIB_TOWCTRANS=0; AC_SUBST([GNULIB_TOWCTRANS])
207 dnl Assume proper GNU behavior unless another module says otherwise.
208 HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK])
209 HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T])
210 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T])
211 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])