1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* A substitute <strings.h>.
3
4 Copyright (C) 2007-2013 Free Software Foundation, Inc.
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, or (at your option)
9 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#ifndef _GL_STRINGS_H
20
21#if __GNUC__ >= 3
22#pragma GCC system_header
23#endif
24
25
26/* Minix 3.1.8 has a bug: <sys/types.h> must be included before <strings.h>.
27 But avoid namespace pollution on glibc systems. */
28#if defined __minix && !defined __GLIBC__
29# include <sys/types.h>
30#endif
31
32/* The include_next requires a split double-inclusion guard. */
33#if 1
34# include_next <strings.h>
35#endif
36
37#ifndef _GL_STRINGS_H
38#define _GL_STRINGS_H
39
40#if ! 1
41/* Get size_t. */
42# include <stddef.h>
43#endif
44
45
46/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
47#ifndef _GL_CXXDEFS_H
48#define _GL_CXXDEFS_H
49
50/* The three most frequent use cases of these macros are:
51
52 * For providing a substitute for a function that is missing on some
53 platforms, but is declared and works fine on the platforms on which
54 it exists:
55
56 #if @GNULIB_FOO@
57 # if !@HAVE_FOO@
58 _GL_FUNCDECL_SYS (foo, ...);
59 # endif
60 _GL_CXXALIAS_SYS (foo, ...);
61 _GL_CXXALIASWARN (foo);
62 #elif defined GNULIB_POSIXCHECK
63 ...
64 #endif
65
66 * For providing a replacement for a function that exists on all platforms,
67 but is broken/insufficient and needs to be replaced on some platforms:
68
69 #if @GNULIB_FOO@
70 # if @REPLACE_FOO@
71 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
72 # undef foo
73 # define foo rpl_foo
74 # endif
75 _GL_FUNCDECL_RPL (foo, ...);
76 _GL_CXXALIAS_RPL (foo, ...);
77 # else
78 _GL_CXXALIAS_SYS (foo, ...);
79 # endif
80 _GL_CXXALIASWARN (foo);
81 #elif defined GNULIB_POSIXCHECK
82 ...
83 #endif
84
85 * For providing a replacement for a function that exists on some platforms
86 but is broken/insufficient and needs to be replaced on some of them and
87 is additionally either missing or undeclared on some other platforms:
88
89 #if @GNULIB_FOO@
90 # if @REPLACE_FOO@
91 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
92 # undef foo
93 # define foo rpl_foo
94 # endif
95 _GL_FUNCDECL_RPL (foo, ...);
96 _GL_CXXALIAS_RPL (foo, ...);
97 # else
98 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
99 _GL_FUNCDECL_SYS (foo, ...);
100 # endif
101 _GL_CXXALIAS_SYS (foo, ...);
102 # endif
103 _GL_CXXALIASWARN (foo);
104 #elif defined GNULIB_POSIXCHECK
105 ...
106 #endif
107*/
108
109/* _GL_EXTERN_C declaration;
110 performs the declaration with C linkage. */
111#if defined __cplusplus
112# define _GL_EXTERN_C extern "C"
113#else
114# define _GL_EXTERN_C extern
115#endif
116
117/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
118 declares a replacement function, named rpl_func, with the given prototype,
119 consisting of return type, parameters, and attributes.
120 Example:
121 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
122 _GL_ARG_NONNULL ((1)));
123 */
124#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
125 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
126#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
127 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
128
129/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
130 declares the system function, named func, with the given prototype,
131 consisting of return type, parameters, and attributes.
132 Example:
133 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
134 _GL_ARG_NONNULL ((1)));
135 */
136#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
137 _GL_EXTERN_C rettype func parameters_and_attributes
138
139/* _GL_CXXALIAS_RPL (func, rettype, parameters);
140 declares a C++ alias called GNULIB_NAMESPACE::func
141 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
142 Example:
143 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
144 */
145#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
146 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
147#if defined __cplusplus && defined GNULIB_NAMESPACE
148# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
149 namespace GNULIB_NAMESPACE \
150 { \
151 rettype (*const func) parameters = ::rpl_func; \
152 } \
153 _GL_EXTERN_C int _gl_cxxalias_dummy
154#else
155# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
156 _GL_EXTERN_C int _gl_cxxalias_dummy
157#endif
158
159/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
160 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
161 except that the C function rpl_func may have a slightly different
162 declaration. A cast is used to silence the "invalid conversion" error
163 that would otherwise occur. */
164#if defined __cplusplus && defined GNULIB_NAMESPACE
165# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
166 namespace GNULIB_NAMESPACE \
167 { \
168 rettype (*const func) parameters = \
169 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
170 } \
171 _GL_EXTERN_C int _gl_cxxalias_dummy
172#else
173# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
174 _GL_EXTERN_C int _gl_cxxalias_dummy
175#endif
176
177/* _GL_CXXALIAS_SYS (func, rettype, parameters);
178 declares a C++ alias called GNULIB_NAMESPACE::func
179 that redirects to the system provided function func, if GNULIB_NAMESPACE
180 is defined.
181 Example:
182 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
183 */
184#if defined __cplusplus && defined GNULIB_NAMESPACE
185 /* If we were to write
186 rettype (*const func) parameters = ::func;
187 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
188 better (remove an indirection through a 'static' pointer variable),
189 but then the _GL_CXXALIASWARN macro below would cause a warning not only
190 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
191# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
192 namespace GNULIB_NAMESPACE \
193 { \
194 static rettype (*func) parameters = ::func; \
195 } \
196 _GL_EXTERN_C int _gl_cxxalias_dummy
197#else
198# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
199 _GL_EXTERN_C int _gl_cxxalias_dummy
200#endif
201
202/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
203 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
204 except that the C function func may have a slightly different declaration.
205 A cast is used to silence the "invalid conversion" error that would
206 otherwise occur. */
207#if defined __cplusplus && defined GNULIB_NAMESPACE
208# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
209 namespace GNULIB_NAMESPACE \
210 { \
211 static rettype (*func) parameters = \
212 reinterpret_cast<rettype(*)parameters>(::func); \
213 } \
214 _GL_EXTERN_C int _gl_cxxalias_dummy
215#else
216# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
217 _GL_EXTERN_C int _gl_cxxalias_dummy
218#endif
219
220/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
221 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
222 except that the C function is picked among a set of overloaded functions,
223 namely the one with rettype2 and parameters2. Two consecutive casts
224 are used to silence the "cannot find a match" and "invalid conversion"
225 errors that would otherwise occur. */
226#if defined __cplusplus && defined GNULIB_NAMESPACE
227 /* The outer cast must be a reinterpret_cast.
228 The inner cast: When the function is defined as a set of overloaded
229 functions, it works as a static_cast<>, choosing the designated variant.
230 When the function is defined as a single variant, it works as a
231 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
232# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
233 namespace GNULIB_NAMESPACE \
234 { \
235 static rettype (*func) parameters = \
236 reinterpret_cast<rettype(*)parameters>( \
237 (rettype2(*)parameters2)(::func)); \
238 } \
239 _GL_EXTERN_C int _gl_cxxalias_dummy
240#else
241# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
242 _GL_EXTERN_C int _gl_cxxalias_dummy
243#endif
244
245/* _GL_CXXALIASWARN (func);
246 causes a warning to be emitted when ::func is used but not when
247 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
248 variants. */
249#if defined __cplusplus && defined GNULIB_NAMESPACE
250# define _GL_CXXALIASWARN(func) \
251 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
252# define _GL_CXXALIASWARN_1(func,namespace) \
253 _GL_CXXALIASWARN_2 (func, namespace)
254/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
255 we enable the warning only when not optimizing. */
256# if !__OPTIMIZE__
257# define _GL_CXXALIASWARN_2(func,namespace) \
258 _GL_WARN_ON_USE (func, \
259 "The symbol ::" #func " refers to the system function. " \
260 "Use " #namespace "::" #func " instead.")
261# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
262# define _GL_CXXALIASWARN_2(func,namespace) \
263 extern __typeof__ (func) func
264# else
265# define _GL_CXXALIASWARN_2(func,namespace) \
266 _GL_EXTERN_C int _gl_cxxalias_dummy
267# endif
268#else
269# define _GL_CXXALIASWARN(func) \
270 _GL_EXTERN_C int _gl_cxxalias_dummy
271#endif
272
273/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
274 causes a warning to be emitted when the given overloaded variant of ::func
275 is used but not when GNULIB_NAMESPACE::func is used. */
276#if defined __cplusplus && defined GNULIB_NAMESPACE
277# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
278 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
279 GNULIB_NAMESPACE)
280# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
281 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
282/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
283 we enable the warning only when not optimizing. */
284# if !__OPTIMIZE__
285# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
286 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
287 "The symbol ::" #func " refers to the system function. " \
288 "Use " #namespace "::" #func " instead.")
289# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
290# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
291 extern __typeof__ (func) func
292# else
293# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
294 _GL_EXTERN_C int _gl_cxxalias_dummy
295# endif
296#else
297# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
298 _GL_EXTERN_C int _gl_cxxalias_dummy
299#endif
300
301#endif /* _GL_CXXDEFS_H */
302
303/* The definition of _GL_ARG_NONNULL is copied here. */
304/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
305 that the values passed as arguments n, ..., m must be non-NULL pointers.
306 n = 1 stands for the first argument, n = 2 for the second argument etc. */
307#ifndef _GL_ARG_NONNULL
308# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
309# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
310# else
311# define _GL_ARG_NONNULL(params)
312# endif
313#endif
314
315/* The definition of _GL_WARN_ON_USE is copied here. */
316#ifndef _GL_WARN_ON_USE
317
318# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
319/* A compiler attribute is available in gcc versions 4.3.0 and later. */
320# define _GL_WARN_ON_USE(function, message) \
321extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
322# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
323/* Verify the existence of the function. */
324# define _GL_WARN_ON_USE(function, message) \
325extern __typeof__ (function) function
326# else /* Unsupported. */
327# define _GL_WARN_ON_USE(function, message) \
328_GL_WARN_EXTERN_C int _gl_warn_on_use
329# endif
330#endif
331
332/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
333 is like _GL_WARN_ON_USE (function, "string"), except that the function is
334 declared with the given prototype, consisting of return type, parameters,
335 and attributes.
336 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
337 not work in this case. */
338#ifndef _GL_WARN_ON_USE_CXX
339# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
340# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
341extern rettype function parameters_and_attributes \
342 __attribute__ ((__warning__ (msg)))
343# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
344/* Verify the existence of the function. */
345# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
346extern rettype function parameters_and_attributes
347# else /* Unsupported. */
348# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
349_GL_WARN_EXTERN_C int _gl_warn_on_use
350# endif
351#endif
352
353/* _GL_WARN_EXTERN_C declaration;
354 performs the declaration with C linkage. */
355#ifndef _GL_WARN_EXTERN_C
356# if defined __cplusplus
357# define _GL_WARN_EXTERN_C extern "C"
358# else
359# define _GL_WARN_EXTERN_C extern
360# endif
361#endif
362
363#ifdef __cplusplus
364extern "C" {
365#endif
366
367
368 /* Find the index of the least-significant set bit. */
369#if 0
370# if !1
371_GL_FUNCDECL_SYS (ffs, int, (int i));
372# endif
373_GL_CXXALIAS_SYS (ffs, int, (int i));
374_GL_CXXALIASWARN (ffs);
375#elif defined GNULIB_POSIXCHECK
376# undef ffs
377# if HAVE_RAW_DECL_FFS
378_GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module");
379# endif
380#endif
381
382/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
383 greater than zero if S1 is lexicographically less than, equal to or greater
384 than S2.
385 Note: This function does not work in multibyte locales. */
386#if ! 1
387extern int strcasecmp (char const *s1, char const *s2)
388 _GL_ARG_NONNULL ((1, 2));
389#endif
390#if defined GNULIB_POSIXCHECK
391/* strcasecmp() does not work with multibyte strings:
392 POSIX says that it operates on "strings", and "string" in POSIX is defined
393 as a sequence of bytes, not of characters. */
394# undef strcasecmp
395# if HAVE_RAW_DECL_STRCASECMP
396_GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
397 "strings in multibyte locales - "
398 "use mbscasecmp if you care about "
399 "internationalization, or use c_strcasecmp , "
400 "gnulib module c-strcase) if you want a locale "
401 "independent function");
402# endif
403#endif
404
405/* Compare no more than N bytes of strings S1 and S2, ignoring case,
406 returning less than, equal to or greater than zero if S1 is
407 lexicographically less than, equal to or greater than S2.
408 Note: This function cannot work correctly in multibyte locales. */
409#if ! 1
410extern int strncasecmp (char const *s1, char const *s2, size_t n)
411 _GL_ARG_NONNULL ((1, 2));
412#endif
413#if defined GNULIB_POSIXCHECK
414/* strncasecmp() does not work with multibyte strings:
415 POSIX says that it operates on "strings", and "string" in POSIX is defined
416 as a sequence of bytes, not of characters. */
417# undef strncasecmp
418# if HAVE_RAW_DECL_STRNCASECMP
419_GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
420 "strings in multibyte locales - "
421 "use mbsncasecmp or mbspcasecmp if you care about "
422 "internationalization, or use c_strncasecmp , "
423 "gnulib module c-strcase) if you want a locale "
424 "independent function");
425# endif
426#endif
427
428
429#ifdef __cplusplus
430}
431#endif
432
433#endif /* _GL_STRING_H */
434#endif /* _GL_STRING_H */
435