VirtualBox

source: kBuild/trunk/src/grep/m4/wctype_h.m4

Last change on this file was 3529, checked in by bird, 3 years ago

Imported grep 3.7 from grep-3.7.tar.gz (sha256: c22b0cf2d4f6bbe599c902387e8058990e1eee99aef333a203829e5fd3dbb342), applying minimal auto-props.

  • Property svn:eol-style set to LF
File size: 6.3 KB
Line 
1# wctype_h.m4 serial 30
2
3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
4
5dnl Copyright (C) 2006-2021 Free Software Foundation, Inc.
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_ONCE([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([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
33 AC_REQUIRE([gl_TYPE_WINT_T_PREREQ])
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 #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],
49 [dnl Guess no on Linux libc5, yes otherwise.
50 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
51 #if __GNU_LIBRARY__ == 1
52 Linux libc5 i18n is broken.
53 #endif]], [[]])],
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
65 if test $GNULIBHEADERS_OVERRIDE_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
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],,,
88 [[#include <wchar.h>
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(
117 [[#include <wchar.h>
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(
136 [[#include <wchar.h>
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([[
151#if !(defined __GLIBC__ && !defined __UCLIBC__)
152# include <wchar.h>
153#endif
154#include <wctype.h>
155 ]],
156 [wctype iswctype wctrans towctrans
157 ])
158])
159
160# gl_WCTYPE_MODULE_INDICATOR([modulename])
161# sets the shell variable that indicates the presence of the given module
162# to a C preprocessor expression that will evaluate to 1.
163# This macro invocation must not occur in macros that are AC_REQUIREd.
164AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
165[
166 dnl Ensure to expand the default settings once only.
167 gl_WCTYPE_H_REQUIRE_DEFAULTS
168 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
169 dnl Define it also as a C macro, for the benefit of the unit tests.
170 gl_MODULE_INDICATOR_FOR_TESTS([$1])
171])
172
173# Initializes the default values for AC_SUBSTed shell variables.
174# This macro must not be AC_REQUIREd. It must only be invoked, and only
175# outside of macros or in macros that are not AC_REQUIREd.
176AC_DEFUN([gl_WCTYPE_H_REQUIRE_DEFAULTS],
177[
178 m4_defun(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS], [
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWBLANK])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWDIGIT])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWXDIGIT])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTYPE])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWCTYPE])
184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTRANS])
185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOWCTRANS])
186 ])
187 m4_require(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS])
188 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
189])
190
191AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
192[
193 dnl Assume proper GNU behavior unless another module says otherwise.
194 HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK])
195 HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T])
196 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T])
197 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])
198 REPLACE_ISWDIGIT=0; AC_SUBST([REPLACE_ISWDIGIT])
199 REPLACE_ISWXDIGIT=0; AC_SUBST([REPLACE_ISWXDIGIT])
200])
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette