summaryrefslogtreecommitdiffstats
path: root/gl/m4/wctype_h.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/wctype_h.m4')
-rw-r--r--gl/m4/wctype_h.m4181
1 files changed, 157 insertions, 24 deletions
diff --git a/gl/m4/wctype_h.m4 b/gl/m4/wctype_h.m4
index 3292451..82ada0e 100644
--- a/gl/m4/wctype_h.m4
+++ b/gl/m4/wctype_h.m4
@@ -1,8 +1,8 @@
1# wctype_h.m4 serial 6 1# wctype_h.m4 serial 18
2 2
3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it. 3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
4 4
5dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. 5dnl Copyright (C) 2006-2013 Free Software Foundation, Inc.
6dnl This file is free software; the Free Software Foundation 6dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it, 7dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved. 8dnl with or without modifications, as long as this notice is preserved.
@@ -11,6 +11,7 @@ dnl Written by Paul Eggert.
11 11
12AC_DEFUN([gl_WCTYPE_H], 12AC_DEFUN([gl_WCTYPE_H],
13[ 13[
14 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
14 AC_REQUIRE([AC_PROG_CC]) 15 AC_REQUIRE([AC_PROG_CC])
15 AC_REQUIRE([AC_CANONICAL_HOST]) 16 AC_REQUIRE([AC_CANONICAL_HOST])
16 AC_CHECK_FUNCS_ONCE([iswcntrl]) 17 AC_CHECK_FUNCS_ONCE([iswcntrl])
@@ -20,15 +21,6 @@ AC_DEFUN([gl_WCTYPE_H],
20 HAVE_ISWCNTRL=0 21 HAVE_ISWCNTRL=0
21 fi 22 fi
22 AC_SUBST([HAVE_ISWCNTRL]) 23 AC_SUBST([HAVE_ISWCNTRL])
23 AC_CHECK_FUNCS_ONCE([iswblank])
24 if test $ac_cv_func_iswblank = yes; then
25 HAVE_ISWBLANK=1
26 else
27 HAVE_ISWBLANK=0
28 fi
29 AC_SUBST([HAVE_ISWBLANK])
30 AC_CHECK_HEADERS_ONCE([wctype.h])
31 AC_REQUIRE([AC_C_INLINE])
32 24
33 AC_REQUIRE([gt_TYPE_WINT_T]) 25 AC_REQUIRE([gt_TYPE_WINT_T])
34 if test $gt_cv_c_wint_t = yes; then 26 if test $gt_cv_c_wint_t = yes; then
@@ -38,39 +30,180 @@ AC_DEFUN([gl_WCTYPE_H],
38 fi 30 fi
39 AC_SUBST([HAVE_WINT_T]) 31 AC_SUBST([HAVE_WINT_T])
40 32
33 gl_CHECK_NEXT_HEADERS([wctype.h])
41 if test $ac_cv_header_wctype_h = yes; then 34 if test $ac_cv_header_wctype_h = yes; then
42 if test $ac_cv_func_iswcntrl = yes; then 35 if test $ac_cv_func_iswcntrl = yes; then
43 dnl Linux libc5 has an iswprint function that returns 0 for all arguments. 36 dnl Linux libc5 has an iswprint function that returns 0 for all arguments.
44 dnl The other functions are likely broken in the same way. 37 dnl The other functions are likely broken in the same way.
45 AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works], 38 AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works],
46 [ 39 [
47 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 40 AC_RUN_IFELSE(
48 #include <stddef.h> 41 [AC_LANG_SOURCE([[
49 #include <stdio.h> 42 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
50 #include <time.h> 43 included before <wchar.h>.
51 #include <wchar.h> 44 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
52 #include <wctype.h> 45 must be included before <wchar.h>. */
53 int main () { return iswprint ('x') == 0; }]])], 46 #include <stddef.h>
47 #include <stdio.h>
48 #include <time.h>
49 #include <wchar.h>
50 #include <wctype.h>
51 int main () { return iswprint ('x') == 0; }
52 ]])],
54 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no], 53 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
55 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h> 54 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
56 #if __GNU_LIBRARY__ == 1 55 #if __GNU_LIBRARY__ == 1
57 Linux libc5 i18n is broken. 56 Linux libc5 i18n is broken.
58 #endif]], [])], 57 #endif]], [])],
59 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no]) 58 [gl_cv_func_iswcntrl_works="guessing yes"],
59 [gl_cv_func_iswcntrl_works="guessing no"])
60 ]) 60 ])
61 ]) 61 ])
62 fi 62 fi
63 gl_CHECK_NEXT_HEADERS([wctype.h])
64 HAVE_WCTYPE_H=1 63 HAVE_WCTYPE_H=1
65 else 64 else
66 HAVE_WCTYPE_H=0 65 HAVE_WCTYPE_H=0
67 fi 66 fi
68 AC_SUBST([HAVE_WCTYPE_H]) 67 AC_SUBST([HAVE_WCTYPE_H])
69 68
70 if test "$gl_cv_func_iswcntrl_works" = no; then 69 case "$gl_cv_func_iswcntrl_works" in
71 REPLACE_ISWCNTRL=1 70 *yes) REPLACE_ISWCNTRL=0 ;;
71 *) REPLACE_ISWCNTRL=1 ;;
72 esac
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
72 else 82 else
73 REPLACE_ISWCNTRL=0 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],,,
88 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
89 included before <wchar.h>.
90 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
91 must be included before <wchar.h>. */
92 #include <stddef.h>
93 #include <stdio.h>
94 #include <time.h>
95 #include <wchar.h>
96 #if HAVE_WCTYPE_H
97 # include <wctype.h>
98 #endif
99 ]])
100 if test $ac_cv_have_decl_towlower = yes; then
101 dnl On Minix 3.1.8, the system's <wctype.h> declares towlower() and
102 dnl towupper() although it does not have the functions. Avoid a
103 dnl collision with gnulib's replacement.
104 REPLACE_TOWLOWER=1
105 else
106 REPLACE_TOWLOWER=0
107 fi
108 fi
74 fi 109 fi
75 AC_SUBST([REPLACE_ISWCNTRL]) 110 AC_SUBST([REPLACE_TOWLOWER])
111
112 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_TOWLOWER = 1; then
113 dnl Redefine towlower, towupper in <wctype.h>.
114 :
115 fi
116
117 dnl We assume that the wctype() and iswctype() functions exist if and only
118 dnl if the type wctype_t is defined in <wchar.h> or in <wctype.h> if that
119 dnl exists.
120 dnl HP-UX 11.00 declares all these in <wchar.h> and lacks <wctype.h>.
121 AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t],
122 [AC_COMPILE_IFELSE(
123 [AC_LANG_PROGRAM(
124 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
125 included before <wchar.h>.
126 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
127 must be included before <wchar.h>. */
128 #include <stddef.h>
129 #include <stdio.h>
130 #include <time.h>
131 #include <wchar.h>
132 #if HAVE_WCTYPE_H
133 # include <wctype.h>
134 #endif
135 wctype_t a;
136 ]],
137 [[]])],
138 [gl_cv_type_wctype_t=yes],
139 [gl_cv_type_wctype_t=no])
140 ])
141 if test $gl_cv_type_wctype_t = no; then
142 HAVE_WCTYPE_T=0
143 fi
144
145 dnl We assume that the wctrans() and towctrans() functions exist if and only
146 dnl if the type wctrans_t is defined in <wctype.h>.
147 AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t],
148 [AC_COMPILE_IFELSE(
149 [AC_LANG_PROGRAM(
150 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
151 included before <wchar.h>.
152 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
153 must be included before <wchar.h>. */
154 #include <stddef.h>
155 #include <stdio.h>
156 #include <time.h>
157 #include <wchar.h>
158 #include <wctype.h>
159 wctrans_t a;
160 ]],
161 [[]])],
162 [gl_cv_type_wctrans_t=yes],
163 [gl_cv_type_wctrans_t=no])
164 ])
165 if test $gl_cv_type_wctrans_t = no; then
166 HAVE_WCTRANS_T=0
167 fi
168
169 dnl Check for declarations of anything we want to poison if the
170 dnl corresponding gnulib module is not in use.
171 gl_WARN_ON_USE_PREPARE([[
172/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
173 <wchar.h>.
174 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
175 included before <wchar.h>. */
176#if !(defined __GLIBC__ && !defined __UCLIBC__)
177# include <stddef.h>
178# include <stdio.h>
179# include <time.h>
180# include <wchar.h>
181#endif
182#include <wctype.h>
183 ]],
184 [wctype iswctype wctrans towctrans
185 ])
186])
187
188AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
189[
190 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
191 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
192 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
193 dnl Define it also as a C macro, for the benefit of the unit tests.
194 gl_MODULE_INDICATOR_FOR_TESTS([$1])
195])
196
197AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
198[
199 GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK])
200 GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE])
201 GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE])
202 GNULIB_WCTRANS=0; AC_SUBST([GNULIB_WCTRANS])
203 GNULIB_TOWCTRANS=0; AC_SUBST([GNULIB_TOWCTRANS])
204 dnl Assume proper GNU behavior unless another module says otherwise.
205 HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK])
206 HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T])
207 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T])
208 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])
76]) 209])