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