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