diff options
-rw-r--r-- | arg-nonnull.h | 26 | ||||
-rw-r--r-- | c++defs.h | 271 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | m4/00gnulib.m4 | 30 | ||||
-rw-r--r-- | m4/Makefile.am | 1 | ||||
-rw-r--r-- | m4/extensions.m4 | 118 | ||||
-rw-r--r-- | m4/gnulib-cache.m4 | 35 | ||||
-rw-r--r-- | m4/gnulib-common.m4 | 234 | ||||
-rw-r--r-- | m4/gnulib-comp.m4 | 219 | ||||
-rw-r--r-- | m4/gnulib-tool.m4 | 57 | ||||
-rw-r--r-- | m4/include_next.m4 | 244 | ||||
-rw-r--r-- | m4/stddef_h.m4 | 45 | ||||
-rw-r--r-- | m4/string_h.m4 | 115 | ||||
-rw-r--r-- | m4/strtok_r.m4 | 74 | ||||
-rw-r--r-- | m4/warn-on-use.m4 | 45 | ||||
-rw-r--r-- | m4/wchar_t.m4 | 18 | ||||
-rw-r--r-- | src/util/Makefile.am | 4 | ||||
-rw-r--r-- | src/util/libgnu/Makefile.am | 248 | ||||
-rw-r--r-- | src/util/libgnu/dummy.c | 42 | ||||
-rw-r--r-- | src/util/libgnu/stddef.in.h | 87 | ||||
-rw-r--r-- | src/util/libgnu/string.in.h | 970 | ||||
-rw-r--r-- | src/util/libgnu/strtok_r.c | 76 | ||||
-rw-r--r-- | warn-on-use.h | 109 |
23 files changed, 3063 insertions, 8 deletions
diff --git a/arg-nonnull.h b/arg-nonnull.h new file mode 100644 index 000000000..6c2f1e82d --- /dev/null +++ b/arg-nonnull.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* A C macro for declaring that specific arguments must not be NULL. | ||
2 | Copyright (C) 2009-2011 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify it | ||
5 | under the terms of the GNU General Public License as published | ||
6 | by the Free Software Foundation; either version 3 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools | ||
18 | that the values passed as arguments n, ..., m must be non-NULL pointers. | ||
19 | n = 1 stands for the first argument, n = 2 for the second argument etc. */ | ||
20 | #ifndef _GL_ARG_NONNULL | ||
21 | # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 | ||
22 | # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) | ||
23 | # else | ||
24 | # define _GL_ARG_NONNULL(params) | ||
25 | # endif | ||
26 | #endif | ||
diff --git a/c++defs.h b/c++defs.h new file mode 100644 index 000000000..b6821a64a --- /dev/null +++ b/c++defs.h | |||
@@ -0,0 +1,271 @@ | |||
1 | /* C++ compatible function declaration macros. | ||
2 | Copyright (C) 2010-2011 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify it | ||
5 | under the terms of the GNU General Public License as published | ||
6 | by the Free Software Foundation; either version 3 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #ifndef _GL_CXXDEFS_H | ||
18 | #define _GL_CXXDEFS_H | ||
19 | |||
20 | /* The three most frequent use cases of these macros are: | ||
21 | |||
22 | * For providing a substitute for a function that is missing on some | ||
23 | platforms, but is declared and works fine on the platforms on which | ||
24 | it exists: | ||
25 | |||
26 | #if @GNULIB_FOO@ | ||
27 | # if !@HAVE_FOO@ | ||
28 | _GL_FUNCDECL_SYS (foo, ...); | ||
29 | # endif | ||
30 | _GL_CXXALIAS_SYS (foo, ...); | ||
31 | _GL_CXXALIASWARN (foo); | ||
32 | #elif defined GNULIB_POSIXCHECK | ||
33 | ... | ||
34 | #endif | ||
35 | |||
36 | * For providing a replacement for a function that exists on all platforms, | ||
37 | but is broken/insufficient and needs to be replaced on some platforms: | ||
38 | |||
39 | #if @GNULIB_FOO@ | ||
40 | # if @REPLACE_FOO@ | ||
41 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
42 | # undef foo | ||
43 | # define foo rpl_foo | ||
44 | # endif | ||
45 | _GL_FUNCDECL_RPL (foo, ...); | ||
46 | _GL_CXXALIAS_RPL (foo, ...); | ||
47 | # else | ||
48 | _GL_CXXALIAS_SYS (foo, ...); | ||
49 | # endif | ||
50 | _GL_CXXALIASWARN (foo); | ||
51 | #elif defined GNULIB_POSIXCHECK | ||
52 | ... | ||
53 | #endif | ||
54 | |||
55 | * For providing a replacement for a function that exists on some platforms | ||
56 | but is broken/insufficient and needs to be replaced on some of them and | ||
57 | is additionally either missing or undeclared on some other platforms: | ||
58 | |||
59 | #if @GNULIB_FOO@ | ||
60 | # if @REPLACE_FOO@ | ||
61 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
62 | # undef foo | ||
63 | # define foo rpl_foo | ||
64 | # endif | ||
65 | _GL_FUNCDECL_RPL (foo, ...); | ||
66 | _GL_CXXALIAS_RPL (foo, ...); | ||
67 | # else | ||
68 | # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ | ||
69 | _GL_FUNCDECL_SYS (foo, ...); | ||
70 | # endif | ||
71 | _GL_CXXALIAS_SYS (foo, ...); | ||
72 | # endif | ||
73 | _GL_CXXALIASWARN (foo); | ||
74 | #elif defined GNULIB_POSIXCHECK | ||
75 | ... | ||
76 | #endif | ||
77 | */ | ||
78 | |||
79 | /* _GL_EXTERN_C declaration; | ||
80 | performs the declaration with C linkage. */ | ||
81 | #if defined __cplusplus | ||
82 | # define _GL_EXTERN_C extern "C" | ||
83 | #else | ||
84 | # define _GL_EXTERN_C extern | ||
85 | #endif | ||
86 | |||
87 | /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); | ||
88 | declares a replacement function, named rpl_func, with the given prototype, | ||
89 | consisting of return type, parameters, and attributes. | ||
90 | Example: | ||
91 | _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) | ||
92 | _GL_ARG_NONNULL ((1))); | ||
93 | */ | ||
94 | #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ | ||
95 | _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) | ||
96 | #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ | ||
97 | _GL_EXTERN_C rettype rpl_func parameters_and_attributes | ||
98 | |||
99 | /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); | ||
100 | declares the system function, named func, with the given prototype, | ||
101 | consisting of return type, parameters, and attributes. | ||
102 | Example: | ||
103 | _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) | ||
104 | _GL_ARG_NONNULL ((1))); | ||
105 | */ | ||
106 | #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ | ||
107 | _GL_EXTERN_C rettype func parameters_and_attributes | ||
108 | |||
109 | /* _GL_CXXALIAS_RPL (func, rettype, parameters); | ||
110 | declares a C++ alias called GNULIB_NAMESPACE::func | ||
111 | that redirects to rpl_func, if GNULIB_NAMESPACE is defined. | ||
112 | Example: | ||
113 | _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); | ||
114 | */ | ||
115 | #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ | ||
116 | _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) | ||
117 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
118 | # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ | ||
119 | namespace GNULIB_NAMESPACE \ | ||
120 | { \ | ||
121 | rettype (*const func) parameters = ::rpl_func; \ | ||
122 | } \ | ||
123 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
124 | #else | ||
125 | # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ | ||
126 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
127 | #endif | ||
128 | |||
129 | /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); | ||
130 | is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); | ||
131 | except that the C function rpl_func may have a slightly different | ||
132 | declaration. A cast is used to silence the "invalid conversion" error | ||
133 | that would otherwise occur. */ | ||
134 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
135 | # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ | ||
136 | namespace GNULIB_NAMESPACE \ | ||
137 | { \ | ||
138 | rettype (*const func) parameters = \ | ||
139 | reinterpret_cast<rettype(*)parameters>(::rpl_func); \ | ||
140 | } \ | ||
141 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
142 | #else | ||
143 | # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ | ||
144 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
145 | #endif | ||
146 | |||
147 | /* _GL_CXXALIAS_SYS (func, rettype, parameters); | ||
148 | declares a C++ alias called GNULIB_NAMESPACE::func | ||
149 | that redirects to the system provided function func, if GNULIB_NAMESPACE | ||
150 | is defined. | ||
151 | Example: | ||
152 | _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); | ||
153 | */ | ||
154 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
155 | /* If we were to write | ||
156 | rettype (*const func) parameters = ::func; | ||
157 | like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls | ||
158 | better (remove an indirection through a 'static' pointer variable), | ||
159 | but then the _GL_CXXALIASWARN macro below would cause a warning not only | ||
160 | for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ | ||
161 | # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ | ||
162 | namespace GNULIB_NAMESPACE \ | ||
163 | { \ | ||
164 | static rettype (*func) parameters = ::func; \ | ||
165 | } \ | ||
166 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
167 | #else | ||
168 | # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ | ||
169 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
170 | #endif | ||
171 | |||
172 | /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); | ||
173 | is like _GL_CXXALIAS_SYS (func, rettype, parameters); | ||
174 | except that the C function func may have a slightly different declaration. | ||
175 | A cast is used to silence the "invalid conversion" error that would | ||
176 | otherwise occur. */ | ||
177 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
178 | # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ | ||
179 | namespace GNULIB_NAMESPACE \ | ||
180 | { \ | ||
181 | static rettype (*func) parameters = \ | ||
182 | reinterpret_cast<rettype(*)parameters>(::func); \ | ||
183 | } \ | ||
184 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
185 | #else | ||
186 | # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ | ||
187 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
188 | #endif | ||
189 | |||
190 | /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); | ||
191 | is like _GL_CXXALIAS_SYS (func, rettype, parameters); | ||
192 | except that the C function is picked among a set of overloaded functions, | ||
193 | namely the one with rettype2 and parameters2. Two consecutive casts | ||
194 | are used to silence the "cannot find a match" and "invalid conversion" | ||
195 | errors that would otherwise occur. */ | ||
196 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
197 | /* The outer cast must be a reinterpret_cast. | ||
198 | The inner cast: When the function is defined as a set of overloaded | ||
199 | functions, it works as a static_cast<>, choosing the designated variant. | ||
200 | When the function is defined as a single variant, it works as a | ||
201 | reinterpret_cast<>. The parenthesized cast syntax works both ways. */ | ||
202 | # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ | ||
203 | namespace GNULIB_NAMESPACE \ | ||
204 | { \ | ||
205 | static rettype (*func) parameters = \ | ||
206 | reinterpret_cast<rettype(*)parameters>( \ | ||
207 | (rettype2(*)parameters2)(::func)); \ | ||
208 | } \ | ||
209 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
210 | #else | ||
211 | # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ | ||
212 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
213 | #endif | ||
214 | |||
215 | /* _GL_CXXALIASWARN (func); | ||
216 | causes a warning to be emitted when ::func is used but not when | ||
217 | GNULIB_NAMESPACE::func is used. func must be defined without overloaded | ||
218 | variants. */ | ||
219 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
220 | # define _GL_CXXALIASWARN(func) \ | ||
221 | _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) | ||
222 | # define _GL_CXXALIASWARN_1(func,namespace) \ | ||
223 | _GL_CXXALIASWARN_2 (func, namespace) | ||
224 | /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, | ||
225 | we enable the warning only when not optimizing. */ | ||
226 | # if !__OPTIMIZE__ | ||
227 | # define _GL_CXXALIASWARN_2(func,namespace) \ | ||
228 | _GL_WARN_ON_USE (func, \ | ||
229 | "The symbol ::" #func " refers to the system function. " \ | ||
230 | "Use " #namespace "::" #func " instead.") | ||
231 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||
232 | # define _GL_CXXALIASWARN_2(func,namespace) \ | ||
233 | extern __typeof__ (func) func | ||
234 | # else | ||
235 | # define _GL_CXXALIASWARN_2(func,namespace) \ | ||
236 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
237 | # endif | ||
238 | #else | ||
239 | # define _GL_CXXALIASWARN(func) \ | ||
240 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
241 | #endif | ||
242 | |||
243 | /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); | ||
244 | causes a warning to be emitted when the given overloaded variant of ::func | ||
245 | is used but not when GNULIB_NAMESPACE::func is used. */ | ||
246 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
247 | # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ | ||
248 | _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ | ||
249 | GNULIB_NAMESPACE) | ||
250 | # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ | ||
251 | _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) | ||
252 | /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, | ||
253 | we enable the warning only when not optimizing. */ | ||
254 | # if !__OPTIMIZE__ | ||
255 | # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ | ||
256 | _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ | ||
257 | "The symbol ::" #func " refers to the system function. " \ | ||
258 | "Use " #namespace "::" #func " instead.") | ||
259 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||
260 | # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ | ||
261 | extern __typeof__ (func) func | ||
262 | # else | ||
263 | # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ | ||
264 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
265 | # endif | ||
266 | #else | ||
267 | # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ | ||
268 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
269 | #endif | ||
270 | |||
271 | #endif /* _GL_CXXDEFS_H */ | ||
diff --git a/configure.ac b/configure.ac index 7938ff1d8..822c0d53e 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -32,6 +32,8 @@ AH_TOP([#define _GNU_SOURCE 1]) | |||
32 | AC_CANONICAL_HOST | 32 | AC_CANONICAL_HOST |
33 | AC_PROG_AWK | 33 | AC_PROG_AWK |
34 | AC_PROG_CC | 34 | AC_PROG_CC |
35 | gl_EARLY | ||
36 | gl_INIT | ||
35 | AC_PROG_CPP | 37 | AC_PROG_CPP |
36 | AC_PROG_CXX | 38 | AC_PROG_CXX |
37 | AC_PROG_OBJC | 39 | AC_PROG_OBJC |
@@ -809,6 +811,7 @@ src/testing/Makefile | |||
809 | src/topology/Makefile | 811 | src/topology/Makefile |
810 | src/transport/Makefile | 812 | src/transport/Makefile |
811 | src/util/Makefile | 813 | src/util/Makefile |
814 | src/util/libgnu/Makefile | ||
812 | src/vpn/Makefile | 815 | src/vpn/Makefile |
813 | src/chat/Makefile | 816 | src/chat/Makefile |
814 | pkgconfig/Makefile | 817 | pkgconfig/Makefile |
diff --git a/m4/00gnulib.m4 b/m4/00gnulib.m4 new file mode 100644 index 000000000..7feed4669 --- /dev/null +++ b/m4/00gnulib.m4 | |||
@@ -0,0 +1,30 @@ | |||
1 | # 00gnulib.m4 serial 2 | ||
2 | dnl Copyright (C) 2009-2011 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | dnl This file must be named something that sorts before all other | ||
8 | dnl gnulib-provided .m4 files. It is needed until such time as we can | ||
9 | dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics. | ||
10 | |||
11 | # AC_DEFUN_ONCE([NAME], VALUE) | ||
12 | # ---------------------------- | ||
13 | # Define NAME to expand to VALUE on the first use (whether by direct | ||
14 | # expansion, or by AC_REQUIRE), and to nothing on all subsequent uses. | ||
15 | # Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This | ||
16 | # definition is slower than the version in Autoconf 2.64, because it | ||
17 | # can only use interfaces that existed since 2.59; but it achieves the | ||
18 | # same effect. Quoting is necessary to avoid confusing Automake. | ||
19 | m4_version_prereq([2.63.263], [], | ||
20 | [m4_define([AC][_DEFUN_ONCE], | ||
21 | [AC][_DEFUN([$1], | ||
22 | [AC_REQUIRE([_gl_DEFUN_ONCE([$1])], | ||
23 | [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl | ||
24 | [AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])]) | ||
25 | |||
26 | # gl_00GNULIB | ||
27 | # ----------- | ||
28 | # Witness macro that this file has been included. Needed to force | ||
29 | # Automake to include this file prior to all other gnulib .m4 files. | ||
30 | AC_DEFUN([gl_00GNULIB]) | ||
diff --git a/m4/Makefile.am b/m4/Makefile.am index 3afad7e81..7b44b8e69 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am | |||
@@ -5,6 +5,7 @@ gettext.m4\ | |||
5 | glib-2.0.m4\ | 5 | glib-2.0.m4\ |
6 | glibc21.m4\ | 6 | glibc21.m4\ |
7 | glib-gettext.m4\ | 7 | glib-gettext.m4\ |
8 | gnulib-cache.m4\ | ||
8 | gtk-2.0.m4\ | 9 | gtk-2.0.m4\ |
9 | iconv.m4\ | 10 | iconv.m4\ |
10 | intdiv0.m4\ | 11 | intdiv0.m4\ |
diff --git a/m4/extensions.m4 b/m4/extensions.m4 new file mode 100644 index 000000000..1330503f0 --- /dev/null +++ b/m4/extensions.m4 | |||
@@ -0,0 +1,118 @@ | |||
1 | # serial 9 -*- Autoconf -*- | ||
2 | # Enable extensions on systems that normally disable them. | ||
3 | |||
4 | # Copyright (C) 2003, 2006-2011 Free Software Foundation, Inc. | ||
5 | # This file is free software; the Free Software Foundation | ||
6 | # gives unlimited permission to copy and/or distribute it, | ||
7 | # with or without modifications, as long as this notice is preserved. | ||
8 | |||
9 | # This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS | ||
10 | # Autoconf. Perhaps we can remove this once we can assume Autoconf | ||
11 | # 2.62 or later everywhere, but since CVS Autoconf mutates rapidly | ||
12 | # enough in this area it's likely we'll need to redefine | ||
13 | # AC_USE_SYSTEM_EXTENSIONS for quite some time. | ||
14 | |||
15 | # If autoconf reports a warning | ||
16 | # warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS | ||
17 | # or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS | ||
18 | # the fix is | ||
19 | # 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked | ||
20 | # but always AC_REQUIREd, | ||
21 | # 2) to ensure that for each occurrence of | ||
22 | # AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) | ||
23 | # or | ||
24 | # AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | ||
25 | # the corresponding gnulib module description has 'extensions' among | ||
26 | # its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS | ||
27 | # invocation occurs in gl_EARLY, not in gl_INIT. | ||
28 | |||
29 | # AC_USE_SYSTEM_EXTENSIONS | ||
30 | # ------------------------ | ||
31 | # Enable extensions on systems that normally disable them, | ||
32 | # typically due to standards-conformance issues. | ||
33 | # Remember that #undef in AH_VERBATIM gets replaced with #define by | ||
34 | # AC_DEFINE. The goal here is to define all known feature-enabling | ||
35 | # macros, then, if reports of conflicts are made, disable macros that | ||
36 | # cause problems on some platforms (such as __EXTENSIONS__). | ||
37 | AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS], | ||
38 | [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl | ||
39 | AC_BEFORE([$0], [AC_RUN_IFELSE])dnl | ||
40 | |||
41 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
42 | |||
43 | AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=]) | ||
44 | if test "$MINIX" = yes; then | ||
45 | AC_DEFINE([_POSIX_SOURCE], [1], | ||
46 | [Define to 1 if you need to in order for `stat' and other | ||
47 | things to work.]) | ||
48 | AC_DEFINE([_POSIX_1_SOURCE], [2], | ||
49 | [Define to 2 if the system does not provide POSIX.1 features | ||
50 | except with this defined.]) | ||
51 | AC_DEFINE([_MINIX], [1], | ||
52 | [Define to 1 if on MINIX.]) | ||
53 | fi | ||
54 | |||
55 | dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500, | ||
56 | dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already | ||
57 | dnl provided. | ||
58 | case "$host_os" in | ||
59 | hpux*) | ||
60 | AC_DEFINE([_XOPEN_SOURCE], [500], | ||
61 | [Define to 500 only on HP-UX.]) | ||
62 | ;; | ||
63 | esac | ||
64 | |||
65 | AH_VERBATIM([__EXTENSIONS__], | ||
66 | [/* Enable extensions on AIX 3, Interix. */ | ||
67 | #ifndef _ALL_SOURCE | ||
68 | # undef _ALL_SOURCE | ||
69 | #endif | ||
70 | /* Enable GNU extensions on systems that have them. */ | ||
71 | #ifndef _GNU_SOURCE | ||
72 | # undef _GNU_SOURCE | ||
73 | #endif | ||
74 | /* Enable threading extensions on Solaris. */ | ||
75 | #ifndef _POSIX_PTHREAD_SEMANTICS | ||
76 | # undef _POSIX_PTHREAD_SEMANTICS | ||
77 | #endif | ||
78 | /* Enable extensions on HP NonStop. */ | ||
79 | #ifndef _TANDEM_SOURCE | ||
80 | # undef _TANDEM_SOURCE | ||
81 | #endif | ||
82 | /* Enable general extensions on Solaris. */ | ||
83 | #ifndef __EXTENSIONS__ | ||
84 | # undef __EXTENSIONS__ | ||
85 | #endif | ||
86 | ]) | ||
87 | AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], | ||
88 | [ac_cv_safe_to_define___extensions__], | ||
89 | [AC_COMPILE_IFELSE( | ||
90 | [AC_LANG_PROGRAM([[ | ||
91 | # define __EXTENSIONS__ 1 | ||
92 | ]AC_INCLUDES_DEFAULT])], | ||
93 | [ac_cv_safe_to_define___extensions__=yes], | ||
94 | [ac_cv_safe_to_define___extensions__=no])]) | ||
95 | test $ac_cv_safe_to_define___extensions__ = yes && | ||
96 | AC_DEFINE([__EXTENSIONS__]) | ||
97 | AC_DEFINE([_ALL_SOURCE]) | ||
98 | AC_DEFINE([_GNU_SOURCE]) | ||
99 | AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) | ||
100 | AC_DEFINE([_TANDEM_SOURCE]) | ||
101 | ])# AC_USE_SYSTEM_EXTENSIONS | ||
102 | |||
103 | # gl_USE_SYSTEM_EXTENSIONS | ||
104 | # ------------------------ | ||
105 | # Enable extensions on systems that normally disable them, | ||
106 | # typically due to standards-conformance issues. | ||
107 | AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], | ||
108 | [ | ||
109 | dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS. | ||
110 | dnl gnulib does not need it. But if it gets required by third-party macros | ||
111 | dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a | ||
112 | dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS". | ||
113 | dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE, | ||
114 | dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck. | ||
115 | AC_REQUIRE([AC_GNU_SOURCE]) | ||
116 | |||
117 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) | ||
118 | ]) | ||
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 new file mode 100644 index 000000000..a9ec8f3bd --- /dev/null +++ b/m4/gnulib-cache.m4 | |||
@@ -0,0 +1,35 @@ | |||
1 | # Copyright (C) 2002-2011 Free Software Foundation, Inc. | ||
2 | # | ||
3 | # This file is free software, distributed under the terms of the GNU | ||
4 | # General Public License. As a special exception to the GNU General | ||
5 | # Public License, this file may be distributed as part of a program | ||
6 | # that contains a configuration script generated by Autoconf, under | ||
7 | # the same distribution terms as the rest of that program. | ||
8 | # | ||
9 | # Generated by gnulib-tool. | ||
10 | # | ||
11 | # This file represents the specification of how gnulib-tool is used. | ||
12 | # It acts as a cache: It is written and read by gnulib-tool. | ||
13 | # In projects that use version control, this file is meant to be put under | ||
14 | # version control, like the configure.ac and various Makefile.am files. | ||
15 | |||
16 | |||
17 | # Specification in the form of a command-line invocation: | ||
18 | # gnulib-tool --import --dir=/home/nils/workspace/gnunet --lib=libgnu --source-base=src/util/libgnu --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --libtool --macro-prefix=gl strtok_r | ||
19 | |||
20 | # Specification in the form of a few gnulib-tool.m4 macro invocations: | ||
21 | gl_LOCAL_DIR([]) | ||
22 | gl_MODULES([ | ||
23 | strtok_r | ||
24 | ]) | ||
25 | gl_AVOID([]) | ||
26 | gl_SOURCE_BASE([src/util/libgnu]) | ||
27 | gl_M4_BASE([m4]) | ||
28 | gl_PO_BASE([]) | ||
29 | gl_DOC_BASE([doc]) | ||
30 | gl_TESTS_BASE([tests]) | ||
31 | gl_LIB([libgnu]) | ||
32 | gl_MAKEFILE_NAME([]) | ||
33 | gl_LIBTOOL | ||
34 | gl_MACRO_PREFIX([gl]) | ||
35 | gl_PO_DOMAIN([]) | ||
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 new file mode 100644 index 000000000..ecbf33694 --- /dev/null +++ b/m4/gnulib-common.m4 | |||
@@ -0,0 +1,234 @@ | |||
1 | # gnulib-common.m4 serial 23 | ||
2 | dnl Copyright (C) 2007-2011 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | # gl_COMMON | ||
8 | # is expanded unconditionally through gnulib-tool magic. | ||
9 | AC_DEFUN([gl_COMMON], [ | ||
10 | dnl Use AC_REQUIRE here, so that the code is expanded once only. | ||
11 | AC_REQUIRE([gl_00GNULIB]) | ||
12 | AC_REQUIRE([gl_COMMON_BODY]) | ||
13 | ]) | ||
14 | AC_DEFUN([gl_COMMON_BODY], [ | ||
15 | AH_VERBATIM([isoc99_inline], | ||
16 | [/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports | ||
17 | the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of | ||
18 | earlier versions), but does not display it by setting __GNUC_STDC_INLINE__. | ||
19 | __APPLE__ && __MACH__ test for MacOS X. | ||
20 | __APPLE_CC__ tests for the Apple compiler and its version. | ||
21 | __STDC_VERSION__ tests for the C99 mode. */ | ||
22 | #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ | ||
23 | # define __GNUC_STDC_INLINE__ 1 | ||
24 | #endif]) | ||
25 | AH_VERBATIM([unused_parameter], | ||
26 | [/* Define as a marker that can be attached to declarations that might not | ||
27 | be used. This helps to reduce warnings, such as from | ||
28 | GCC -Wunused-parameter. */ | ||
29 | #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) | ||
30 | # define _GL_UNUSED __attribute__ ((__unused__)) | ||
31 | #else | ||
32 | # define _GL_UNUSED | ||
33 | #endif | ||
34 | /* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name | ||
35 | is a misnomer outside of parameter lists. */ | ||
36 | #define _UNUSED_PARAMETER_ _GL_UNUSED | ||
37 | ]) | ||
38 | dnl Preparation for running test programs: | ||
39 | dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not | ||
40 | dnl to /dev/tty, so they can be redirected to log files. Such diagnostics | ||
41 | dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N. | ||
42 | LIBC_FATAL_STDERR_=1 | ||
43 | export LIBC_FATAL_STDERR_ | ||
44 | ]) | ||
45 | |||
46 | # gl_MODULE_INDICATOR_CONDITION | ||
47 | # expands to a C preprocessor expression that evaluates to 1 or 0, depending | ||
48 | # whether a gnulib module that has been requested shall be considered present | ||
49 | # or not. | ||
50 | AC_DEFUN([gl_MODULE_INDICATOR_CONDITION], [1]) | ||
51 | |||
52 | # gl_MODULE_INDICATOR_SET_VARIABLE([modulename]) | ||
53 | # sets the shell variable that indicates the presence of the given module to | ||
54 | # a C preprocessor expression that will evaluate to 1. | ||
55 | AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], | ||
56 | [ | ||
57 | GNULIB_[]m4_translit([[$1]], | ||
58 | [abcdefghijklmnopqrstuvwxyz./-], | ||
59 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=gl_MODULE_INDICATOR_CONDITION | ||
60 | ]) | ||
61 | |||
62 | # gl_MODULE_INDICATOR([modulename]) | ||
63 | # defines a C macro indicating the presence of the given module | ||
64 | # in a location where it can be used. | ||
65 | # | Value | Value | | ||
66 | # | in lib/ | in tests/ | | ||
67 | # --------------------------------------------+---------+-----------+ | ||
68 | # Module present among main modules: | 1 | 1 | | ||
69 | # --------------------------------------------+---------+-----------+ | ||
70 | # Module present among tests-related modules: | 0 | 1 | | ||
71 | # --------------------------------------------+---------+-----------+ | ||
72 | # Module not present at all: | 0 | 0 | | ||
73 | # --------------------------------------------+---------+-----------+ | ||
74 | AC_DEFUN([gl_MODULE_INDICATOR], | ||
75 | [ | ||
76 | AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]], | ||
77 | [abcdefghijklmnopqrstuvwxyz./-], | ||
78 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), | ||
79 | [gl_MODULE_INDICATOR_CONDITION], | ||
80 | [Define to a C preprocessor expression that evaluates to 1 or 0, | ||
81 | depending whether the gnulib module $1 shall be considered present.]) | ||
82 | ]) | ||
83 | |||
84 | # gl_MODULE_INDICATOR_FOR_TESTS([modulename]) | ||
85 | # defines a C macro indicating the presence of the given module | ||
86 | # in lib or tests. This is useful to determine whether the module | ||
87 | # should be tested. | ||
88 | # | Value | Value | | ||
89 | # | in lib/ | in tests/ | | ||
90 | # --------------------------------------------+---------+-----------+ | ||
91 | # Module present among main modules: | 1 | 1 | | ||
92 | # --------------------------------------------+---------+-----------+ | ||
93 | # Module present among tests-related modules: | 1 | 1 | | ||
94 | # --------------------------------------------+---------+-----------+ | ||
95 | # Module not present at all: | 0 | 0 | | ||
96 | # --------------------------------------------+---------+-----------+ | ||
97 | AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], | ||
98 | [ | ||
99 | AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]], | ||
100 | [abcdefghijklmnopqrstuvwxyz./-], | ||
101 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1], | ||
102 | [Define to 1 when the gnulib module $1 should be tested.]) | ||
103 | ]) | ||
104 | |||
105 | # gl_ASSERT_NO_GNULIB_POSIXCHECK | ||
106 | # asserts that there will never be a need to #define GNULIB_POSIXCHECK. | ||
107 | # and thereby enables an optimization of configure and config.h. | ||
108 | # Used by Emacs. | ||
109 | AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK], | ||
110 | [ | ||
111 | dnl Override gl_WARN_ON_USE_PREPARE. | ||
112 | AC_DEFUN([gl_WARN_ON_USE_PREPARE], []) | ||
113 | ]) | ||
114 | |||
115 | # gl_ASSERT_NO_GNULIB_TESTS | ||
116 | # asserts that there will be no gnulib tests in the scope of the configure.ac | ||
117 | # and thereby enables an optimization of config.h. | ||
118 | # Used by Emacs. | ||
119 | AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS], | ||
120 | [ | ||
121 | dnl Override gl_MODULE_INDICATOR_FOR_TESTS. | ||
122 | AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], []) | ||
123 | ]) | ||
124 | |||
125 | # Test whether <features.h> exists. | ||
126 | # Set HAVE_FEATURES_H. | ||
127 | AC_DEFUN([gl_FEATURES_H], | ||
128 | [ | ||
129 | AC_CHECK_HEADERS_ONCE([features.h]) | ||
130 | if test $ac_cv_header_features_h = yes; then | ||
131 | HAVE_FEATURES_H=1 | ||
132 | else | ||
133 | HAVE_FEATURES_H=0 | ||
134 | fi | ||
135 | AC_SUBST([HAVE_FEATURES_H]) | ||
136 | ]) | ||
137 | |||
138 | # m4_foreach_w | ||
139 | # is a backport of autoconf-2.59c's m4_foreach_w. | ||
140 | # Remove this macro when we can assume autoconf >= 2.60. | ||
141 | m4_ifndef([m4_foreach_w], | ||
142 | [m4_define([m4_foreach_w], | ||
143 | [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])]) | ||
144 | |||
145 | # AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH]) | ||
146 | # ---------------------------------------------------- | ||
147 | # Backport of autoconf-2.63b's macro. | ||
148 | # Remove this macro when we can assume autoconf >= 2.64. | ||
149 | m4_ifndef([AS_VAR_IF], | ||
150 | [m4_define([AS_VAR_IF], | ||
151 | [AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])]) | ||
152 | |||
153 | # AC_PROG_MKDIR_P | ||
154 | # is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix | ||
155 | # for interoperability with automake-1.9.6 from autoconf-2.62. | ||
156 | # Remove this macro when we can assume autoconf >= 2.62 or | ||
157 | # autoconf >= 2.60 && automake >= 1.10. | ||
158 | m4_ifdef([AC_PROG_MKDIR_P], [ | ||
159 | dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed. | ||
160 | m4_define([AC_PROG_MKDIR_P], | ||
161 | m4_defn([AC_PROG_MKDIR_P])[ | ||
162 | AC_SUBST([MKDIR_P])])], [ | ||
163 | dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P. | ||
164 | AC_DEFUN_ONCE([AC_PROG_MKDIR_P], | ||
165 | [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake | ||
166 | MKDIR_P='$(mkdir_p)' | ||
167 | AC_SUBST([MKDIR_P])])]) | ||
168 | |||
169 | # AC_C_RESTRICT | ||
170 | # This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61, | ||
171 | # so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++ | ||
172 | # works. | ||
173 | # This definition can be removed once autoconf >= 2.62 can be assumed. | ||
174 | m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[ | ||
175 | AC_DEFUN([AC_C_RESTRICT], | ||
176 | [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], | ||
177 | [ac_cv_c_restrict=no | ||
178 | # The order here caters to the fact that C++ does not require restrict. | ||
179 | for ac_kw in __restrict __restrict__ _Restrict restrict; do | ||
180 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( | ||
181 | [[typedef int * int_ptr; | ||
182 | int foo (int_ptr $ac_kw ip) { | ||
183 | return ip[0]; | ||
184 | }]], | ||
185 | [[int s[1]; | ||
186 | int * $ac_kw t = s; | ||
187 | t[0] = 0; | ||
188 | return foo(t)]])], | ||
189 | [ac_cv_c_restrict=$ac_kw]) | ||
190 | test "$ac_cv_c_restrict" != no && break | ||
191 | done | ||
192 | ]) | ||
193 | AH_VERBATIM([restrict], | ||
194 | [/* Define to the equivalent of the C99 'restrict' keyword, or to | ||
195 | nothing if this is not supported. Do not define if restrict is | ||
196 | supported directly. */ | ||
197 | #undef restrict | ||
198 | /* Work around a bug in Sun C++: it does not support _Restrict, even | ||
199 | though the corresponding Sun C compiler does, which causes | ||
200 | "#define restrict _Restrict" in the previous line. Perhaps some future | ||
201 | version of Sun C++ will work with _Restrict; if so, it'll probably | ||
202 | define __RESTRICT, just as Sun C does. */ | ||
203 | #if defined __SUNPRO_CC && !defined __RESTRICT | ||
204 | # define _Restrict | ||
205 | #endif]) | ||
206 | case $ac_cv_c_restrict in | ||
207 | restrict) ;; | ||
208 | no) AC_DEFINE([restrict], []) ;; | ||
209 | *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; | ||
210 | esac | ||
211 | ]) | ||
212 | ]) | ||
213 | |||
214 | # gl_BIGENDIAN | ||
215 | # is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd. | ||
216 | # Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some | ||
217 | # macros invoke AC_C_BIGENDIAN with arguments. | ||
218 | AC_DEFUN([gl_BIGENDIAN], | ||
219 | [ | ||
220 | AC_C_BIGENDIAN | ||
221 | ]) | ||
222 | |||
223 | # gl_CACHE_VAL_SILENT(cache-id, command-to-set-it) | ||
224 | # is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not | ||
225 | # output a spurious "(cached)" mark in the midst of other configure output. | ||
226 | # This macro should be used instead of AC_CACHE_VAL when it is not surrounded | ||
227 | # by an AC_MSG_CHECKING/AC_MSG_RESULT pair. | ||
228 | AC_DEFUN([gl_CACHE_VAL_SILENT], | ||
229 | [ | ||
230 | saved_as_echo_n="$as_echo_n" | ||
231 | as_echo_n=':' | ||
232 | AC_CACHE_VAL([$1], [$2]) | ||
233 | as_echo_n="$saved_as_echo_n" | ||
234 | ]) | ||
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 new file mode 100644 index 000000000..eea83a226 --- /dev/null +++ b/m4/gnulib-comp.m4 | |||
@@ -0,0 +1,219 @@ | |||
1 | # DO NOT EDIT! GENERATED AUTOMATICALLY! | ||
2 | # Copyright (C) 2002-2011 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # This file is free software, distributed under the terms of the GNU | ||
5 | # General Public License. As a special exception to the GNU General | ||
6 | # Public License, this file may be distributed as part of a program | ||
7 | # that contains a configuration script generated by Autoconf, under | ||
8 | # the same distribution terms as the rest of that program. | ||
9 | # | ||
10 | # Generated by gnulib-tool. | ||
11 | # | ||
12 | # This file represents the compiled summary of the specification in | ||
13 | # gnulib-cache.m4. It lists the computed macro invocations that need | ||
14 | # to be invoked from configure.ac. | ||
15 | # In projects that use version control, this file can be treated like | ||
16 | # other built files. | ||
17 | |||
18 | |||
19 | # This macro should be invoked from /home/nils/workspace/gnunet/configure.ac, in the section | ||
20 | # "Checks for programs", right after AC_PROG_CC, and certainly before | ||
21 | # any checks for libraries, header files, types and library functions. | ||
22 | AC_DEFUN([gl_EARLY], | ||
23 | [ | ||
24 | m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace | ||
25 | m4_pattern_allow([^gl_ES$])dnl a valid locale name | ||
26 | m4_pattern_allow([^gl_LIBOBJS$])dnl a variable | ||
27 | m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable | ||
28 | AC_REQUIRE([AC_PROG_RANLIB]) | ||
29 | # Code from module arg-nonnull: | ||
30 | # Code from module c++defs: | ||
31 | # Code from module extensions: | ||
32 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | ||
33 | # Code from module include_next: | ||
34 | # Code from module stddef: | ||
35 | # Code from module string: | ||
36 | # Code from module strtok_r: | ||
37 | # Code from module warn-on-use: | ||
38 | ]) | ||
39 | |||
40 | # This macro should be invoked from /home/nils/workspace/gnunet/configure.ac, in the section | ||
41 | # "Check for header files, types and library functions". | ||
42 | AC_DEFUN([gl_INIT], | ||
43 | [ | ||
44 | AM_CONDITIONAL([GL_COND_LIBTOOL], [true]) | ||
45 | gl_cond_libtool=true | ||
46 | gl_m4_base='m4' | ||
47 | m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ])) | ||
48 | m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS])) | ||
49 | m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) | ||
50 | m4_pushdef([gl_LIBSOURCES_LIST], []) | ||
51 | m4_pushdef([gl_LIBSOURCES_DIR], []) | ||
52 | gl_COMMON | ||
53 | gl_source_base='src/util/libgnu' | ||
54 | # Code from module arg-nonnull: | ||
55 | # Code from module c++defs: | ||
56 | # Code from module extensions: | ||
57 | # Code from module include_next: | ||
58 | # Code from module stddef: | ||
59 | gl_STDDEF_H | ||
60 | # Code from module string: | ||
61 | gl_HEADER_STRING_H | ||
62 | # Code from module strtok_r: | ||
63 | gl_FUNC_STRTOK_R | ||
64 | gl_STRING_MODULE_INDICATOR([strtok_r]) | ||
65 | # Code from module warn-on-use: | ||
66 | # Code from module dummy: | ||
67 | # End of code from modules | ||
68 | m4_ifval(gl_LIBSOURCES_LIST, [ | ||
69 | m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || | ||
70 | for gl_file in ]gl_LIBSOURCES_LIST[ ; do | ||
71 | if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then | ||
72 | echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2 | ||
73 | exit 1 | ||
74 | fi | ||
75 | done])dnl | ||
76 | m4_if(m4_sysval, [0], [], | ||
77 | [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) | ||
78 | ]) | ||
79 | m4_popdef([gl_LIBSOURCES_DIR]) | ||
80 | m4_popdef([gl_LIBSOURCES_LIST]) | ||
81 | m4_popdef([AC_LIBSOURCES]) | ||
82 | m4_popdef([AC_REPLACE_FUNCS]) | ||
83 | m4_popdef([AC_LIBOBJ]) | ||
84 | AC_CONFIG_COMMANDS_PRE([ | ||
85 | gl_libobjs= | ||
86 | gl_ltlibobjs= | ||
87 | if test -n "$gl_LIBOBJS"; then | ||
88 | # Remove the extension. | ||
89 | sed_drop_objext='s/\.o$//;s/\.obj$//' | ||
90 | for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do | ||
91 | gl_libobjs="$gl_libobjs $i.$ac_objext" | ||
92 | gl_ltlibobjs="$gl_ltlibobjs $i.lo" | ||
93 | done | ||
94 | fi | ||
95 | AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) | ||
96 | AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) | ||
97 | ]) | ||
98 | gltests_libdeps= | ||
99 | gltests_ltlibdeps= | ||
100 | m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ])) | ||
101 | m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS])) | ||
102 | m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) | ||
103 | m4_pushdef([gltests_LIBSOURCES_LIST], []) | ||
104 | m4_pushdef([gltests_LIBSOURCES_DIR], []) | ||
105 | gl_COMMON | ||
106 | gl_source_base='tests' | ||
107 | changequote(,)dnl | ||
108 | gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS | ||
109 | changequote([, ])dnl | ||
110 | AC_SUBST([gltests_WITNESS]) | ||
111 | gl_module_indicator_condition=$gltests_WITNESS | ||
112 | m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition]) | ||
113 | m4_popdef([gl_MODULE_INDICATOR_CONDITION]) | ||
114 | m4_ifval(gltests_LIBSOURCES_LIST, [ | ||
115 | m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ || | ||
116 | for gl_file in ]gltests_LIBSOURCES_LIST[ ; do | ||
117 | if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then | ||
118 | echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2 | ||
119 | exit 1 | ||
120 | fi | ||
121 | done])dnl | ||
122 | m4_if(m4_sysval, [0], [], | ||
123 | [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) | ||
124 | ]) | ||
125 | m4_popdef([gltests_LIBSOURCES_DIR]) | ||
126 | m4_popdef([gltests_LIBSOURCES_LIST]) | ||
127 | m4_popdef([AC_LIBSOURCES]) | ||
128 | m4_popdef([AC_REPLACE_FUNCS]) | ||
129 | m4_popdef([AC_LIBOBJ]) | ||
130 | AC_CONFIG_COMMANDS_PRE([ | ||
131 | gltests_libobjs= | ||
132 | gltests_ltlibobjs= | ||
133 | if test -n "$gltests_LIBOBJS"; then | ||
134 | # Remove the extension. | ||
135 | sed_drop_objext='s/\.o$//;s/\.obj$//' | ||
136 | for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do | ||
137 | gltests_libobjs="$gltests_libobjs $i.$ac_objext" | ||
138 | gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" | ||
139 | done | ||
140 | fi | ||
141 | AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) | ||
142 | AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) | ||
143 | ]) | ||
144 | ]) | ||
145 | |||
146 | # Like AC_LIBOBJ, except that the module name goes | ||
147 | # into gl_LIBOBJS instead of into LIBOBJS. | ||
148 | AC_DEFUN([gl_LIBOBJ], [ | ||
149 | AS_LITERAL_IF([$1], [gl_LIBSOURCES([$1.c])])dnl | ||
150 | gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext" | ||
151 | ]) | ||
152 | |||
153 | # Like AC_REPLACE_FUNCS, except that the module name goes | ||
154 | # into gl_LIBOBJS instead of into LIBOBJS. | ||
155 | AC_DEFUN([gl_REPLACE_FUNCS], [ | ||
156 | m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl | ||
157 | AC_CHECK_FUNCS([$1], , [gl_LIBOBJ($ac_func)]) | ||
158 | ]) | ||
159 | |||
160 | # Like AC_LIBSOURCES, except the directory where the source file is | ||
161 | # expected is derived from the gnulib-tool parameterization, | ||
162 | # and alloca is special cased (for the alloca-opt module). | ||
163 | # We could also entirely rely on EXTRA_lib..._SOURCES. | ||
164 | AC_DEFUN([gl_LIBSOURCES], [ | ||
165 | m4_foreach([_gl_NAME], [$1], [ | ||
166 | m4_if(_gl_NAME, [alloca.c], [], [ | ||
167 | m4_define([gl_LIBSOURCES_DIR], [src/util/libgnu]) | ||
168 | m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ]) | ||
169 | ]) | ||
170 | ]) | ||
171 | ]) | ||
172 | |||
173 | # Like AC_LIBOBJ, except that the module name goes | ||
174 | # into gltests_LIBOBJS instead of into LIBOBJS. | ||
175 | AC_DEFUN([gltests_LIBOBJ], [ | ||
176 | AS_LITERAL_IF([$1], [gltests_LIBSOURCES([$1.c])])dnl | ||
177 | gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext" | ||
178 | ]) | ||
179 | |||
180 | # Like AC_REPLACE_FUNCS, except that the module name goes | ||
181 | # into gltests_LIBOBJS instead of into LIBOBJS. | ||
182 | AC_DEFUN([gltests_REPLACE_FUNCS], [ | ||
183 | m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl | ||
184 | AC_CHECK_FUNCS([$1], , [gltests_LIBOBJ($ac_func)]) | ||
185 | ]) | ||
186 | |||
187 | # Like AC_LIBSOURCES, except the directory where the source file is | ||
188 | # expected is derived from the gnulib-tool parameterization, | ||
189 | # and alloca is special cased (for the alloca-opt module). | ||
190 | # We could also entirely rely on EXTRA_lib..._SOURCES. | ||
191 | AC_DEFUN([gltests_LIBSOURCES], [ | ||
192 | m4_foreach([_gl_NAME], [$1], [ | ||
193 | m4_if(_gl_NAME, [alloca.c], [], [ | ||
194 | m4_define([gltests_LIBSOURCES_DIR], [tests]) | ||
195 | m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ]) | ||
196 | ]) | ||
197 | ]) | ||
198 | ]) | ||
199 | |||
200 | # This macro records the list of files which have been installed by | ||
201 | # gnulib-tool and may be removed by future gnulib-tool invocations. | ||
202 | AC_DEFUN([gl_FILE_LIST], [ | ||
203 | build-aux/arg-nonnull.h | ||
204 | build-aux/c++defs.h | ||
205 | build-aux/warn-on-use.h | ||
206 | lib/dummy.c | ||
207 | lib/stddef.in.h | ||
208 | lib/string.in.h | ||
209 | lib/strtok_r.c | ||
210 | m4/00gnulib.m4 | ||
211 | m4/extensions.m4 | ||
212 | m4/gnulib-common.m4 | ||
213 | m4/include_next.m4 | ||
214 | m4/stddef_h.m4 | ||
215 | m4/string_h.m4 | ||
216 | m4/strtok_r.m4 | ||
217 | m4/warn-on-use.m4 | ||
218 | m4/wchar_t.m4 | ||
219 | ]) | ||
diff --git a/m4/gnulib-tool.m4 b/m4/gnulib-tool.m4 new file mode 100644 index 000000000..ed41e9d41 --- /dev/null +++ b/m4/gnulib-tool.m4 | |||
@@ -0,0 +1,57 @@ | |||
1 | # gnulib-tool.m4 serial 2 | ||
2 | dnl Copyright (C) 2004-2005, 2009-2011 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | dnl The following macros need not be invoked explicitly. | ||
8 | dnl Invoking them does nothing except to declare default arguments | ||
9 | dnl for "gnulib-tool --import". | ||
10 | |||
11 | dnl Usage: gl_LOCAL_DIR([DIR]) | ||
12 | AC_DEFUN([gl_LOCAL_DIR], []) | ||
13 | |||
14 | dnl Usage: gl_MODULES([module1 module2 ...]) | ||
15 | AC_DEFUN([gl_MODULES], []) | ||
16 | |||
17 | dnl Usage: gl_AVOID([module1 module2 ...]) | ||
18 | AC_DEFUN([gl_AVOID], []) | ||
19 | |||
20 | dnl Usage: gl_SOURCE_BASE([DIR]) | ||
21 | AC_DEFUN([gl_SOURCE_BASE], []) | ||
22 | |||
23 | dnl Usage: gl_M4_BASE([DIR]) | ||
24 | AC_DEFUN([gl_M4_BASE], []) | ||
25 | |||
26 | dnl Usage: gl_PO_BASE([DIR]) | ||
27 | AC_DEFUN([gl_PO_BASE], []) | ||
28 | |||
29 | dnl Usage: gl_DOC_BASE([DIR]) | ||
30 | AC_DEFUN([gl_DOC_BASE], []) | ||
31 | |||
32 | dnl Usage: gl_TESTS_BASE([DIR]) | ||
33 | AC_DEFUN([gl_TESTS_BASE], []) | ||
34 | |||
35 | dnl Usage: gl_WITH_TESTS | ||
36 | AC_DEFUN([gl_WITH_TESTS], []) | ||
37 | |||
38 | dnl Usage: gl_LIB([LIBNAME]) | ||
39 | AC_DEFUN([gl_LIB], []) | ||
40 | |||
41 | dnl Usage: gl_LGPL or gl_LGPL([VERSION]) | ||
42 | AC_DEFUN([gl_LGPL], []) | ||
43 | |||
44 | dnl Usage: gl_MAKEFILE_NAME([FILENAME]) | ||
45 | AC_DEFUN([gl_MAKEFILE_NAME], []) | ||
46 | |||
47 | dnl Usage: gl_LIBTOOL | ||
48 | AC_DEFUN([gl_LIBTOOL], []) | ||
49 | |||
50 | dnl Usage: gl_MACRO_PREFIX([PREFIX]) | ||
51 | AC_DEFUN([gl_MACRO_PREFIX], []) | ||
52 | |||
53 | dnl Usage: gl_PO_DOMAIN([DOMAIN]) | ||
54 | AC_DEFUN([gl_PO_DOMAIN], []) | ||
55 | |||
56 | dnl Usage: gl_VC_FILES([BOOLEAN]) | ||
57 | AC_DEFUN([gl_VC_FILES], []) | ||
diff --git a/m4/include_next.m4 b/m4/include_next.m4 new file mode 100644 index 000000000..b3c784918 --- /dev/null +++ b/m4/include_next.m4 | |||
@@ -0,0 +1,244 @@ | |||
1 | # include_next.m4 serial 18 | ||
2 | dnl Copyright (C) 2006-2011 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | dnl From Paul Eggert and Derek Price. | ||
8 | |||
9 | dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER. | ||
10 | dnl | ||
11 | dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to | ||
12 | dnl 'include' otherwise. | ||
13 | dnl | ||
14 | dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler | ||
15 | dnl supports it in the special case that it is the first include directive in | ||
16 | dnl the given file, or to 'include' otherwise. | ||
17 | dnl | ||
18 | dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next, | ||
19 | dnl so as to avoid GCC warnings when the gcc option -pedantic is used. | ||
20 | dnl '#pragma GCC system_header' has the same effect as if the file was found | ||
21 | dnl through the include search path specified with '-isystem' options (as | ||
22 | dnl opposed to the search path specified with '-I' options). Namely, gcc | ||
23 | dnl does not warn about some things, and on some systems (Solaris and Interix) | ||
24 | dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side | ||
25 | dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead | ||
26 | dnl of plain '__STDC__'. | ||
27 | dnl | ||
28 | dnl PRAGMA_COLUMNS can be used in files that override system header files, so | ||
29 | dnl as to avoid compilation errors on HP NonStop systems when the gnulib file | ||
30 | dnl is included by a system header file that does a "#pragma COLUMNS 80" (which | ||
31 | dnl has the effect of truncating the lines of that file and all files that it | ||
32 | dnl includes to 80 columns) and the gnulib file has lines longer than 80 | ||
33 | dnl columns. | ||
34 | |||
35 | AC_DEFUN([gl_INCLUDE_NEXT], | ||
36 | [ | ||
37 | AC_LANG_PREPROC_REQUIRE() | ||
38 | AC_CACHE_CHECK([whether the preprocessor supports include_next], | ||
39 | [gl_cv_have_include_next], | ||
40 | [rm -rf conftestd1a conftestd1b conftestd2 | ||
41 | mkdir conftestd1a conftestd1b conftestd2 | ||
42 | dnl IBM C 9.0, 10.1 (original versions, prior to the 2009-01 updates) on | ||
43 | dnl AIX 6.1 support include_next when used as first preprocessor directive | ||
44 | dnl in a file, but not when preceded by another include directive. Check | ||
45 | dnl for this bug by including <stdio.h>. | ||
46 | dnl Additionally, with this same compiler, include_next is a no-op when | ||
47 | dnl used in a header file that was included by specifying its absolute | ||
48 | dnl file name. Despite these two bugs, include_next is used in the | ||
49 | dnl compiler's <math.h>. By virtue of the second bug, we need to use | ||
50 | dnl include_next as well in this case. | ||
51 | cat <<EOF > conftestd1a/conftest.h | ||
52 | #define DEFINED_IN_CONFTESTD1 | ||
53 | #include_next <conftest.h> | ||
54 | #ifdef DEFINED_IN_CONFTESTD2 | ||
55 | int foo; | ||
56 | #else | ||
57 | #error "include_next doesn't work" | ||
58 | #endif | ||
59 | EOF | ||
60 | cat <<EOF > conftestd1b/conftest.h | ||
61 | #define DEFINED_IN_CONFTESTD1 | ||
62 | #include <stdio.h> | ||
63 | #include_next <conftest.h> | ||
64 | #ifdef DEFINED_IN_CONFTESTD2 | ||
65 | int foo; | ||
66 | #else | ||
67 | #error "include_next doesn't work" | ||
68 | #endif | ||
69 | EOF | ||
70 | cat <<EOF > conftestd2/conftest.h | ||
71 | #ifndef DEFINED_IN_CONFTESTD1 | ||
72 | #error "include_next test doesn't work" | ||
73 | #endif | ||
74 | #define DEFINED_IN_CONFTESTD2 | ||
75 | EOF | ||
76 | gl_save_CPPFLAGS="$CPPFLAGS" | ||
77 | CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" | ||
78 | dnl We intentionally avoid using AC_LANG_SOURCE here. | ||
79 | AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]], | ||
80 | [gl_cv_have_include_next=yes], | ||
81 | [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" | ||
82 | AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]], | ||
83 | [gl_cv_have_include_next=buggy], | ||
84 | [gl_cv_have_include_next=no]) | ||
85 | ]) | ||
86 | CPPFLAGS="$gl_save_CPPFLAGS" | ||
87 | rm -rf conftestd1a conftestd1b conftestd2 | ||
88 | ]) | ||
89 | PRAGMA_SYSTEM_HEADER= | ||
90 | if test $gl_cv_have_include_next = yes; then | ||
91 | INCLUDE_NEXT=include_next | ||
92 | INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next | ||
93 | if test -n "$GCC"; then | ||
94 | PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' | ||
95 | fi | ||
96 | else | ||
97 | if test $gl_cv_have_include_next = buggy; then | ||
98 | INCLUDE_NEXT=include | ||
99 | INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next | ||
100 | else | ||
101 | INCLUDE_NEXT=include | ||
102 | INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include | ||
103 | fi | ||
104 | fi | ||
105 | AC_SUBST([INCLUDE_NEXT]) | ||
106 | AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) | ||
107 | AC_SUBST([PRAGMA_SYSTEM_HEADER]) | ||
108 | AC_CACHE_CHECK([whether system header files limit the line length], | ||
109 | [gl_cv_pragma_columns], | ||
110 | [dnl HP NonStop systems, which define __TANDEM, have this misfeature. | ||
111 | AC_EGREP_CPP([choke me], | ||
112 | [ | ||
113 | #ifdef __TANDEM | ||
114 | choke me | ||
115 | #endif | ||
116 | ], | ||
117 | [gl_cv_pragma_columns=yes], | ||
118 | [gl_cv_pragma_columns=no]) | ||
119 | ]) | ||
120 | if test $gl_cv_pragma_columns = yes; then | ||
121 | PRAGMA_COLUMNS="#pragma COLUMNS 10000" | ||
122 | else | ||
123 | PRAGMA_COLUMNS= | ||
124 | fi | ||
125 | AC_SUBST([PRAGMA_COLUMNS]) | ||
126 | ]) | ||
127 | |||
128 | # gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) | ||
129 | # ------------------------------------------ | ||
130 | # For each arg foo.h, if #include_next works, define NEXT_FOO_H to be | ||
131 | # '<foo.h>'; otherwise define it to be | ||
132 | # '"///usr/include/foo.h"', or whatever other absolute file name is suitable. | ||
133 | # Also, if #include_next works as first preprocessing directive in a file, | ||
134 | # define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be '<foo.h>'; otherwise define it to | ||
135 | # be | ||
136 | # '"///usr/include/foo.h"', or whatever other absolute file name is suitable. | ||
137 | # That way, a header file with the following line: | ||
138 | # #@INCLUDE_NEXT@ @NEXT_FOO_H@ | ||
139 | # or | ||
140 | # #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@ | ||
141 | # behaves (after sed substitution) as if it contained | ||
142 | # #include_next <foo.h> | ||
143 | # even if the compiler does not support include_next. | ||
144 | # The three "///" are to pacify Sun C 5.8, which otherwise would say | ||
145 | # "warning: #include of /usr/include/... may be non-portable". | ||
146 | # Use `""', not `<>', so that the /// cannot be confused with a C99 comment. | ||
147 | # Note: This macro assumes that the header file is not empty after | ||
148 | # preprocessing, i.e. it does not only define preprocessor macros but also | ||
149 | # provides some type/enum definitions or function/variable declarations. | ||
150 | # | ||
151 | # This macro also checks whether each header exists, by invoking | ||
152 | # AC_CHECK_HEADERS_ONCE or AC_CHECK_HEADERS on each argument. | ||
153 | AC_DEFUN([gl_CHECK_NEXT_HEADERS], | ||
154 | [ | ||
155 | gl_NEXT_HEADERS_INTERNAL([$1], [check]) | ||
156 | ]) | ||
157 | |||
158 | # gl_NEXT_HEADERS(HEADER1 HEADER2 ...) | ||
159 | # ------------------------------------ | ||
160 | # Like gl_CHECK_NEXT_HEADERS, except do not check whether the headers exist. | ||
161 | # This is suitable for headers like <stddef.h> that are standardized by C89 | ||
162 | # and therefore can be assumed to exist. | ||
163 | AC_DEFUN([gl_NEXT_HEADERS], | ||
164 | [ | ||
165 | gl_NEXT_HEADERS_INTERNAL([$1], [assume]) | ||
166 | ]) | ||
167 | |||
168 | # The guts of gl_CHECK_NEXT_HEADERS and gl_NEXT_HEADERS. | ||
169 | AC_DEFUN([gl_NEXT_HEADERS_INTERNAL], | ||
170 | [ | ||
171 | AC_REQUIRE([gl_INCLUDE_NEXT]) | ||
172 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
173 | |||
174 | m4_if([$2], [check], | ||
175 | [AC_CHECK_HEADERS_ONCE([$1]) | ||
176 | ]) | ||
177 | |||
178 | m4_foreach_w([gl_HEADER_NAME], [$1], | ||
179 | [AS_VAR_PUSHDEF([gl_next_header], | ||
180 | [gl_cv_next_]m4_defn([gl_HEADER_NAME])) | ||
181 | if test $gl_cv_have_include_next = yes; then | ||
182 | AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) | ||
183 | else | ||
184 | AC_CACHE_CHECK( | ||
185 | [absolute name of <]m4_defn([gl_HEADER_NAME])[>], | ||
186 | m4_defn([gl_next_header]), | ||
187 | [m4_if([$2], [check], | ||
188 | [AS_VAR_PUSHDEF([gl_header_exists], | ||
189 | [ac_cv_header_]m4_defn([gl_HEADER_NAME])) | ||
190 | if test AS_VAR_GET(gl_header_exists) = yes; then | ||
191 | AS_VAR_POPDEF([gl_header_exists]) | ||
192 | ]) | ||
193 | AC_LANG_CONFTEST( | ||
194 | [AC_LANG_SOURCE( | ||
195 | [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] | ||
196 | )]) | ||
197 | dnl AIX "xlc -E" and "cc -E" omit #line directives for header | ||
198 | dnl files that contain only a #include of other header files and | ||
199 | dnl no non-comment tokens of their own. This leads to a failure | ||
200 | dnl to detect the absolute name of <dirent.h>, <signal.h>, | ||
201 | dnl <poll.h> and others. The workaround is to force preservation | ||
202 | dnl of comments through option -C. This ensures all necessary | ||
203 | dnl #line directives are present. GCC supports option -C as well. | ||
204 | case "$host_os" in | ||
205 | aix*) gl_absname_cpp="$ac_cpp -C" ;; | ||
206 | *) gl_absname_cpp="$ac_cpp" ;; | ||
207 | esac | ||
208 | dnl eval is necessary to expand gl_absname_cpp. | ||
209 | dnl Ultrix and Pyramid sh refuse to redirect output of eval, | ||
210 | dnl so use subshell. | ||
211 | AS_VAR_SET([gl_next_header], | ||
212 | ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | | ||
213 | sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{ | ||
214 | s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1# | ||
215 | s#^/[^/]#//&# | ||
216 | p | ||
217 | q | ||
218 | }'`'"']) | ||
219 | m4_if([$2], [check], | ||
220 | [else | ||
221 | AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) | ||
222 | fi | ||
223 | ]) | ||
224 | ]) | ||
225 | fi | ||
226 | AC_SUBST( | ||
227 | AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), | ||
228 | [AS_VAR_GET([gl_next_header])]) | ||
229 | if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then | ||
230 | # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' | ||
231 | gl_next_as_first_directive='<'gl_HEADER_NAME'>' | ||
232 | else | ||
233 | # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' | ||
234 | gl_next_as_first_directive=AS_VAR_GET([gl_next_header]) | ||
235 | fi | ||
236 | AC_SUBST( | ||
237 | AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), | ||
238 | [$gl_next_as_first_directive]) | ||
239 | AS_VAR_POPDEF([gl_next_header])]) | ||
240 | ]) | ||
241 | |||
242 | # Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE; | ||
243 | # this fallback is safe for all earlier autoconf versions. | ||
244 | m4_define_default([AC_LANG_DEFINES_PROVIDED]) | ||
diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4 new file mode 100644 index 000000000..1942b6aa0 --- /dev/null +++ b/m4/stddef_h.m4 | |||
@@ -0,0 +1,45 @@ | |||
1 | dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues. | ||
2 | # stddef_h.m4 serial 3 | ||
3 | dnl Copyright (C) 2009-2011 Free Software Foundation, Inc. | ||
4 | dnl This file is free software; the Free Software Foundation | ||
5 | dnl gives unlimited permission to copy and/or distribute it, | ||
6 | dnl with or without modifications, as long as this notice is preserved. | ||
7 | |||
8 | AC_DEFUN([gl_STDDEF_H], | ||
9 | [ | ||
10 | AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) | ||
11 | AC_REQUIRE([gt_TYPE_WCHAR_T]) | ||
12 | if test $gt_cv_c_wchar_t = no; then | ||
13 | HAVE_WCHAR_T=0 | ||
14 | STDDEF_H=stddef.h | ||
15 | fi | ||
16 | AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], | ||
17 | [gl_cv_decl_null_works], | ||
18 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h> | ||
19 | int test[2 * (sizeof NULL == sizeof (void *)) -1]; | ||
20 | ]])], | ||
21 | [gl_cv_decl_null_works=yes], | ||
22 | [gl_cv_decl_null_works=no])]) | ||
23 | if test $gl_cv_decl_null_works = no; then | ||
24 | REPLACE_NULL=1 | ||
25 | STDDEF_H=stddef.h | ||
26 | fi | ||
27 | if test -n "$STDDEF_H"; then | ||
28 | gl_NEXT_HEADERS([stddef.h]) | ||
29 | fi | ||
30 | ]) | ||
31 | |||
32 | AC_DEFUN([gl_STDDEF_MODULE_INDICATOR], | ||
33 | [ | ||
34 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. | ||
35 | AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) | ||
36 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) | ||
37 | ]) | ||
38 | |||
39 | AC_DEFUN([gl_STDDEF_H_DEFAULTS], | ||
40 | [ | ||
41 | dnl Assume proper GNU behavior unless another module says otherwise. | ||
42 | REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) | ||
43 | HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T]) | ||
44 | STDDEF_H=''; AC_SUBST([STDDEF_H]) | ||
45 | ]) | ||
diff --git a/m4/string_h.m4 b/m4/string_h.m4 new file mode 100644 index 000000000..30ddfbc3a --- /dev/null +++ b/m4/string_h.m4 | |||
@@ -0,0 +1,115 @@ | |||
1 | # Configure a GNU-like replacement for <string.h>. | ||
2 | |||
3 | # Copyright (C) 2007-2011 Free Software Foundation, Inc. | ||
4 | # This file is free software; the Free Software Foundation | ||
5 | # gives unlimited permission to copy and/or distribute it, | ||
6 | # with or without modifications, as long as this notice is preserved. | ||
7 | |||
8 | # serial 19 | ||
9 | |||
10 | # Written by Paul Eggert. | ||
11 | |||
12 | AC_DEFUN([gl_HEADER_STRING_H], | ||
13 | [ | ||
14 | dnl Use AC_REQUIRE here, so that the default behavior below is expanded | ||
15 | dnl once only, before all statements that occur in other macros. | ||
16 | AC_REQUIRE([gl_HEADER_STRING_H_BODY]) | ||
17 | ]) | ||
18 | |||
19 | AC_DEFUN([gl_HEADER_STRING_H_BODY], | ||
20 | [ | ||
21 | AC_REQUIRE([AC_C_RESTRICT]) | ||
22 | AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) | ||
23 | gl_NEXT_HEADERS([string.h]) | ||
24 | |||
25 | dnl Check for declarations of anything we want to poison if the | ||
26 | dnl corresponding gnulib module is not in use, and which is not | ||
27 | dnl guaranteed by C89. | ||
28 | gl_WARN_ON_USE_PREPARE([[#include <string.h> | ||
29 | ]], | ||
30 | [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup | ||
31 | strncat strndup strnlen strpbrk strsep strcasestr strtok_r strerror_r | ||
32 | strsignal strverscmp]) | ||
33 | ]) | ||
34 | |||
35 | AC_DEFUN([gl_STRING_MODULE_INDICATOR], | ||
36 | [ | ||
37 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. | ||
38 | AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) | ||
39 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) | ||
40 | dnl Define it also as a C macro, for the benefit of the unit tests. | ||
41 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) | ||
42 | ]) | ||
43 | |||
44 | AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], | ||
45 | [ | ||
46 | GNULIB_MEMCHR=0; AC_SUBST([GNULIB_MEMCHR]) | ||
47 | GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM]) | ||
48 | GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY]) | ||
49 | GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR]) | ||
50 | GNULIB_RAWMEMCHR=0; AC_SUBST([GNULIB_RAWMEMCHR]) | ||
51 | GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY]) | ||
52 | GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY]) | ||
53 | GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL]) | ||
54 | GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP]) | ||
55 | GNULIB_STRNCAT=0; AC_SUBST([GNULIB_STRNCAT]) | ||
56 | GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP]) | ||
57 | GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN]) | ||
58 | GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK]) | ||
59 | GNULIB_STRSEP=0; AC_SUBST([GNULIB_STRSEP]) | ||
60 | GNULIB_STRSTR=0; AC_SUBST([GNULIB_STRSTR]) | ||
61 | GNULIB_STRCASESTR=0; AC_SUBST([GNULIB_STRCASESTR]) | ||
62 | GNULIB_STRTOK_R=0; AC_SUBST([GNULIB_STRTOK_R]) | ||
63 | GNULIB_MBSLEN=0; AC_SUBST([GNULIB_MBSLEN]) | ||
64 | GNULIB_MBSNLEN=0; AC_SUBST([GNULIB_MBSNLEN]) | ||
65 | GNULIB_MBSCHR=0; AC_SUBST([GNULIB_MBSCHR]) | ||
66 | GNULIB_MBSRCHR=0; AC_SUBST([GNULIB_MBSRCHR]) | ||
67 | GNULIB_MBSSTR=0; AC_SUBST([GNULIB_MBSSTR]) | ||
68 | GNULIB_MBSCASECMP=0; AC_SUBST([GNULIB_MBSCASECMP]) | ||
69 | GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP]) | ||
70 | GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP]) | ||
71 | GNULIB_MBSCASESTR=0; AC_SUBST([GNULIB_MBSCASESTR]) | ||
72 | GNULIB_MBSCSPN=0; AC_SUBST([GNULIB_MBSCSPN]) | ||
73 | GNULIB_MBSPBRK=0; AC_SUBST([GNULIB_MBSPBRK]) | ||
74 | GNULIB_MBSSPN=0; AC_SUBST([GNULIB_MBSSPN]) | ||
75 | GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP]) | ||
76 | GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R]) | ||
77 | GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR]) | ||
78 | GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R]) | ||
79 | GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL]) | ||
80 | GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP]) | ||
81 | HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN]) | ||
82 | dnl Assume proper GNU behavior unless another module says otherwise. | ||
83 | HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR]) | ||
84 | HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) | ||
85 | HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) | ||
86 | HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) | ||
87 | HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR]) | ||
88 | HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) | ||
89 | HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY]) | ||
90 | HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL]) | ||
91 | HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP]) | ||
92 | HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP]) | ||
93 | HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN]) | ||
94 | HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK]) | ||
95 | HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP]) | ||
96 | HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) | ||
97 | HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) | ||
98 | HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R]) | ||
99 | HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) | ||
100 | HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP]) | ||
101 | REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) | ||
102 | REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) | ||
103 | REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY]) | ||
104 | REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) | ||
105 | REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) | ||
106 | REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) | ||
107 | REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) | ||
108 | REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R]) | ||
109 | REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) | ||
110 | REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) | ||
111 | REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN]) | ||
112 | REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) | ||
113 | REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R]) | ||
114 | UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) | ||
115 | ]) | ||
diff --git a/m4/strtok_r.m4 b/m4/strtok_r.m4 new file mode 100644 index 000000000..3f8a26fe7 --- /dev/null +++ b/m4/strtok_r.m4 | |||
@@ -0,0 +1,74 @@ | |||
1 | # strtok_r.m4 serial 12 | ||
2 | dnl Copyright (C) 2002-2004, 2006-2007, 2009-2011 Free Software Foundation, | ||
3 | dnl Inc. | ||
4 | dnl This file is free software; the Free Software Foundation | ||
5 | dnl gives unlimited permission to copy and/or distribute it, | ||
6 | dnl with or without modifications, as long as this notice is preserved. | ||
7 | |||
8 | AC_DEFUN([gl_FUNC_STRTOK_R], | ||
9 | [ | ||
10 | dnl The strtok_r() declaration in lib/string.in.h uses 'restrict'. | ||
11 | AC_REQUIRE([AC_C_RESTRICT]) | ||
12 | |||
13 | AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) | ||
14 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | ||
15 | AC_CHECK_FUNCS([strtok_r]) | ||
16 | if test $ac_cv_func_strtok_r = yes; then | ||
17 | dnl glibc 2.7 has a bug in strtok_r that causes a segmentation fault | ||
18 | dnl when the second argument to strtok_r is a constant string that has | ||
19 | dnl exactly one byte and compiling with optimization. This bug is, for | ||
20 | dnl example, present in the glibc 2.7-18 package in Debian "lenny". | ||
21 | dnl See <http://sources.redhat.com/bugzilla/show_bug.cgi?id=5614>. | ||
22 | AC_CACHE_CHECK([whether strtok_r works], [gl_cv_func_strtok_r_works], | ||
23 | [AC_RUN_IFELSE( | ||
24 | [AC_LANG_PROGRAM([[ | ||
25 | #ifndef __OPTIMIZE__ | ||
26 | # define __OPTIMIZE__ 1 | ||
27 | #endif | ||
28 | #undef __OPTIMIZE_SIZE__ | ||
29 | #undef __NO_INLINE__ | ||
30 | #include <stdlib.h> | ||
31 | #include <string.h> | ||
32 | ]], | ||
33 | [[static const char dummy[] = "\177\01a"; | ||
34 | char delimiters[] = "xxxxxxxx"; | ||
35 | char *save_ptr = (char *) dummy; | ||
36 | strtok_r (delimiters, "x", &save_ptr); | ||
37 | strtok_r (NULL, "x", &save_ptr); | ||
38 | return 0; | ||
39 | ]]) | ||
40 | ], | ||
41 | [gl_cv_func_strtok_r_works=yes], | ||
42 | [gl_cv_func_strtok_r_works=no], | ||
43 | [ | ||
44 | changequote(,)dnl | ||
45 | case "$host_os" in | ||
46 | # Guess no on glibc systems. | ||
47 | *-gnu*) gl_cv_func_strtok_r_works="guessing no";; | ||
48 | *) gl_cv_func_strtok_r_works="guessing yes";; | ||
49 | esac | ||
50 | changequote([,])dnl | ||
51 | ]) | ||
52 | ]) | ||
53 | case "$gl_cv_func_strtok_r_works" in | ||
54 | *no) | ||
55 | dnl We could set REPLACE_STRTOK_R=1 and AC_LIBOBJ([strtok_r]) here, | ||
56 | dnl but it's only the macro version in <bits/string2.h> which is wrong. | ||
57 | dnl The code compiled into libc is fine. | ||
58 | UNDEFINE_STRTOK_R=1 | ||
59 | ;; | ||
60 | esac | ||
61 | else | ||
62 | AC_LIBOBJ([strtok_r]) | ||
63 | gl_PREREQ_STRTOK_R | ||
64 | fi | ||
65 | AC_CHECK_DECLS_ONCE([strtok_r]) | ||
66 | if test $ac_cv_have_decl_strtok_r = no; then | ||
67 | HAVE_DECL_STRTOK_R=0 | ||
68 | fi | ||
69 | ]) | ||
70 | |||
71 | # Prerequisites of lib/strtok_r.c. | ||
72 | AC_DEFUN([gl_PREREQ_STRTOK_R], [ | ||
73 | : | ||
74 | ]) | ||
diff --git a/m4/warn-on-use.m4 b/m4/warn-on-use.m4 new file mode 100644 index 000000000..e0d0f2764 --- /dev/null +++ b/m4/warn-on-use.m4 | |||
@@ -0,0 +1,45 @@ | |||
1 | # warn-on-use.m4 serial 2 | ||
2 | dnl Copyright (C) 2010-2011 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | # gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES) | ||
8 | # --------------------------------------- | ||
9 | # For each whitespace-separated element in the list of NAMES, define | ||
10 | # HAVE_RAW_DECL_name if the function has a declaration among INCLUDES | ||
11 | # even after being undefined as a macro. | ||
12 | # | ||
13 | # See warn-on-use.h for some hints on how to poison function names, as | ||
14 | # well as ideas on poisoning global variables and macros. NAMES may | ||
15 | # include global variables, but remember that only functions work with | ||
16 | # _GL_WARN_ON_USE. Typically, INCLUDES only needs to list a single | ||
17 | # header, but if the replacement header pulls in other headers because | ||
18 | # some systems declare functions in the wrong header, then INCLUDES | ||
19 | # should do likewise. | ||
20 | # | ||
21 | # If you assume C89, then it is generally safe to assume declarations | ||
22 | # for functions declared in that standard (such as gets) without | ||
23 | # needing gl_WARN_ON_USE_PREPARE. | ||
24 | AC_DEFUN([gl_WARN_ON_USE_PREPARE], | ||
25 | [ | ||
26 | m4_foreach_w([gl_decl], [$2], | ||
27 | [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])), | ||
28 | [Define to 1 if ]m4_defn([gl_decl])[ is declared even after | ||
29 | undefining macros.])])dnl | ||
30 | for gl_func in m4_flatten([$2]); do | ||
31 | AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl | ||
32 | AC_CACHE_CHECK([whether $gl_func is declared without a macro], | ||
33 | gl_Symbol, | ||
34 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1], | ||
35 | [@%:@undef $gl_func | ||
36 | (void) $gl_func;])], | ||
37 | [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])]) | ||
38 | AS_VAR_IF(gl_Symbol, [yes], | ||
39 | [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) | ||
40 | dnl shortcut - if the raw declaration exists, then set a cache | ||
41 | dnl variable to allow skipping any later AC_CHECK_DECL efforts | ||
42 | eval ac_cv_have_decl_$gl_func=yes]) | ||
43 | AS_VAR_POPDEF([gl_Symbol])dnl | ||
44 | done | ||
45 | ]) | ||
diff --git a/m4/wchar_t.m4 b/m4/wchar_t.m4 index cde2129a9..d2c03c42d 100644 --- a/m4/wchar_t.m4 +++ b/m4/wchar_t.m4 | |||
@@ -1,5 +1,5 @@ | |||
1 | # wchar_t.m4 serial 1 (gettext-0.12) | 1 | # wchar_t.m4 serial 4 (gettext-0.18.2) |
2 | dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002-2003, 2008-2011 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
@@ -10,11 +10,15 @@ dnl Prerequisite: AC_PROG_CC | |||
10 | 10 | ||
11 | AC_DEFUN([gt_TYPE_WCHAR_T], | 11 | AC_DEFUN([gt_TYPE_WCHAR_T], |
12 | [ | 12 | [ |
13 | AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t, | 13 | AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], |
14 | [AC_TRY_COMPILE([#include <stddef.h> | 14 | [AC_COMPILE_IFELSE( |
15 | wchar_t foo = (wchar_t)'\0';], , | 15 | [AC_LANG_PROGRAM( |
16 | gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)]) | 16 | [[#include <stddef.h> |
17 | wchar_t foo = (wchar_t)'\0';]], | ||
18 | [[]])], | ||
19 | [gt_cv_c_wchar_t=yes], | ||
20 | [gt_cv_c_wchar_t=no])]) | ||
17 | if test $gt_cv_c_wchar_t = yes; then | 21 | if test $gt_cv_c_wchar_t = yes; then |
18 | AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.]) | 22 | AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.]) |
19 | fi | 23 | fi |
20 | ]) | 24 | ]) |
diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 01e7e3219..927f50f2b 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am | |||
@@ -1,6 +1,7 @@ | |||
1 | INCLUDES = -I$(top_srcdir)/src/include | 1 | INCLUDES = -I$(top_srcdir)/src/include |
2 | 2 | ||
3 | plugindir = $(libdir)/gnunet | 3 | plugindir = $(libdir)/gnunet |
4 | SUBDIRS = libgnu | ||
4 | 5 | ||
5 | if MINGW | 6 | if MINGW |
6 | noinst_LTLIBRARIES = \ | 7 | noinst_LTLIBRARIES = \ |
@@ -74,7 +75,8 @@ libgnunetutil_la_LIBADD = \ | |||
74 | $(GCLIBADD) $(WINLIB) \ | 75 | $(GCLIBADD) $(WINLIB) \ |
75 | $(LIBGCRYPT_LIBS) \ | 76 | $(LIBGCRYPT_LIBS) \ |
76 | $(LTLIBICONV) \ | 77 | $(LTLIBICONV) \ |
77 | -lltdl -lz $(XLIB) | 78 | -lltdl -lz $(XLIB) \ |
79 | libgnu/libgnu.la | ||
78 | 80 | ||
79 | libgnunetutil_la_LDFLAGS = \ | 81 | libgnunetutil_la_LDFLAGS = \ |
80 | $(GN_LIB_LDFLAGS) \ | 82 | $(GN_LIB_LDFLAGS) \ |
diff --git a/src/util/libgnu/Makefile.am b/src/util/libgnu/Makefile.am new file mode 100644 index 000000000..b0f704c61 --- /dev/null +++ b/src/util/libgnu/Makefile.am | |||
@@ -0,0 +1,248 @@ | |||
1 | ## DO NOT EDIT! GENERATED AUTOMATICALLY! | ||
2 | ## Process this file with automake to produce Makefile.in. | ||
3 | # Copyright (C) 2002-2011 Free Software Foundation, Inc. | ||
4 | # | ||
5 | # This file is free software, distributed under the terms of the GNU | ||
6 | # General Public License. As a special exception to the GNU General | ||
7 | # Public License, this file may be distributed as part of a program | ||
8 | # that contains a configuration script generated by Autoconf, under | ||
9 | # the same distribution terms as the rest of that program. | ||
10 | # | ||
11 | # Generated by gnulib-tool. | ||
12 | # Reproduce by: gnulib-tool --import --dir=/home/nils/workspace/gnunet --lib=libgnu --source-base=src/util/libgnu --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --libtool --macro-prefix=gl strtok_r | ||
13 | |||
14 | AUTOMAKE_OPTIONS = 1.5 gnits | ||
15 | |||
16 | SUBDIRS = | ||
17 | noinst_HEADERS = | ||
18 | noinst_LIBRARIES = | ||
19 | noinst_LTLIBRARIES = | ||
20 | EXTRA_DIST = | ||
21 | BUILT_SOURCES = | ||
22 | SUFFIXES = | ||
23 | MOSTLYCLEANFILES = core *.stackdump | ||
24 | MOSTLYCLEANDIRS = | ||
25 | CLEANFILES = | ||
26 | DISTCLEANFILES = | ||
27 | MAINTAINERCLEANFILES = | ||
28 | |||
29 | AM_CPPFLAGS = | ||
30 | AM_CFLAGS = | ||
31 | |||
32 | noinst_LTLIBRARIES += libgnu.la | ||
33 | |||
34 | libgnu_la_SOURCES = | ||
35 | libgnu_la_LIBADD = $(gl_LTLIBOBJS) | ||
36 | libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS) | ||
37 | EXTRA_libgnu_la_SOURCES = | ||
38 | libgnu_la_LDFLAGS = $(AM_LDFLAGS) | ||
39 | libgnu_la_LDFLAGS += -no-undefined | ||
40 | |||
41 | ## begin gnulib module arg-nonnull | ||
42 | |||
43 | # The BUILT_SOURCES created by this Makefile snippet are not used via #include | ||
44 | # statements but through direct file reference. Therefore this snippet must be | ||
45 | # present in all Makefile.am that need it. This is ensured by the applicability | ||
46 | # 'all' defined above. | ||
47 | |||
48 | BUILT_SOURCES += arg-nonnull.h | ||
49 | # The arg-nonnull.h that gets inserted into generated .h files is the same as | ||
50 | # build-aux/arg-nonnull.h, except that it has the copyright header cut off. | ||
51 | arg-nonnull.h: $(top_srcdir)/./arg-nonnull.h | ||
52 | $(AM_V_GEN)rm -f $@-t $@ && \ | ||
53 | sed -n -e '/GL_ARG_NONNULL/,$$p' \ | ||
54 | < $(top_srcdir)/./arg-nonnull.h \ | ||
55 | > $@-t && \ | ||
56 | mv $@-t $@ | ||
57 | MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t | ||
58 | |||
59 | ARG_NONNULL_H=arg-nonnull.h | ||
60 | |||
61 | EXTRA_DIST += $(top_srcdir)/./arg-nonnull.h | ||
62 | |||
63 | ## end gnulib module arg-nonnull | ||
64 | |||
65 | ## begin gnulib module c++defs | ||
66 | |||
67 | # The BUILT_SOURCES created by this Makefile snippet are not used via #include | ||
68 | # statements but through direct file reference. Therefore this snippet must be | ||
69 | # present in all Makefile.am that need it. This is ensured by the applicability | ||
70 | # 'all' defined above. | ||
71 | |||
72 | BUILT_SOURCES += c++defs.h | ||
73 | # The c++defs.h that gets inserted into generated .h files is the same as | ||
74 | # build-aux/c++defs.h, except that it has the copyright header cut off. | ||
75 | c++defs.h: $(top_srcdir)/./c++defs.h | ||
76 | $(AM_V_GEN)rm -f $@-t $@ && \ | ||
77 | sed -n -e '/_GL_CXXDEFS/,$$p' \ | ||
78 | < $(top_srcdir)/./c++defs.h \ | ||
79 | > $@-t && \ | ||
80 | mv $@-t $@ | ||
81 | MOSTLYCLEANFILES += c++defs.h c++defs.h-t | ||
82 | |||
83 | CXXDEFS_H=c++defs.h | ||
84 | |||
85 | EXTRA_DIST += $(top_srcdir)/./c++defs.h | ||
86 | |||
87 | ## end gnulib module c++defs | ||
88 | |||
89 | ## begin gnulib module stddef | ||
90 | |||
91 | BUILT_SOURCES += $(STDDEF_H) | ||
92 | |||
93 | # We need the following in order to create <stddef.h> when the system | ||
94 | # doesn't have one that works with the given compiler. | ||
95 | stddef.h: stddef.in.h | ||
96 | $(AM_V_GEN)rm -f $@-t $@ && \ | ||
97 | { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ | ||
98 | sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ | ||
99 | -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ | ||
100 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ | ||
101 | -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \ | ||
102 | -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ | ||
103 | -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ | ||
104 | < $(srcdir)/stddef.in.h; \ | ||
105 | } > $@-t && \ | ||
106 | mv $@-t $@ | ||
107 | MOSTLYCLEANFILES += stddef.h stddef.h-t | ||
108 | |||
109 | EXTRA_DIST += stddef.in.h | ||
110 | |||
111 | ## end gnulib module stddef | ||
112 | |||
113 | ## begin gnulib module string | ||
114 | |||
115 | BUILT_SOURCES += string.h | ||
116 | |||
117 | # We need the following in order to create <string.h> when the system | ||
118 | # doesn't have one that works with the given compiler. | ||
119 | string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) | ||
120 | $(AM_V_GEN)rm -f $@-t $@ && \ | ||
121 | { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ | ||
122 | sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ | ||
123 | -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ | ||
124 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ | ||
125 | -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \ | ||
126 | -e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \ | ||
127 | -e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \ | ||
128 | -e 's|@''GNULIB_MBSCHR''@|$(GNULIB_MBSCHR)|g' \ | ||
129 | -e 's|@''GNULIB_MBSRCHR''@|$(GNULIB_MBSRCHR)|g' \ | ||
130 | -e 's|@''GNULIB_MBSSTR''@|$(GNULIB_MBSSTR)|g' \ | ||
131 | -e 's|@''GNULIB_MBSCASECMP''@|$(GNULIB_MBSCASECMP)|g' \ | ||
132 | -e 's|@''GNULIB_MBSNCASECMP''@|$(GNULIB_MBSNCASECMP)|g' \ | ||
133 | -e 's|@''GNULIB_MBSPCASECMP''@|$(GNULIB_MBSPCASECMP)|g' \ | ||
134 | -e 's|@''GNULIB_MBSCASESTR''@|$(GNULIB_MBSCASESTR)|g' \ | ||
135 | -e 's|@''GNULIB_MBSCSPN''@|$(GNULIB_MBSCSPN)|g' \ | ||
136 | -e 's|@''GNULIB_MBSPBRK''@|$(GNULIB_MBSPBRK)|g' \ | ||
137 | -e 's|@''GNULIB_MBSSPN''@|$(GNULIB_MBSSPN)|g' \ | ||
138 | -e 's|@''GNULIB_MBSSEP''@|$(GNULIB_MBSSEP)|g' \ | ||
139 | -e 's|@''GNULIB_MBSTOK_R''@|$(GNULIB_MBSTOK_R)|g' \ | ||
140 | -e 's|@''GNULIB_MEMCHR''@|$(GNULIB_MEMCHR)|g' \ | ||
141 | -e 's|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \ | ||
142 | -e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \ | ||
143 | -e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \ | ||
144 | -e 's|@''GNULIB_RAWMEMCHR''@|$(GNULIB_RAWMEMCHR)|g' \ | ||
145 | -e 's|@''GNULIB_STPCPY''@|$(GNULIB_STPCPY)|g' \ | ||
146 | -e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \ | ||
147 | -e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \ | ||
148 | -e 's|@''GNULIB_STRDUP''@|$(GNULIB_STRDUP)|g' \ | ||
149 | -e 's|@''GNULIB_STRNCAT''@|$(GNULIB_STRNCAT)|g' \ | ||
150 | -e 's|@''GNULIB_STRNDUP''@|$(GNULIB_STRNDUP)|g' \ | ||
151 | -e 's|@''GNULIB_STRNLEN''@|$(GNULIB_STRNLEN)|g' \ | ||
152 | -e 's|@''GNULIB_STRPBRK''@|$(GNULIB_STRPBRK)|g' \ | ||
153 | -e 's|@''GNULIB_STRSEP''@|$(GNULIB_STRSEP)|g' \ | ||
154 | -e 's|@''GNULIB_STRSTR''@|$(GNULIB_STRSTR)|g' \ | ||
155 | -e 's|@''GNULIB_STRCASESTR''@|$(GNULIB_STRCASESTR)|g' \ | ||
156 | -e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|g' \ | ||
157 | -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \ | ||
158 | -e 's|@''GNULIB_STRERROR_R''@|$(GNULIB_STRERROR_R)|g' \ | ||
159 | -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \ | ||
160 | -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \ | ||
161 | < $(srcdir)/string.in.h | \ | ||
162 | sed -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ | ||
163 | -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \ | ||
164 | -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ | ||
165 | -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ | ||
166 | -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ | ||
167 | -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \ | ||
168 | -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \ | ||
169 | -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ | ||
170 | -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \ | ||
171 | -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \ | ||
172 | -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \ | ||
173 | -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \ | ||
174 | -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \ | ||
175 | -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \ | ||
176 | -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ | ||
177 | -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ | ||
178 | -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \ | ||
179 | -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ | ||
180 | -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \ | ||
181 | -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ | ||
182 | -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ | ||
183 | -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ | ||
184 | -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ | ||
185 | -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ | ||
186 | -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ | ||
187 | -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ | ||
188 | -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \ | ||
189 | -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ | ||
190 | -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ | ||
191 | -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ | ||
192 | -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ | ||
193 | -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ | ||
194 | -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ | ||
195 | -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ | ||
196 | -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ | ||
197 | -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ | ||
198 | < $(srcdir)/string.in.h; \ | ||
199 | } > $@-t && \ | ||
200 | mv $@-t $@ | ||
201 | MOSTLYCLEANFILES += string.h string.h-t | ||
202 | |||
203 | EXTRA_DIST += string.in.h | ||
204 | |||
205 | ## end gnulib module string | ||
206 | |||
207 | ## begin gnulib module strtok_r | ||
208 | |||
209 | |||
210 | EXTRA_DIST += strtok_r.c | ||
211 | |||
212 | EXTRA_libgnu_la_SOURCES += strtok_r.c | ||
213 | |||
214 | ## end gnulib module strtok_r | ||
215 | |||
216 | ## begin gnulib module warn-on-use | ||
217 | |||
218 | BUILT_SOURCES += warn-on-use.h | ||
219 | # The warn-on-use.h that gets inserted into generated .h files is the same as | ||
220 | # build-aux/warn-on-use.h, except that it has the copyright header cut off. | ||
221 | warn-on-use.h: $(top_srcdir)/./warn-on-use.h | ||
222 | $(AM_V_GEN)rm -f $@-t $@ && \ | ||
223 | sed -n -e '/^.ifndef/,$$p' \ | ||
224 | < $(top_srcdir)/./warn-on-use.h \ | ||
225 | > $@-t && \ | ||
226 | mv $@-t $@ | ||
227 | MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t | ||
228 | |||
229 | WARN_ON_USE_H=warn-on-use.h | ||
230 | |||
231 | EXTRA_DIST += $(top_srcdir)/./warn-on-use.h | ||
232 | |||
233 | ## end gnulib module warn-on-use | ||
234 | |||
235 | ## begin gnulib module dummy | ||
236 | |||
237 | libgnu_la_SOURCES += dummy.c | ||
238 | |||
239 | ## end gnulib module dummy | ||
240 | |||
241 | |||
242 | mostlyclean-local: mostlyclean-generic | ||
243 | @for dir in '' $(MOSTLYCLEANDIRS); do \ | ||
244 | if test -n "$$dir" && test -d $$dir; then \ | ||
245 | echo "rmdir $$dir"; rmdir $$dir; \ | ||
246 | fi; \ | ||
247 | done; \ | ||
248 | : | ||
diff --git a/src/util/libgnu/dummy.c b/src/util/libgnu/dummy.c new file mode 100644 index 000000000..c958ea05d --- /dev/null +++ b/src/util/libgnu/dummy.c | |||
@@ -0,0 +1,42 @@ | |||
1 | /* A dummy file, to prevent empty libraries from breaking builds. | ||
2 | Copyright (C) 2004, 2007, 2009-2011 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 3 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | /* Some systems, reportedly OpenBSD and Mac OS X, refuse to create | ||
18 | libraries without any object files. You might get an error like: | ||
19 | |||
20 | > ar cru .libs/libgl.a | ||
21 | > ar: no archive members specified | ||
22 | |||
23 | Compiling this file, and adding its object file to the library, will | ||
24 | prevent the library from being empty. */ | ||
25 | |||
26 | /* Some systems, such as Solaris with cc 5.0, refuse to work with libraries | ||
27 | that don't export any symbol. You might get an error like: | ||
28 | |||
29 | > cc ... libgnu.a | ||
30 | > ild: (bad file) garbled symbol table in archive ../gllib/libgnu.a | ||
31 | |||
32 | Compiling this file, and adding its object file to the library, will | ||
33 | prevent the library from exporting no symbols. */ | ||
34 | |||
35 | #ifdef __sun | ||
36 | /* This declaration ensures that the library will export at least 1 symbol. */ | ||
37 | int gl_dummy_symbol; | ||
38 | #else | ||
39 | /* This declaration is solely to ensure that after preprocessing | ||
40 | this file is never empty. */ | ||
41 | typedef int dummy; | ||
42 | #endif | ||
diff --git a/src/util/libgnu/stddef.in.h b/src/util/libgnu/stddef.in.h new file mode 100644 index 000000000..62a91a7a6 --- /dev/null +++ b/src/util/libgnu/stddef.in.h | |||
@@ -0,0 +1,87 @@ | |||
1 | /* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues. | ||
2 | |||
3 | Copyright (C) 2009-2011 Free Software Foundation, Inc. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 3, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software Foundation, | ||
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
18 | |||
19 | /* Written by Eric Blake. */ | ||
20 | |||
21 | /* | ||
22 | * POSIX 2008 <stddef.h> for platforms that have issues. | ||
23 | * <http://www.opengroup.org/susv3xbd/stddef.h.html> | ||
24 | */ | ||
25 | |||
26 | #if __GNUC__ >= 3 | ||
27 | @PRAGMA_SYSTEM_HEADER@ | ||
28 | #endif | ||
29 | @PRAGMA_COLUMNS@ | ||
30 | |||
31 | #if defined __need_wchar_t || defined __need_size_t \ | ||
32 | || defined __need_ptrdiff_t || defined __need_NULL \ | ||
33 | || defined __need_wint_t | ||
34 | /* Special invocation convention inside gcc header files. In | ||
35 | particular, gcc provides a version of <stddef.h> that blindly | ||
36 | redefines NULL even when __need_wint_t was defined, even though | ||
37 | wint_t is not normally provided by <stddef.h>. Hence, we must | ||
38 | remember if special invocation has ever been used to obtain wint_t, | ||
39 | in which case we need to clean up NULL yet again. */ | ||
40 | |||
41 | # if !(defined _GL_STDDEF_H && defined _GL_STDDEF_WINT_T) | ||
42 | # ifdef __need_wint_t | ||
43 | # undef _GL_STDDEF_H | ||
44 | # define _GL_STDDEF_WINT_T | ||
45 | # endif | ||
46 | # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ | ||
47 | # endif | ||
48 | |||
49 | #else | ||
50 | /* Normal invocation convention. */ | ||
51 | |||
52 | # ifndef _GL_STDDEF_H | ||
53 | |||
54 | /* The include_next requires a split double-inclusion guard. */ | ||
55 | |||
56 | # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ | ||
57 | |||
58 | # ifndef _GL_STDDEF_H | ||
59 | # define _GL_STDDEF_H | ||
60 | |||
61 | /* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ | ||
62 | #if @REPLACE_NULL@ | ||
63 | # undef NULL | ||
64 | # ifdef __cplusplus | ||
65 | /* ISO C++ says that the macro NULL must expand to an integer constant | ||
66 | expression, hence '((void *) 0)' is not allowed in C++. */ | ||
67 | # if __GNUG__ >= 3 | ||
68 | /* GNU C++ has a __null macro that behaves like an integer ('int' or | ||
69 | 'long') but has the same size as a pointer. Use that, to avoid | ||
70 | warnings. */ | ||
71 | # define NULL __null | ||
72 | # else | ||
73 | # define NULL 0L | ||
74 | # endif | ||
75 | # else | ||
76 | # define NULL ((void *) 0) | ||
77 | # endif | ||
78 | #endif | ||
79 | |||
80 | /* Some platforms lack wchar_t. */ | ||
81 | #if !@HAVE_WCHAR_T@ | ||
82 | # define wchar_t int | ||
83 | #endif | ||
84 | |||
85 | # endif /* _GL_STDDEF_H */ | ||
86 | # endif /* _GL_STDDEF_H */ | ||
87 | #endif /* __need_XXX */ | ||
diff --git a/src/util/libgnu/string.in.h b/src/util/libgnu/string.in.h new file mode 100644 index 000000000..336e24651 --- /dev/null +++ b/src/util/libgnu/string.in.h | |||
@@ -0,0 +1,970 @@ | |||
1 | /* A GNU-like <string.h>. | ||
2 | |||
3 | Copyright (C) 1995-1996, 2001-2011 Free Software Foundation, Inc. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 3, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software Foundation, | ||
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
18 | |||
19 | #ifndef _GL_STRING_H | ||
20 | |||
21 | #if __GNUC__ >= 3 | ||
22 | @PRAGMA_SYSTEM_HEADER@ | ||
23 | #endif | ||
24 | @PRAGMA_COLUMNS@ | ||
25 | |||
26 | /* The include_next requires a split double-inclusion guard. */ | ||
27 | #@INCLUDE_NEXT@ @NEXT_STRING_H@ | ||
28 | |||
29 | #ifndef _GL_STRING_H | ||
30 | #define _GL_STRING_H | ||
31 | |||
32 | /* NetBSD 5.0 mis-defines NULL. */ | ||
33 | #include <stddef.h> | ||
34 | |||
35 | /* MirBSD defines mbslen as a macro. */ | ||
36 | #if @GNULIB_MBSLEN@ && defined __MirBSD__ | ||
37 | # include <wchar.h> | ||
38 | #endif | ||
39 | |||
40 | /* The __attribute__ feature is available in gcc versions 2.5 and later. | ||
41 | The attribute __pure__ was added in gcc 2.96. */ | ||
42 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) | ||
43 | # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) | ||
44 | #else | ||
45 | # define _GL_ATTRIBUTE_PURE /* empty */ | ||
46 | #endif | ||
47 | |||
48 | /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ | ||
49 | /* But in any case avoid namespace pollution on glibc systems. */ | ||
50 | #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ | ||
51 | && ! defined __GLIBC__ | ||
52 | # include <unistd.h> | ||
53 | #endif | ||
54 | |||
55 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | ||
56 | |||
57 | /* The definition of _GL_ARG_NONNULL is copied here. */ | ||
58 | |||
59 | /* The definition of _GL_WARN_ON_USE is copied here. */ | ||
60 | |||
61 | |||
62 | /* Return the first instance of C within N bytes of S, or NULL. */ | ||
63 | #if @GNULIB_MEMCHR@ | ||
64 | # if @REPLACE_MEMCHR@ | ||
65 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
66 | # define memchr rpl_memchr | ||
67 | # endif | ||
68 | _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) | ||
69 | _GL_ATTRIBUTE_PURE | ||
70 | _GL_ARG_NONNULL ((1))); | ||
71 | _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); | ||
72 | # else | ||
73 | # if ! @HAVE_MEMCHR@ | ||
74 | _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) | ||
75 | _GL_ATTRIBUTE_PURE | ||
76 | _GL_ARG_NONNULL ((1))); | ||
77 | # endif | ||
78 | /* On some systems, this function is defined as an overloaded function: | ||
79 | extern "C" { const void * std::memchr (const void *, int, size_t); } | ||
80 | extern "C++" { void * std::memchr (void *, int, size_t); } */ | ||
81 | _GL_CXXALIAS_SYS_CAST2 (memchr, | ||
82 | void *, (void const *__s, int __c, size_t __n), | ||
83 | void const *, (void const *__s, int __c, size_t __n)); | ||
84 | # endif | ||
85 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | ||
86 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||
87 | _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); | ||
88 | _GL_CXXALIASWARN1 (memchr, void const *, | ||
89 | (void const *__s, int __c, size_t __n)); | ||
90 | # else | ||
91 | _GL_CXXALIASWARN (memchr); | ||
92 | # endif | ||
93 | #elif defined GNULIB_POSIXCHECK | ||
94 | # undef memchr | ||
95 | /* Assume memchr is always declared. */ | ||
96 | _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " | ||
97 | "use gnulib module memchr for portability" ); | ||
98 | #endif | ||
99 | |||
100 | /* Return the first occurrence of NEEDLE in HAYSTACK. */ | ||
101 | #if @GNULIB_MEMMEM@ | ||
102 | # if @REPLACE_MEMMEM@ | ||
103 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
104 | # define memmem rpl_memmem | ||
105 | # endif | ||
106 | _GL_FUNCDECL_RPL (memmem, void *, | ||
107 | (void const *__haystack, size_t __haystack_len, | ||
108 | void const *__needle, size_t __needle_len) | ||
109 | _GL_ATTRIBUTE_PURE | ||
110 | _GL_ARG_NONNULL ((1, 3))); | ||
111 | _GL_CXXALIAS_RPL (memmem, void *, | ||
112 | (void const *__haystack, size_t __haystack_len, | ||
113 | void const *__needle, size_t __needle_len)); | ||
114 | # else | ||
115 | # if ! @HAVE_DECL_MEMMEM@ | ||
116 | _GL_FUNCDECL_SYS (memmem, void *, | ||
117 | (void const *__haystack, size_t __haystack_len, | ||
118 | void const *__needle, size_t __needle_len) | ||
119 | _GL_ATTRIBUTE_PURE | ||
120 | _GL_ARG_NONNULL ((1, 3))); | ||
121 | # endif | ||
122 | _GL_CXXALIAS_SYS (memmem, void *, | ||
123 | (void const *__haystack, size_t __haystack_len, | ||
124 | void const *__needle, size_t __needle_len)); | ||
125 | # endif | ||
126 | _GL_CXXALIASWARN (memmem); | ||
127 | #elif defined GNULIB_POSIXCHECK | ||
128 | # undef memmem | ||
129 | # if HAVE_RAW_DECL_MEMMEM | ||
130 | _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " | ||
131 | "use gnulib module memmem-simple for portability, " | ||
132 | "and module memmem for speed" ); | ||
133 | # endif | ||
134 | #endif | ||
135 | |||
136 | /* Copy N bytes of SRC to DEST, return pointer to bytes after the | ||
137 | last written byte. */ | ||
138 | #if @GNULIB_MEMPCPY@ | ||
139 | # if ! @HAVE_MEMPCPY@ | ||
140 | _GL_FUNCDECL_SYS (mempcpy, void *, | ||
141 | (void *restrict __dest, void const *restrict __src, | ||
142 | size_t __n) | ||
143 | _GL_ARG_NONNULL ((1, 2))); | ||
144 | # endif | ||
145 | _GL_CXXALIAS_SYS (mempcpy, void *, | ||
146 | (void *restrict __dest, void const *restrict __src, | ||
147 | size_t __n)); | ||
148 | _GL_CXXALIASWARN (mempcpy); | ||
149 | #elif defined GNULIB_POSIXCHECK | ||
150 | # undef mempcpy | ||
151 | # if HAVE_RAW_DECL_MEMPCPY | ||
152 | _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " | ||
153 | "use gnulib module mempcpy for portability"); | ||
154 | # endif | ||
155 | #endif | ||
156 | |||
157 | /* Search backwards through a block for a byte (specified as an int). */ | ||
158 | #if @GNULIB_MEMRCHR@ | ||
159 | # if ! @HAVE_DECL_MEMRCHR@ | ||
160 | _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) | ||
161 | _GL_ATTRIBUTE_PURE | ||
162 | _GL_ARG_NONNULL ((1))); | ||
163 | # endif | ||
164 | /* On some systems, this function is defined as an overloaded function: | ||
165 | extern "C++" { const void * std::memrchr (const void *, int, size_t); } | ||
166 | extern "C++" { void * std::memrchr (void *, int, size_t); } */ | ||
167 | _GL_CXXALIAS_SYS_CAST2 (memrchr, | ||
168 | void *, (void const *, int, size_t), | ||
169 | void const *, (void const *, int, size_t)); | ||
170 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | ||
171 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||
172 | _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); | ||
173 | _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); | ||
174 | # else | ||
175 | _GL_CXXALIASWARN (memrchr); | ||
176 | # endif | ||
177 | #elif defined GNULIB_POSIXCHECK | ||
178 | # undef memrchr | ||
179 | # if HAVE_RAW_DECL_MEMRCHR | ||
180 | _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " | ||
181 | "use gnulib module memrchr for portability"); | ||
182 | # endif | ||
183 | #endif | ||
184 | |||
185 | /* Find the first occurrence of C in S. More efficient than | ||
186 | memchr(S,C,N), at the expense of undefined behavior if C does not | ||
187 | occur within N bytes. */ | ||
188 | #if @GNULIB_RAWMEMCHR@ | ||
189 | # if ! @HAVE_RAWMEMCHR@ | ||
190 | _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) | ||
191 | _GL_ATTRIBUTE_PURE | ||
192 | _GL_ARG_NONNULL ((1))); | ||
193 | # endif | ||
194 | /* On some systems, this function is defined as an overloaded function: | ||
195 | extern "C++" { const void * std::rawmemchr (const void *, int); } | ||
196 | extern "C++" { void * std::rawmemchr (void *, int); } */ | ||
197 | _GL_CXXALIAS_SYS_CAST2 (rawmemchr, | ||
198 | void *, (void const *__s, int __c_in), | ||
199 | void const *, (void const *__s, int __c_in)); | ||
200 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | ||
201 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||
202 | _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); | ||
203 | _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); | ||
204 | # else | ||
205 | _GL_CXXALIASWARN (rawmemchr); | ||
206 | # endif | ||
207 | #elif defined GNULIB_POSIXCHECK | ||
208 | # undef rawmemchr | ||
209 | # if HAVE_RAW_DECL_RAWMEMCHR | ||
210 | _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " | ||
211 | "use gnulib module rawmemchr for portability"); | ||
212 | # endif | ||
213 | #endif | ||
214 | |||
215 | /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ | ||
216 | #if @GNULIB_STPCPY@ | ||
217 | # if ! @HAVE_STPCPY@ | ||
218 | _GL_FUNCDECL_SYS (stpcpy, char *, | ||
219 | (char *restrict __dst, char const *restrict __src) | ||
220 | _GL_ARG_NONNULL ((1, 2))); | ||
221 | # endif | ||
222 | _GL_CXXALIAS_SYS (stpcpy, char *, | ||
223 | (char *restrict __dst, char const *restrict __src)); | ||
224 | _GL_CXXALIASWARN (stpcpy); | ||
225 | #elif defined GNULIB_POSIXCHECK | ||
226 | # undef stpcpy | ||
227 | # if HAVE_RAW_DECL_STPCPY | ||
228 | _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " | ||
229 | "use gnulib module stpcpy for portability"); | ||
230 | # endif | ||
231 | #endif | ||
232 | |||
233 | /* Copy no more than N bytes of SRC to DST, returning a pointer past the | ||
234 | last non-NUL byte written into DST. */ | ||
235 | #if @GNULIB_STPNCPY@ | ||
236 | # if @REPLACE_STPNCPY@ | ||
237 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
238 | # undef stpncpy | ||
239 | # define stpncpy rpl_stpncpy | ||
240 | # endif | ||
241 | _GL_FUNCDECL_RPL (stpncpy, char *, | ||
242 | (char *restrict __dst, char const *restrict __src, | ||
243 | size_t __n) | ||
244 | _GL_ARG_NONNULL ((1, 2))); | ||
245 | _GL_CXXALIAS_RPL (stpncpy, char *, | ||
246 | (char *restrict __dst, char const *restrict __src, | ||
247 | size_t __n)); | ||
248 | # else | ||
249 | # if ! @HAVE_STPNCPY@ | ||
250 | _GL_FUNCDECL_SYS (stpncpy, char *, | ||
251 | (char *restrict __dst, char const *restrict __src, | ||
252 | size_t __n) | ||
253 | _GL_ARG_NONNULL ((1, 2))); | ||
254 | # endif | ||
255 | _GL_CXXALIAS_SYS (stpncpy, char *, | ||
256 | (char *restrict __dst, char const *restrict __src, | ||
257 | size_t __n)); | ||
258 | # endif | ||
259 | _GL_CXXALIASWARN (stpncpy); | ||
260 | #elif defined GNULIB_POSIXCHECK | ||
261 | # undef stpncpy | ||
262 | # if HAVE_RAW_DECL_STPNCPY | ||
263 | _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " | ||
264 | "use gnulib module stpncpy for portability"); | ||
265 | # endif | ||
266 | #endif | ||
267 | |||
268 | #if defined GNULIB_POSIXCHECK | ||
269 | /* strchr() does not work with multibyte strings if the locale encoding is | ||
270 | GB18030 and the character to be searched is a digit. */ | ||
271 | # undef strchr | ||
272 | /* Assume strchr is always declared. */ | ||
273 | _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " | ||
274 | "in some multibyte locales - " | ||
275 | "use mbschr if you care about internationalization"); | ||
276 | #endif | ||
277 | |||
278 | /* Find the first occurrence of C in S or the final NUL byte. */ | ||
279 | #if @GNULIB_STRCHRNUL@ | ||
280 | # if ! @HAVE_STRCHRNUL@ | ||
281 | _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) | ||
282 | _GL_ATTRIBUTE_PURE | ||
283 | _GL_ARG_NONNULL ((1))); | ||
284 | # endif | ||
285 | /* On some systems, this function is defined as an overloaded function: | ||
286 | extern "C++" { const char * std::strchrnul (const char *, int); } | ||
287 | extern "C++" { char * std::strchrnul (char *, int); } */ | ||
288 | _GL_CXXALIAS_SYS_CAST2 (strchrnul, | ||
289 | char *, (char const *__s, int __c_in), | ||
290 | char const *, (char const *__s, int __c_in)); | ||
291 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | ||
292 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||
293 | _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); | ||
294 | _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); | ||
295 | # else | ||
296 | _GL_CXXALIASWARN (strchrnul); | ||
297 | # endif | ||
298 | #elif defined GNULIB_POSIXCHECK | ||
299 | # undef strchrnul | ||
300 | # if HAVE_RAW_DECL_STRCHRNUL | ||
301 | _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " | ||
302 | "use gnulib module strchrnul for portability"); | ||
303 | # endif | ||
304 | #endif | ||
305 | |||
306 | /* Duplicate S, returning an identical malloc'd string. */ | ||
307 | #if @GNULIB_STRDUP@ | ||
308 | # if @REPLACE_STRDUP@ | ||
309 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
310 | # undef strdup | ||
311 | # define strdup rpl_strdup | ||
312 | # endif | ||
313 | _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); | ||
314 | _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); | ||
315 | # else | ||
316 | # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup | ||
317 | /* strdup exists as a function and as a macro. Get rid of the macro. */ | ||
318 | # undef strdup | ||
319 | # endif | ||
320 | # if !(@HAVE_DECL_STRDUP@ || defined strdup) | ||
321 | _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); | ||
322 | # endif | ||
323 | _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); | ||
324 | # endif | ||
325 | _GL_CXXALIASWARN (strdup); | ||
326 | #elif defined GNULIB_POSIXCHECK | ||
327 | # undef strdup | ||
328 | # if HAVE_RAW_DECL_STRDUP | ||
329 | _GL_WARN_ON_USE (strdup, "strdup is unportable - " | ||
330 | "use gnulib module strdup for portability"); | ||
331 | # endif | ||
332 | #endif | ||
333 | |||
334 | /* Append no more than N characters from SRC onto DEST. */ | ||
335 | #if @GNULIB_STRNCAT@ | ||
336 | # if @REPLACE_STRNCAT@ | ||
337 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
338 | # undef strncat | ||
339 | # define strncat rpl_strncat | ||
340 | # endif | ||
341 | _GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) | ||
342 | _GL_ARG_NONNULL ((1, 2))); | ||
343 | _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); | ||
344 | # else | ||
345 | _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); | ||
346 | # endif | ||
347 | _GL_CXXALIASWARN (strncat); | ||
348 | #elif defined GNULIB_POSIXCHECK | ||
349 | # undef strncat | ||
350 | # if HAVE_RAW_DECL_STRNCAT | ||
351 | _GL_WARN_ON_USE (strncat, "strncat is unportable - " | ||
352 | "use gnulib module strncat for portability"); | ||
353 | # endif | ||
354 | #endif | ||
355 | |||
356 | /* Return a newly allocated copy of at most N bytes of STRING. */ | ||
357 | #if @GNULIB_STRNDUP@ | ||
358 | # if @REPLACE_STRNDUP@ | ||
359 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
360 | # undef strndup | ||
361 | # define strndup rpl_strndup | ||
362 | # endif | ||
363 | _GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n) | ||
364 | _GL_ARG_NONNULL ((1))); | ||
365 | _GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n)); | ||
366 | # else | ||
367 | # if ! @HAVE_DECL_STRNDUP@ | ||
368 | _GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n) | ||
369 | _GL_ARG_NONNULL ((1))); | ||
370 | # endif | ||
371 | _GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n)); | ||
372 | # endif | ||
373 | _GL_CXXALIASWARN (strndup); | ||
374 | #elif defined GNULIB_POSIXCHECK | ||
375 | # undef strndup | ||
376 | # if HAVE_RAW_DECL_STRNDUP | ||
377 | _GL_WARN_ON_USE (strndup, "strndup is unportable - " | ||
378 | "use gnulib module strndup for portability"); | ||
379 | # endif | ||
380 | #endif | ||
381 | |||
382 | /* Find the length (number of bytes) of STRING, but scan at most | ||
383 | MAXLEN bytes. If no '\0' terminator is found in that many bytes, | ||
384 | return MAXLEN. */ | ||
385 | #if @GNULIB_STRNLEN@ | ||
386 | # if @REPLACE_STRNLEN@ | ||
387 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
388 | # undef strnlen | ||
389 | # define strnlen rpl_strnlen | ||
390 | # endif | ||
391 | _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) | ||
392 | _GL_ATTRIBUTE_PURE | ||
393 | _GL_ARG_NONNULL ((1))); | ||
394 | _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); | ||
395 | # else | ||
396 | # if ! @HAVE_DECL_STRNLEN@ | ||
397 | _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) | ||
398 | _GL_ATTRIBUTE_PURE | ||
399 | _GL_ARG_NONNULL ((1))); | ||
400 | # endif | ||
401 | _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); | ||
402 | # endif | ||
403 | _GL_CXXALIASWARN (strnlen); | ||
404 | #elif defined GNULIB_POSIXCHECK | ||
405 | # undef strnlen | ||
406 | # if HAVE_RAW_DECL_STRNLEN | ||
407 | _GL_WARN_ON_USE (strnlen, "strnlen is unportable - " | ||
408 | "use gnulib module strnlen for portability"); | ||
409 | # endif | ||
410 | #endif | ||
411 | |||
412 | #if defined GNULIB_POSIXCHECK | ||
413 | /* strcspn() assumes the second argument is a list of single-byte characters. | ||
414 | Even in this simple case, it does not work with multibyte strings if the | ||
415 | locale encoding is GB18030 and one of the characters to be searched is a | ||
416 | digit. */ | ||
417 | # undef strcspn | ||
418 | /* Assume strcspn is always declared. */ | ||
419 | _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " | ||
420 | "in multibyte locales - " | ||
421 | "use mbscspn if you care about internationalization"); | ||
422 | #endif | ||
423 | |||
424 | /* Find the first occurrence in S of any character in ACCEPT. */ | ||
425 | #if @GNULIB_STRPBRK@ | ||
426 | # if ! @HAVE_STRPBRK@ | ||
427 | _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) | ||
428 | _GL_ATTRIBUTE_PURE | ||
429 | _GL_ARG_NONNULL ((1, 2))); | ||
430 | # endif | ||
431 | /* On some systems, this function is defined as an overloaded function: | ||
432 | extern "C" { const char * strpbrk (const char *, const char *); } | ||
433 | extern "C++" { char * strpbrk (char *, const char *); } */ | ||
434 | _GL_CXXALIAS_SYS_CAST2 (strpbrk, | ||
435 | char *, (char const *__s, char const *__accept), | ||
436 | const char *, (char const *__s, char const *__accept)); | ||
437 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | ||
438 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||
439 | _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); | ||
440 | _GL_CXXALIASWARN1 (strpbrk, char const *, | ||
441 | (char const *__s, char const *__accept)); | ||
442 | # else | ||
443 | _GL_CXXALIASWARN (strpbrk); | ||
444 | # endif | ||
445 | # if defined GNULIB_POSIXCHECK | ||
446 | /* strpbrk() assumes the second argument is a list of single-byte characters. | ||
447 | Even in this simple case, it does not work with multibyte strings if the | ||
448 | locale encoding is GB18030 and one of the characters to be searched is a | ||
449 | digit. */ | ||
450 | # undef strpbrk | ||
451 | _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " | ||
452 | "in multibyte locales - " | ||
453 | "use mbspbrk if you care about internationalization"); | ||
454 | # endif | ||
455 | #elif defined GNULIB_POSIXCHECK | ||
456 | # undef strpbrk | ||
457 | # if HAVE_RAW_DECL_STRPBRK | ||
458 | _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " | ||
459 | "use gnulib module strpbrk for portability"); | ||
460 | # endif | ||
461 | #endif | ||
462 | |||
463 | #if defined GNULIB_POSIXCHECK | ||
464 | /* strspn() assumes the second argument is a list of single-byte characters. | ||
465 | Even in this simple case, it cannot work with multibyte strings. */ | ||
466 | # undef strspn | ||
467 | /* Assume strspn is always declared. */ | ||
468 | _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " | ||
469 | "in multibyte locales - " | ||
470 | "use mbsspn if you care about internationalization"); | ||
471 | #endif | ||
472 | |||
473 | #if defined GNULIB_POSIXCHECK | ||
474 | /* strrchr() does not work with multibyte strings if the locale encoding is | ||
475 | GB18030 and the character to be searched is a digit. */ | ||
476 | # undef strrchr | ||
477 | /* Assume strrchr is always declared. */ | ||
478 | _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " | ||
479 | "in some multibyte locales - " | ||
480 | "use mbsrchr if you care about internationalization"); | ||
481 | #endif | ||
482 | |||
483 | /* Search the next delimiter (char listed in DELIM) starting at *STRINGP. | ||
484 | If one is found, overwrite it with a NUL, and advance *STRINGP | ||
485 | to point to the next char after it. Otherwise, set *STRINGP to NULL. | ||
486 | If *STRINGP was already NULL, nothing happens. | ||
487 | Return the old value of *STRINGP. | ||
488 | |||
489 | This is a variant of strtok() that is multithread-safe and supports | ||
490 | empty fields. | ||
491 | |||
492 | Caveat: It modifies the original string. | ||
493 | Caveat: These functions cannot be used on constant strings. | ||
494 | Caveat: The identity of the delimiting character is lost. | ||
495 | Caveat: It doesn't work with multibyte strings unless all of the delimiter | ||
496 | characters are ASCII characters < 0x30. | ||
497 | |||
498 | See also strtok_r(). */ | ||
499 | #if @GNULIB_STRSEP@ | ||
500 | # if ! @HAVE_STRSEP@ | ||
501 | _GL_FUNCDECL_SYS (strsep, char *, | ||
502 | (char **restrict __stringp, char const *restrict __delim) | ||
503 | _GL_ARG_NONNULL ((1, 2))); | ||
504 | # endif | ||
505 | _GL_CXXALIAS_SYS (strsep, char *, | ||
506 | (char **restrict __stringp, char const *restrict __delim)); | ||
507 | _GL_CXXALIASWARN (strsep); | ||
508 | # if defined GNULIB_POSIXCHECK | ||
509 | # undef strsep | ||
510 | _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings " | ||
511 | "in multibyte locales - " | ||
512 | "use mbssep if you care about internationalization"); | ||
513 | # endif | ||
514 | #elif defined GNULIB_POSIXCHECK | ||
515 | # undef strsep | ||
516 | # if HAVE_RAW_DECL_STRSEP | ||
517 | _GL_WARN_ON_USE (strsep, "strsep is unportable - " | ||
518 | "use gnulib module strsep for portability"); | ||
519 | # endif | ||
520 | #endif | ||
521 | |||
522 | #if @GNULIB_STRSTR@ | ||
523 | # if @REPLACE_STRSTR@ | ||
524 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
525 | # define strstr rpl_strstr | ||
526 | # endif | ||
527 | _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) | ||
528 | _GL_ATTRIBUTE_PURE | ||
529 | _GL_ARG_NONNULL ((1, 2))); | ||
530 | _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); | ||
531 | # else | ||
532 | /* On some systems, this function is defined as an overloaded function: | ||
533 | extern "C++" { const char * strstr (const char *, const char *); } | ||
534 | extern "C++" { char * strstr (char *, const char *); } */ | ||
535 | _GL_CXXALIAS_SYS_CAST2 (strstr, | ||
536 | char *, (const char *haystack, const char *needle), | ||
537 | const char *, (const char *haystack, const char *needle)); | ||
538 | # endif | ||
539 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | ||
540 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||
541 | _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); | ||
542 | _GL_CXXALIASWARN1 (strstr, const char *, | ||
543 | (const char *haystack, const char *needle)); | ||
544 | # else | ||
545 | _GL_CXXALIASWARN (strstr); | ||
546 | # endif | ||
547 | #elif defined GNULIB_POSIXCHECK | ||
548 | /* strstr() does not work with multibyte strings if the locale encoding is | ||
549 | different from UTF-8: | ||
550 | POSIX says that it operates on "strings", and "string" in POSIX is defined | ||
551 | as a sequence of bytes, not of characters. */ | ||
552 | # undef strstr | ||
553 | /* Assume strstr is always declared. */ | ||
554 | _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " | ||
555 | "work correctly on character strings in most " | ||
556 | "multibyte locales - " | ||
557 | "use mbsstr if you care about internationalization, " | ||
558 | "or use strstr if you care about speed"); | ||
559 | #endif | ||
560 | |||
561 | /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive | ||
562 | comparison. */ | ||
563 | #if @GNULIB_STRCASESTR@ | ||
564 | # if @REPLACE_STRCASESTR@ | ||
565 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
566 | # define strcasestr rpl_strcasestr | ||
567 | # endif | ||
568 | _GL_FUNCDECL_RPL (strcasestr, char *, | ||
569 | (const char *haystack, const char *needle) | ||
570 | _GL_ATTRIBUTE_PURE | ||
571 | _GL_ARG_NONNULL ((1, 2))); | ||
572 | _GL_CXXALIAS_RPL (strcasestr, char *, | ||
573 | (const char *haystack, const char *needle)); | ||
574 | # else | ||
575 | # if ! @HAVE_STRCASESTR@ | ||
576 | _GL_FUNCDECL_SYS (strcasestr, char *, | ||
577 | (const char *haystack, const char *needle) | ||
578 | _GL_ATTRIBUTE_PURE | ||
579 | _GL_ARG_NONNULL ((1, 2))); | ||
580 | # endif | ||
581 | /* On some systems, this function is defined as an overloaded function: | ||
582 | extern "C++" { const char * strcasestr (const char *, const char *); } | ||
583 | extern "C++" { char * strcasestr (char *, const char *); } */ | ||
584 | _GL_CXXALIAS_SYS_CAST2 (strcasestr, | ||
585 | char *, (const char *haystack, const char *needle), | ||
586 | const char *, (const char *haystack, const char *needle)); | ||
587 | # endif | ||
588 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | ||
589 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||
590 | _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); | ||
591 | _GL_CXXALIASWARN1 (strcasestr, const char *, | ||
592 | (const char *haystack, const char *needle)); | ||
593 | # else | ||
594 | _GL_CXXALIASWARN (strcasestr); | ||
595 | # endif | ||
596 | #elif defined GNULIB_POSIXCHECK | ||
597 | /* strcasestr() does not work with multibyte strings: | ||
598 | It is a glibc extension, and glibc implements it only for unibyte | ||
599 | locales. */ | ||
600 | # undef strcasestr | ||
601 | # if HAVE_RAW_DECL_STRCASESTR | ||
602 | _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " | ||
603 | "strings in multibyte locales - " | ||
604 | "use mbscasestr if you care about " | ||
605 | "internationalization, or use c-strcasestr if you want " | ||
606 | "a locale independent function"); | ||
607 | # endif | ||
608 | #endif | ||
609 | |||
610 | /* Parse S into tokens separated by characters in DELIM. | ||
611 | If S is NULL, the saved pointer in SAVE_PTR is used as | ||
612 | the next starting point. For example: | ||
613 | char s[] = "-abc-=-def"; | ||
614 | char *sp; | ||
615 | x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" | ||
616 | x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL | ||
617 | x = strtok_r(NULL, "=", &sp); // x = NULL | ||
618 | // s = "abc\0-def\0" | ||
619 | |||
620 | This is a variant of strtok() that is multithread-safe. | ||
621 | |||
622 | For the POSIX documentation for this function, see: | ||
623 | http://www.opengroup.org/susv3xsh/strtok.html | ||
624 | |||
625 | Caveat: It modifies the original string. | ||
626 | Caveat: These functions cannot be used on constant strings. | ||
627 | Caveat: The identity of the delimiting character is lost. | ||
628 | Caveat: It doesn't work with multibyte strings unless all of the delimiter | ||
629 | characters are ASCII characters < 0x30. | ||
630 | |||
631 | See also strsep(). */ | ||
632 | #if @GNULIB_STRTOK_R@ | ||
633 | # if @REPLACE_STRTOK_R@ | ||
634 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
635 | # undef strtok_r | ||
636 | # define strtok_r rpl_strtok_r | ||
637 | # endif | ||
638 | _GL_FUNCDECL_RPL (strtok_r, char *, | ||
639 | (char *restrict s, char const *restrict delim, | ||
640 | char **restrict save_ptr) | ||
641 | _GL_ARG_NONNULL ((2, 3))); | ||
642 | _GL_CXXALIAS_RPL (strtok_r, char *, | ||
643 | (char *restrict s, char const *restrict delim, | ||
644 | char **restrict save_ptr)); | ||
645 | # else | ||
646 | # if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK | ||
647 | # undef strtok_r | ||
648 | # endif | ||
649 | # if ! @HAVE_DECL_STRTOK_R@ | ||
650 | _GL_FUNCDECL_SYS (strtok_r, char *, | ||
651 | (char *restrict s, char const *restrict delim, | ||
652 | char **restrict save_ptr) | ||
653 | _GL_ARG_NONNULL ((2, 3))); | ||
654 | # endif | ||
655 | _GL_CXXALIAS_SYS (strtok_r, char *, | ||
656 | (char *restrict s, char const *restrict delim, | ||
657 | char **restrict save_ptr)); | ||
658 | # endif | ||
659 | _GL_CXXALIASWARN (strtok_r); | ||
660 | # if defined GNULIB_POSIXCHECK | ||
661 | _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character " | ||
662 | "strings in multibyte locales - " | ||
663 | "use mbstok_r if you care about internationalization"); | ||
664 | # endif | ||
665 | #elif defined GNULIB_POSIXCHECK | ||
666 | # undef strtok_r | ||
667 | # if HAVE_RAW_DECL_STRTOK_R | ||
668 | _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " | ||
669 | "use gnulib module strtok_r for portability"); | ||
670 | # endif | ||
671 | #endif | ||
672 | |||
673 | |||
674 | /* The following functions are not specified by POSIX. They are gnulib | ||
675 | extensions. */ | ||
676 | |||
677 | #if @GNULIB_MBSLEN@ | ||
678 | /* Return the number of multibyte characters in the character string STRING. | ||
679 | This considers multibyte characters, unlike strlen, which counts bytes. */ | ||
680 | # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ | ||
681 | # undef mbslen | ||
682 | # endif | ||
683 | # if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */ | ||
684 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
685 | # define mbslen rpl_mbslen | ||
686 | # endif | ||
687 | _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1))); | ||
688 | _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); | ||
689 | # else | ||
690 | _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1))); | ||
691 | _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); | ||
692 | # endif | ||
693 | _GL_CXXALIASWARN (mbslen); | ||
694 | #endif | ||
695 | |||
696 | #if @GNULIB_MBSNLEN@ | ||
697 | /* Return the number of multibyte characters in the character string starting | ||
698 | at STRING and ending at STRING + LEN. */ | ||
699 | _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) | ||
700 | _GL_ARG_NONNULL ((1)); | ||
701 | #endif | ||
702 | |||
703 | #if @GNULIB_MBSCHR@ | ||
704 | /* Locate the first single-byte character C in the character string STRING, | ||
705 | and return a pointer to it. Return NULL if C is not found in STRING. | ||
706 | Unlike strchr(), this function works correctly in multibyte locales with | ||
707 | encodings such as GB18030. */ | ||
708 | # if defined __hpux | ||
709 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
710 | # define mbschr rpl_mbschr /* avoid collision with HP-UX function */ | ||
711 | # endif | ||
712 | _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) | ||
713 | _GL_ARG_NONNULL ((1))); | ||
714 | _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); | ||
715 | # else | ||
716 | _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) | ||
717 | _GL_ARG_NONNULL ((1))); | ||
718 | _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); | ||
719 | # endif | ||
720 | _GL_CXXALIASWARN (mbschr); | ||
721 | #endif | ||
722 | |||
723 | #if @GNULIB_MBSRCHR@ | ||
724 | /* Locate the last single-byte character C in the character string STRING, | ||
725 | and return a pointer to it. Return NULL if C is not found in STRING. | ||
726 | Unlike strrchr(), this function works correctly in multibyte locales with | ||
727 | encodings such as GB18030. */ | ||
728 | # if defined __hpux | ||
729 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
730 | # define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */ | ||
731 | # endif | ||
732 | _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) | ||
733 | _GL_ARG_NONNULL ((1))); | ||
734 | _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); | ||
735 | # else | ||
736 | _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) | ||
737 | _GL_ARG_NONNULL ((1))); | ||
738 | _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); | ||
739 | # endif | ||
740 | _GL_CXXALIASWARN (mbsrchr); | ||
741 | #endif | ||
742 | |||
743 | #if @GNULIB_MBSSTR@ | ||
744 | /* Find the first occurrence of the character string NEEDLE in the character | ||
745 | string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. | ||
746 | Unlike strstr(), this function works correctly in multibyte locales with | ||
747 | encodings different from UTF-8. */ | ||
748 | _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) | ||
749 | _GL_ARG_NONNULL ((1, 2)); | ||
750 | #endif | ||
751 | |||
752 | #if @GNULIB_MBSCASECMP@ | ||
753 | /* Compare the character strings S1 and S2, ignoring case, returning less than, | ||
754 | equal to or greater than zero if S1 is lexicographically less than, equal to | ||
755 | or greater than S2. | ||
756 | Note: This function may, in multibyte locales, return 0 for strings of | ||
757 | different lengths! | ||
758 | Unlike strcasecmp(), this function works correctly in multibyte locales. */ | ||
759 | _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2) | ||
760 | _GL_ARG_NONNULL ((1, 2)); | ||
761 | #endif | ||
762 | |||
763 | #if @GNULIB_MBSNCASECMP@ | ||
764 | /* Compare the initial segment of the character string S1 consisting of at most | ||
765 | N characters with the initial segment of the character string S2 consisting | ||
766 | of at most N characters, ignoring case, returning less than, equal to or | ||
767 | greater than zero if the initial segment of S1 is lexicographically less | ||
768 | than, equal to or greater than the initial segment of S2. | ||
769 | Note: This function may, in multibyte locales, return 0 for initial segments | ||
770 | of different lengths! | ||
771 | Unlike strncasecmp(), this function works correctly in multibyte locales. | ||
772 | But beware that N is not a byte count but a character count! */ | ||
773 | _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) | ||
774 | _GL_ARG_NONNULL ((1, 2)); | ||
775 | #endif | ||
776 | |||
777 | #if @GNULIB_MBSPCASECMP@ | ||
778 | /* Compare the initial segment of the character string STRING consisting of | ||
779 | at most mbslen (PREFIX) characters with the character string PREFIX, | ||
780 | ignoring case. If the two match, return a pointer to the first byte | ||
781 | after this prefix in STRING. Otherwise, return NULL. | ||
782 | Note: This function may, in multibyte locales, return non-NULL if STRING | ||
783 | is of smaller length than PREFIX! | ||
784 | Unlike strncasecmp(), this function works correctly in multibyte | ||
785 | locales. */ | ||
786 | _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) | ||
787 | _GL_ARG_NONNULL ((1, 2)); | ||
788 | #endif | ||
789 | |||
790 | #if @GNULIB_MBSCASESTR@ | ||
791 | /* Find the first occurrence of the character string NEEDLE in the character | ||
792 | string HAYSTACK, using case-insensitive comparison. | ||
793 | Note: This function may, in multibyte locales, return success even if | ||
794 | strlen (haystack) < strlen (needle) ! | ||
795 | Unlike strcasestr(), this function works correctly in multibyte locales. */ | ||
796 | _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) | ||
797 | _GL_ARG_NONNULL ((1, 2)); | ||
798 | #endif | ||
799 | |||
800 | #if @GNULIB_MBSCSPN@ | ||
801 | /* Find the first occurrence in the character string STRING of any character | ||
802 | in the character string ACCEPT. Return the number of bytes from the | ||
803 | beginning of the string to this occurrence, or to the end of the string | ||
804 | if none exists. | ||
805 | Unlike strcspn(), this function works correctly in multibyte locales. */ | ||
806 | _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) | ||
807 | _GL_ARG_NONNULL ((1, 2)); | ||
808 | #endif | ||
809 | |||
810 | #if @GNULIB_MBSPBRK@ | ||
811 | /* Find the first occurrence in the character string STRING of any character | ||
812 | in the character string ACCEPT. Return the pointer to it, or NULL if none | ||
813 | exists. | ||
814 | Unlike strpbrk(), this function works correctly in multibyte locales. */ | ||
815 | # if defined __hpux | ||
816 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
817 | # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ | ||
818 | # endif | ||
819 | _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) | ||
820 | _GL_ARG_NONNULL ((1, 2))); | ||
821 | _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); | ||
822 | # else | ||
823 | _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) | ||
824 | _GL_ARG_NONNULL ((1, 2))); | ||
825 | _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); | ||
826 | # endif | ||
827 | _GL_CXXALIASWARN (mbspbrk); | ||
828 | #endif | ||
829 | |||
830 | #if @GNULIB_MBSSPN@ | ||
831 | /* Find the first occurrence in the character string STRING of any character | ||
832 | not in the character string REJECT. Return the number of bytes from the | ||
833 | beginning of the string to this occurrence, or to the end of the string | ||
834 | if none exists. | ||
835 | Unlike strspn(), this function works correctly in multibyte locales. */ | ||
836 | _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject) | ||
837 | _GL_ARG_NONNULL ((1, 2)); | ||
838 | #endif | ||
839 | |||
840 | #if @GNULIB_MBSSEP@ | ||
841 | /* Search the next delimiter (multibyte character listed in the character | ||
842 | string DELIM) starting at the character string *STRINGP. | ||
843 | If one is found, overwrite it with a NUL, and advance *STRINGP to point | ||
844 | to the next multibyte character after it. Otherwise, set *STRINGP to NULL. | ||
845 | If *STRINGP was already NULL, nothing happens. | ||
846 | Return the old value of *STRINGP. | ||
847 | |||
848 | This is a variant of mbstok_r() that supports empty fields. | ||
849 | |||
850 | Caveat: It modifies the original string. | ||
851 | Caveat: These functions cannot be used on constant strings. | ||
852 | Caveat: The identity of the delimiting character is lost. | ||
853 | |||
854 | See also mbstok_r(). */ | ||
855 | _GL_EXTERN_C char * mbssep (char **stringp, const char *delim) | ||
856 | _GL_ARG_NONNULL ((1, 2)); | ||
857 | #endif | ||
858 | |||
859 | #if @GNULIB_MBSTOK_R@ | ||
860 | /* Parse the character string STRING into tokens separated by characters in | ||
861 | the character string DELIM. | ||
862 | If STRING is NULL, the saved pointer in SAVE_PTR is used as | ||
863 | the next starting point. For example: | ||
864 | char s[] = "-abc-=-def"; | ||
865 | char *sp; | ||
866 | x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" | ||
867 | x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL | ||
868 | x = mbstok_r(NULL, "=", &sp); // x = NULL | ||
869 | // s = "abc\0-def\0" | ||
870 | |||
871 | Caveat: It modifies the original string. | ||
872 | Caveat: These functions cannot be used on constant strings. | ||
873 | Caveat: The identity of the delimiting character is lost. | ||
874 | |||
875 | See also mbssep(). */ | ||
876 | _GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr) | ||
877 | _GL_ARG_NONNULL ((2, 3)); | ||
878 | #endif | ||
879 | |||
880 | /* Map any int, typically from errno, into an error message. */ | ||
881 | #if @GNULIB_STRERROR@ | ||
882 | # if @REPLACE_STRERROR@ | ||
883 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
884 | # undef strerror | ||
885 | # define strerror rpl_strerror | ||
886 | # endif | ||
887 | _GL_FUNCDECL_RPL (strerror, char *, (int)); | ||
888 | _GL_CXXALIAS_RPL (strerror, char *, (int)); | ||
889 | # else | ||
890 | _GL_CXXALIAS_SYS (strerror, char *, (int)); | ||
891 | # endif | ||
892 | _GL_CXXALIASWARN (strerror); | ||
893 | #elif defined GNULIB_POSIXCHECK | ||
894 | # undef strerror | ||
895 | /* Assume strerror is always declared. */ | ||
896 | _GL_WARN_ON_USE (strerror, "strerror is unportable - " | ||
897 | "use gnulib module strerror to guarantee non-NULL result"); | ||
898 | #endif | ||
899 | |||
900 | /* Map any int, typically from errno, into an error message. Multithread-safe. | ||
901 | Uses the POSIX declaration, not the glibc declaration. */ | ||
902 | #if @GNULIB_STRERROR_R@ | ||
903 | # if @REPLACE_STRERROR_R@ | ||
904 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
905 | # undef strerror_r | ||
906 | # define strerror_r rpl_strerror_r | ||
907 | # endif | ||
908 | _GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) | ||
909 | _GL_ARG_NONNULL ((2))); | ||
910 | _GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); | ||
911 | # else | ||
912 | # if !@HAVE_DECL_STRERROR_R@ | ||
913 | _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) | ||
914 | _GL_ARG_NONNULL ((2))); | ||
915 | # endif | ||
916 | _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); | ||
917 | # endif | ||
918 | # if @HAVE_DECL_STRERROR_R@ | ||
919 | _GL_CXXALIASWARN (strerror_r); | ||
920 | # endif | ||
921 | #elif defined GNULIB_POSIXCHECK | ||
922 | # undef strerror_r | ||
923 | # if HAVE_RAW_DECL_STRERROR_R | ||
924 | _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " | ||
925 | "use gnulib module strerror_r-posix for portability"); | ||
926 | # endif | ||
927 | #endif | ||
928 | |||
929 | #if @GNULIB_STRSIGNAL@ | ||
930 | # if @REPLACE_STRSIGNAL@ | ||
931 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
932 | # define strsignal rpl_strsignal | ||
933 | # endif | ||
934 | _GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); | ||
935 | _GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); | ||
936 | # else | ||
937 | # if ! @HAVE_DECL_STRSIGNAL@ | ||
938 | _GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); | ||
939 | # endif | ||
940 | /* Need to cast, because on Cygwin 1.5.x systems, the return type is | ||
941 | 'const char *'. */ | ||
942 | _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig)); | ||
943 | # endif | ||
944 | _GL_CXXALIASWARN (strsignal); | ||
945 | #elif defined GNULIB_POSIXCHECK | ||
946 | # undef strsignal | ||
947 | # if HAVE_RAW_DECL_STRSIGNAL | ||
948 | _GL_WARN_ON_USE (strsignal, "strsignal is unportable - " | ||
949 | "use gnulib module strsignal for portability"); | ||
950 | # endif | ||
951 | #endif | ||
952 | |||
953 | #if @GNULIB_STRVERSCMP@ | ||
954 | # if !@HAVE_STRVERSCMP@ | ||
955 | _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) | ||
956 | _GL_ARG_NONNULL ((1, 2))); | ||
957 | # endif | ||
958 | _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); | ||
959 | _GL_CXXALIASWARN (strverscmp); | ||
960 | #elif defined GNULIB_POSIXCHECK | ||
961 | # undef strverscmp | ||
962 | # if HAVE_RAW_DECL_STRVERSCMP | ||
963 | _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " | ||
964 | "use gnulib module strverscmp for portability"); | ||
965 | # endif | ||
966 | #endif | ||
967 | |||
968 | |||
969 | #endif /* _GL_STRING_H */ | ||
970 | #endif /* _GL_STRING_H */ | ||
diff --git a/src/util/libgnu/strtok_r.c b/src/util/libgnu/strtok_r.c new file mode 100644 index 000000000..789c95c79 --- /dev/null +++ b/src/util/libgnu/strtok_r.c | |||
@@ -0,0 +1,76 @@ | |||
1 | /* Reentrant string tokenizer. Generic version. | ||
2 | Copyright (C) 1991, 1996-1999, 2001, 2004, 2007, 2009-2011 Free Software | ||
3 | Foundation, Inc. | ||
4 | This file is part of the GNU C Library. | ||
5 | |||
6 | This program is free software: you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; either version 3 of the License, or | ||
9 | (at your option) any later version. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <gnunet_config.h> | ||
21 | #endif | ||
22 | |||
23 | #include <string.h> | ||
24 | |||
25 | #ifdef _LIBC | ||
26 | # undef strtok_r | ||
27 | # undef __strtok_r | ||
28 | #else | ||
29 | # define __strtok_r strtok_r | ||
30 | # define __rawmemchr strchr | ||
31 | #endif | ||
32 | |||
33 | /* Parse S into tokens separated by characters in DELIM. | ||
34 | If S is NULL, the saved pointer in SAVE_PTR is used as | ||
35 | the next starting point. For example: | ||
36 | char s[] = "-abc-=-def"; | ||
37 | char *sp; | ||
38 | x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" | ||
39 | x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL | ||
40 | x = strtok_r(NULL, "=", &sp); // x = NULL | ||
41 | // s = "abc\0-def\0" | ||
42 | */ | ||
43 | char * | ||
44 | __strtok_r (char *s, const char *delim, char **save_ptr) | ||
45 | { | ||
46 | char *token; | ||
47 | |||
48 | if (s == NULL) | ||
49 | s = *save_ptr; | ||
50 | |||
51 | /* Scan leading delimiters. */ | ||
52 | s += strspn (s, delim); | ||
53 | if (*s == '\0') | ||
54 | { | ||
55 | *save_ptr = s; | ||
56 | return NULL; | ||
57 | } | ||
58 | |||
59 | /* Find the end of the token. */ | ||
60 | token = s; | ||
61 | s = strpbrk (token, delim); | ||
62 | if (s == NULL) | ||
63 | /* This token finishes the string. */ | ||
64 | *save_ptr = __rawmemchr (token, '\0'); | ||
65 | else | ||
66 | { | ||
67 | /* Terminate the token and make *SAVE_PTR point past it. */ | ||
68 | *s = '\0'; | ||
69 | *save_ptr = s + 1; | ||
70 | } | ||
71 | return token; | ||
72 | } | ||
73 | #ifdef weak_alias | ||
74 | libc_hidden_def (__strtok_r) | ||
75 | weak_alias (__strtok_r, strtok_r) | ||
76 | #endif | ||
diff --git a/warn-on-use.h b/warn-on-use.h new file mode 100644 index 000000000..2cdeec3e6 --- /dev/null +++ b/warn-on-use.h | |||
@@ -0,0 +1,109 @@ | |||
1 | /* A C macro for emitting warnings if a function is used. | ||
2 | Copyright (C) 2010-2011 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify it | ||
5 | under the terms of the GNU General Public License as published | ||
6 | by the Free Software Foundation; either version 3 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | /* _GL_WARN_ON_USE (function, "literal string") issues a declaration | ||
18 | for FUNCTION which will then trigger a compiler warning containing | ||
19 | the text of "literal string" anywhere that function is called, if | ||
20 | supported by the compiler. If the compiler does not support this | ||
21 | feature, the macro expands to an unused extern declaration. | ||
22 | |||
23 | This macro is useful for marking a function as a potential | ||
24 | portability trap, with the intent that "literal string" include | ||
25 | instructions on the replacement function that should be used | ||
26 | instead. However, one of the reasons that a function is a | ||
27 | portability trap is if it has the wrong signature. Declaring | ||
28 | FUNCTION with a different signature in C is a compilation error, so | ||
29 | this macro must use the same type as any existing declaration so | ||
30 | that programs that avoid the problematic FUNCTION do not fail to | ||
31 | compile merely because they included a header that poisoned the | ||
32 | function. But this implies that _GL_WARN_ON_USE is only safe to | ||
33 | use if FUNCTION is known to already have a declaration. Use of | ||
34 | this macro implies that there must not be any other macro hiding | ||
35 | the declaration of FUNCTION; but undefining FUNCTION first is part | ||
36 | of the poisoning process anyway (although for symbols that are | ||
37 | provided only via a macro, the result is a compilation error rather | ||
38 | than a warning containing "literal string"). Also note that in | ||
39 | C++, it is only safe to use if FUNCTION has no overloads. | ||
40 | |||
41 | For an example, it is possible to poison 'getline' by: | ||
42 | - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], | ||
43 | [getline]) in configure.ac, which potentially defines | ||
44 | HAVE_RAW_DECL_GETLINE | ||
45 | - adding this code to a header that wraps the system <stdio.h>: | ||
46 | #undef getline | ||
47 | #if HAVE_RAW_DECL_GETLINE | ||
48 | _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" | ||
49 | "not universally present; use the gnulib module getline"); | ||
50 | #endif | ||
51 | |||
52 | It is not possible to directly poison global variables. But it is | ||
53 | possible to write a wrapper accessor function, and poison that | ||
54 | (less common usage, like &environ, will cause a compilation error | ||
55 | rather than issue the nice warning, but the end result of informing | ||
56 | the developer about their portability problem is still achieved): | ||
57 | #if HAVE_RAW_DECL_ENVIRON | ||
58 | static inline char ***rpl_environ (void) { return &environ; } | ||
59 | _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); | ||
60 | # undef environ | ||
61 | # define environ (*rpl_environ ()) | ||
62 | #endif | ||
63 | */ | ||
64 | #ifndef _GL_WARN_ON_USE | ||
65 | |||
66 | # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) | ||
67 | /* A compiler attribute is available in gcc versions 4.3.0 and later. */ | ||
68 | # define _GL_WARN_ON_USE(function, message) \ | ||
69 | extern __typeof__ (function) function __attribute__ ((__warning__ (message))) | ||
70 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||
71 | /* Verify the existence of the function. */ | ||
72 | # define _GL_WARN_ON_USE(function, message) \ | ||
73 | extern __typeof__ (function) function | ||
74 | # else /* Unsupported. */ | ||
75 | # define _GL_WARN_ON_USE(function, message) \ | ||
76 | _GL_WARN_EXTERN_C int _gl_warn_on_use | ||
77 | # endif | ||
78 | #endif | ||
79 | |||
80 | /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") | ||
81 | is like _GL_WARN_ON_USE (function, "string"), except that the function is | ||
82 | declared with the given prototype, consisting of return type, parameters, | ||
83 | and attributes. | ||
84 | This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does | ||
85 | not work in this case. */ | ||
86 | #ifndef _GL_WARN_ON_USE_CXX | ||
87 | # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) | ||
88 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ | ||
89 | extern rettype function parameters_and_attributes \ | ||
90 | __attribute__ ((__warning__ (msg))) | ||
91 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||
92 | /* Verify the existence of the function. */ | ||
93 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ | ||
94 | extern rettype function parameters_and_attributes | ||
95 | # else /* Unsupported. */ | ||
96 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ | ||
97 | _GL_WARN_EXTERN_C int _gl_warn_on_use | ||
98 | # endif | ||
99 | #endif | ||
100 | |||
101 | /* _GL_WARN_EXTERN_C declaration; | ||
102 | performs the declaration with C linkage. */ | ||
103 | #ifndef _GL_WARN_EXTERN_C | ||
104 | # if defined __cplusplus | ||
105 | # define _GL_WARN_EXTERN_C extern "C" | ||
106 | # else | ||
107 | # define _GL_WARN_EXTERN_C extern | ||
108 | # endif | ||
109 | #endif | ||