gnulib: update to 776af40e0
[deliverable/binutils-gdb.git] / gnulib / import / m4 / wctype_h.m4
CommitLineData
9c9d63b1 1# wctype_h.m4 serial 26
8690e634
JK
2
3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
4
9c9d63b1 5dnl Copyright (C) 2006-2021 Free Software Foundation, Inc.
8690e634
JK
6dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved.
9
10dnl Written by Paul Eggert.
11
12AC_DEFUN([gl_WCTYPE_H],
13[
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
19 HAVE_ISWCNTRL=1
20 else
21 HAVE_ISWCNTRL=0
22 fi
23 AC_SUBST([HAVE_ISWCNTRL])
24
8690e634
JK
25 AC_REQUIRE([gt_TYPE_WINT_T])
26 if test $gt_cv_c_wint_t = yes; then
27 HAVE_WINT_T=1
28 else
29 HAVE_WINT_T=0
30 fi
31 AC_SUBST([HAVE_WINT_T])
32
c0c3707f
CB
33 AC_REQUIRE([gl_TYPE_WINT_T_PREREQ])
34
8690e634
JK
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],
41 [
42 AC_RUN_IFELSE(
43 [AC_LANG_SOURCE([[
8690e634
JK
44 #include <wchar.h>
45 #include <wctype.h>
46 int main () { return iswprint ('x') == 0; }
47 ]])],
48 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
c0c3707f
CB
49 [dnl Guess no on Linux libc5, yes otherwise.
50 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
8690e634
JK
51 #if __GNU_LIBRARY__ == 1
52 Linux libc5 i18n is broken.
9c9d63b1 53 #endif]], [[]])],
8690e634
JK
54 [gl_cv_func_iswcntrl_works="guessing yes"],
55 [gl_cv_func_iswcntrl_works="guessing no"])
56 ])
57 ])
58 fi
59 HAVE_WCTYPE_H=1
60 else
61 HAVE_WCTYPE_H=0
62 fi
63 AC_SUBST([HAVE_WCTYPE_H])
64
c0c3707f
CB
65 if test $GNULIB_OVERRIDES_WINT_T = 1; then
66 REPLACE_ISWCNTRL=1
67 else
68 case "$gl_cv_func_iswcntrl_works" in
69 *yes) REPLACE_ISWCNTRL=0 ;;
70 *) REPLACE_ISWCNTRL=1 ;;
71 esac
72 fi
8690e634
JK
73 AC_SUBST([REPLACE_ISWCNTRL])
74
75 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
76 dnl Redefine all of iswcntrl, ..., iswxdigit in <wctype.h>.
77 :
78 fi
79
80 if test $REPLACE_ISWCNTRL = 1; then
81 REPLACE_TOWLOWER=1
82 else
83 AC_CHECK_FUNCS([towlower])
84 if test $ac_cv_func_towlower = yes; then
85 REPLACE_TOWLOWER=0
86 else
87 AC_CHECK_DECLS([towlower],,,
9c9d63b1 88 [[#include <wchar.h>
8690e634
JK
89 #if HAVE_WCTYPE_H
90 # include <wctype.h>
91 #endif
92 ]])
93 if test $ac_cv_have_decl_towlower = yes; then
94 dnl On Minix 3.1.8, the system's <wctype.h> declares towlower() and
95 dnl towupper() although it does not have the functions. Avoid a
96 dnl collision with gnulib's replacement.
97 REPLACE_TOWLOWER=1
98 else
99 REPLACE_TOWLOWER=0
100 fi
101 fi
102 fi
103 AC_SUBST([REPLACE_TOWLOWER])
104
105 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_TOWLOWER = 1; then
106 dnl Redefine towlower, towupper in <wctype.h>.
107 :
108 fi
109
110 dnl We assume that the wctype() and iswctype() functions exist if and only
111 dnl if the type wctype_t is defined in <wchar.h> or in <wctype.h> if that
112 dnl exists.
113 dnl HP-UX 11.00 declares all these in <wchar.h> and lacks <wctype.h>.
114 AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t],
115 [AC_COMPILE_IFELSE(
116 [AC_LANG_PROGRAM(
9c9d63b1 117 [[#include <wchar.h>
8690e634
JK
118 #if HAVE_WCTYPE_H
119 # include <wctype.h>
120 #endif
121 wctype_t a;
122 ]],
123 [[]])],
124 [gl_cv_type_wctype_t=yes],
125 [gl_cv_type_wctype_t=no])
126 ])
127 if test $gl_cv_type_wctype_t = no; then
128 HAVE_WCTYPE_T=0
129 fi
130
131 dnl We assume that the wctrans() and towctrans() functions exist if and only
132 dnl if the type wctrans_t is defined in <wctype.h>.
133 AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t],
134 [AC_COMPILE_IFELSE(
135 [AC_LANG_PROGRAM(
9c9d63b1 136 [[#include <wchar.h>
8690e634
JK
137 #include <wctype.h>
138 wctrans_t a;
139 ]],
140 [[]])],
141 [gl_cv_type_wctrans_t=yes],
142 [gl_cv_type_wctrans_t=no])
143 ])
144 if test $gl_cv_type_wctrans_t = no; then
145 HAVE_WCTRANS_T=0
146 fi
147
148 dnl Check for declarations of anything we want to poison if the
149 dnl corresponding gnulib module is not in use.
150 gl_WARN_ON_USE_PREPARE([[
8690e634 151#if !(defined __GLIBC__ && !defined __UCLIBC__)
8690e634
JK
152# include <wchar.h>
153#endif
154#include <wctype.h>
155 ]],
156 [wctype iswctype wctrans towctrans
157 ])
158])
159
160AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
161[
162 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
163 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
164 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
165 dnl Define it also as a C macro, for the benefit of the unit tests.
166 gl_MODULE_INDICATOR_FOR_TESTS([$1])
167])
168
169AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
170[
171 GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK])
5df4cba6
SM
172 GNULIB_ISWDIGIT=0; AC_SUBST([GNULIB_ISWDIGIT])
173 GNULIB_ISWXDIGIT=0; AC_SUBST([GNULIB_ISWXDIGIT])
8690e634
JK
174 GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE])
175 GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE])
176 GNULIB_WCTRANS=0; AC_SUBST([GNULIB_WCTRANS])
177 GNULIB_TOWCTRANS=0; AC_SUBST([GNULIB_TOWCTRANS])
178 dnl Assume proper GNU behavior unless another module says otherwise.
179 HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK])
180 HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T])
181 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T])
182 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])
5df4cba6
SM
183 REPLACE_ISWDIGIT=0; AC_SUBST([REPLACE_ISWDIGIT])
184 REPLACE_ISWXDIGIT=0; AC_SUBST([REPLACE_ISWXDIGIT])
8690e634 185])
This page took 0.707806 seconds and 4 git commands to generate.