Update Gnulib to the latest git version
[deliverable/binutils-gdb.git] / gnulib / import / m4 / wctype_h.m4
CommitLineData
c0c3707f 1# wctype_h.m4 serial 22
8690e634
JK
2
3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
4
c0c3707f 5dnl Copyright (C) 2006-2019 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([[
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>. */
48 #include <stddef.h>
49 #include <stdio.h>
50 #include <time.h>
51 #include <wchar.h>
52 #include <wctype.h>
53 int main () { return iswprint ('x') == 0; }
54 ]])],
55 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
c0c3707f
CB
56 [dnl Guess no on Linux libc5, yes otherwise.
57 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
8690e634
JK
58 #if __GNU_LIBRARY__ == 1
59 Linux libc5 i18n is broken.
60 #endif]], [])],
61 [gl_cv_func_iswcntrl_works="guessing yes"],
62 [gl_cv_func_iswcntrl_works="guessing no"])
63 ])
64 ])
65 fi
66 HAVE_WCTYPE_H=1
67 else
68 HAVE_WCTYPE_H=0
69 fi
70 AC_SUBST([HAVE_WCTYPE_H])
71
c0c3707f
CB
72 if test $GNULIB_OVERRIDES_WINT_T = 1; then
73 REPLACE_ISWCNTRL=1
74 else
75 case "$gl_cv_func_iswcntrl_works" in
76 *yes) REPLACE_ISWCNTRL=0 ;;
77 *) REPLACE_ISWCNTRL=1 ;;
78 esac
79 fi
8690e634
JK
80 AC_SUBST([REPLACE_ISWCNTRL])
81
82 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
83 dnl Redefine all of iswcntrl, ..., iswxdigit in <wctype.h>.
84 :
85 fi
86
87 if test $REPLACE_ISWCNTRL = 1; then
88 REPLACE_TOWLOWER=1
89 else
90 AC_CHECK_FUNCS([towlower])
91 if test $ac_cv_func_towlower = yes; then
92 REPLACE_TOWLOWER=0
93 else
94 AC_CHECK_DECLS([towlower],,,
95 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
96 included before <wchar.h>.
97 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
98 must be included before <wchar.h>. */
99 #include <stddef.h>
100 #include <stdio.h>
101 #include <time.h>
102 #include <wchar.h>
103 #if HAVE_WCTYPE_H
104 # include <wctype.h>
105 #endif
106 ]])
107 if test $ac_cv_have_decl_towlower = yes; then
108 dnl On Minix 3.1.8, the system's <wctype.h> declares towlower() and
109 dnl towupper() although it does not have the functions. Avoid a
110 dnl collision with gnulib's replacement.
111 REPLACE_TOWLOWER=1
112 else
113 REPLACE_TOWLOWER=0
114 fi
115 fi
116 fi
117 AC_SUBST([REPLACE_TOWLOWER])
118
119 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_TOWLOWER = 1; then
120 dnl Redefine towlower, towupper in <wctype.h>.
121 :
122 fi
123
124 dnl We assume that the wctype() and iswctype() functions exist if and only
125 dnl if the type wctype_t is defined in <wchar.h> or in <wctype.h> if that
126 dnl exists.
127 dnl HP-UX 11.00 declares all these in <wchar.h> and lacks <wctype.h>.
128 AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t],
129 [AC_COMPILE_IFELSE(
130 [AC_LANG_PROGRAM(
131 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
132 included before <wchar.h>.
133 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
134 must be included before <wchar.h>. */
135 #include <stddef.h>
136 #include <stdio.h>
137 #include <time.h>
138 #include <wchar.h>
139 #if HAVE_WCTYPE_H
140 # include <wctype.h>
141 #endif
142 wctype_t a;
143 ]],
144 [[]])],
145 [gl_cv_type_wctype_t=yes],
146 [gl_cv_type_wctype_t=no])
147 ])
148 if test $gl_cv_type_wctype_t = no; then
149 HAVE_WCTYPE_T=0
150 fi
151
152 dnl We assume that the wctrans() and towctrans() functions exist if and only
153 dnl if the type wctrans_t is defined in <wctype.h>.
154 AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t],
155 [AC_COMPILE_IFELSE(
156 [AC_LANG_PROGRAM(
157 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
158 included before <wchar.h>.
159 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
160 must be included before <wchar.h>. */
161 #include <stddef.h>
162 #include <stdio.h>
163 #include <time.h>
164 #include <wchar.h>
165 #include <wctype.h>
166 wctrans_t a;
167 ]],
168 [[]])],
169 [gl_cv_type_wctrans_t=yes],
170 [gl_cv_type_wctrans_t=no])
171 ])
172 if test $gl_cv_type_wctrans_t = no; then
173 HAVE_WCTRANS_T=0
174 fi
175
176 dnl Check for declarations of anything we want to poison if the
177 dnl corresponding gnulib module is not in use.
178 gl_WARN_ON_USE_PREPARE([[
179/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
180 <wchar.h>.
181 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
182 included before <wchar.h>. */
183#if !(defined __GLIBC__ && !defined __UCLIBC__)
184# include <stddef.h>
185# include <stdio.h>
186# include <time.h>
187# include <wchar.h>
188#endif
189#include <wctype.h>
190 ]],
191 [wctype iswctype wctrans towctrans
192 ])
193])
194
195AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
196[
197 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
198 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
199 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
200 dnl Define it also as a C macro, for the benefit of the unit tests.
201 gl_MODULE_INDICATOR_FOR_TESTS([$1])
202])
203
204AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
205[
206 GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK])
207 GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE])
208 GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE])
209 GNULIB_WCTRANS=0; AC_SUBST([GNULIB_WCTRANS])
210 GNULIB_TOWCTRANS=0; AC_SUBST([GNULIB_TOWCTRANS])
211 dnl Assume proper GNU behavior unless another module says otherwise.
212 HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK])
213 HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T])
214 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T])
215 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])
216])
This page took 0.603944 seconds and 4 git commands to generate.