1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A GNU-like <string.h>.
3 
4    Copyright (C) 1995-1996, 2001-2018 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 <https://www.gnu.org/licenses/>.  */
18 
19 #if __GNUC__ >= 3
20 #pragma GCC system_header
21 #endif
22 
23 
24 #if defined _GL_ALREADY_INCLUDING_STRING_H
25 /* Special invocation convention:
26    - On OS X/NetBSD we have a sequence of nested includes
27        <string.h> -> <strings.h> -> "string.h"
28      In this situation system _chk variants due to -D_FORTIFY_SOURCE
29      might be used after any replacements defined here.  */
30 
31 #include_next <string.h>
32 
33 #else
34 /* Normal invocation convention.  */
35 
36 #ifndef _GL_STRING_H
37 
38 #define _GL_ALREADY_INCLUDING_STRING_H
39 
40 /* The include_next requires a split double-inclusion guard.  */
41 #include_next <string.h>
42 
43 #undef _GL_ALREADY_INCLUDING_STRING_H
44 
45 #ifndef _GL_STRING_H
46 #define _GL_STRING_H
47 
48 /* NetBSD 5.0 mis-defines NULL.  */
49 #include <stddef.h>
50 
51 /* MirBSD defines mbslen as a macro.  */
52 #if 1 && defined __MirBSD__
53 # include <wchar.h>
54 #endif
55 
56 /* The __attribute__ feature is available in gcc versions 2.5 and later.
57    The attribute __pure__ was added in gcc 2.96.  */
58 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
59 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
60 #else
61 # define _GL_ATTRIBUTE_PURE /* empty */
62 #endif
63 
64 /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>.  */
65 /* But in any case avoid namespace pollution on glibc systems.  */
66 #if (0 || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
67     && ! defined __GLIBC__
68 # include <unistd.h>
69 #endif
70 
71 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
72 /* C++ compatible function declaration macros.
73    Copyright (C) 2010-2018 Free Software Foundation, Inc.
74 
75    This program is free software: you can redistribute it and/or modify it
76    under the terms of the GNU General Public License as published
77    by the Free Software Foundation; either version 3 of the License, or
78    (at your option) any later version.
79 
80    This program is distributed in the hope that it will be useful,
81    but WITHOUT ANY WARRANTY; without even the implied warranty of
82    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
83    General Public License for more details.
84 
85    You should have received a copy of the GNU General Public License
86    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
87 
88 #ifndef _GL_CXXDEFS_H
89 #define _GL_CXXDEFS_H
90 
91 /* Begin/end the GNULIB_NAMESPACE namespace.  */
92 #if defined __cplusplus && defined GNULIB_NAMESPACE
93 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
94 # define _GL_END_NAMESPACE }
95 #else
96 # define _GL_BEGIN_NAMESPACE
97 # define _GL_END_NAMESPACE
98 #endif
99 
100 /* The three most frequent use cases of these macros are:
101 
102    * For providing a substitute for a function that is missing on some
103      platforms, but is declared and works fine on the platforms on which
104      it exists:
105 
106        #if @GNULIB_FOO@
107        # if !@HAVE_FOO@
108        _GL_FUNCDECL_SYS (foo, ...);
109        # endif
110        _GL_CXXALIAS_SYS (foo, ...);
111        _GL_CXXALIASWARN (foo);
112        #elif defined GNULIB_POSIXCHECK
113        ...
114        #endif
115 
116    * For providing a replacement for a function that exists on all platforms,
117      but is broken/insufficient and needs to be replaced on some platforms:
118 
119        #if @GNULIB_FOO@
120        # if @REPLACE_FOO@
121        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
122        #   undef foo
123        #   define foo rpl_foo
124        #  endif
125        _GL_FUNCDECL_RPL (foo, ...);
126        _GL_CXXALIAS_RPL (foo, ...);
127        # else
128        _GL_CXXALIAS_SYS (foo, ...);
129        # endif
130        _GL_CXXALIASWARN (foo);
131        #elif defined GNULIB_POSIXCHECK
132        ...
133        #endif
134 
135    * For providing a replacement for a function that exists on some platforms
136      but is broken/insufficient and needs to be replaced on some of them and
137      is additionally either missing or undeclared on some other platforms:
138 
139        #if @GNULIB_FOO@
140        # if @REPLACE_FOO@
141        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
142        #   undef foo
143        #   define foo rpl_foo
144        #  endif
145        _GL_FUNCDECL_RPL (foo, ...);
146        _GL_CXXALIAS_RPL (foo, ...);
147        # else
148        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
149        _GL_FUNCDECL_SYS (foo, ...);
150        #  endif
151        _GL_CXXALIAS_SYS (foo, ...);
152        # endif
153        _GL_CXXALIASWARN (foo);
154        #elif defined GNULIB_POSIXCHECK
155        ...
156        #endif
157 */
158 
159 /* _GL_EXTERN_C declaration;
160    performs the declaration with C linkage.  */
161 #if defined __cplusplus
162 # define _GL_EXTERN_C extern "C"
163 #else
164 # define _GL_EXTERN_C extern
165 #endif
166 
167 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
168    declares a replacement function, named rpl_func, with the given prototype,
169    consisting of return type, parameters, and attributes.
170    Example:
171      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
172                                   _GL_ARG_NONNULL ((1)));
173  */
174 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
175   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
176 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
177   _GL_EXTERN_C rettype rpl_func parameters_and_attributes
178 
179 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
180    declares the system function, named func, with the given prototype,
181    consisting of return type, parameters, and attributes.
182    Example:
183      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
184                                   _GL_ARG_NONNULL ((1)));
185  */
186 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
187   _GL_EXTERN_C rettype func parameters_and_attributes
188 
189 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
190    declares a C++ alias called GNULIB_NAMESPACE::func
191    that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
192    Example:
193      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
194 
195    Wrapping rpl_func in an object with an inline conversion operator
196    avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
197    actually used in the program.  */
198 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
199   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
200 #if defined __cplusplus && defined GNULIB_NAMESPACE
201 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
202     namespace GNULIB_NAMESPACE                                \
203     {                                                         \
204       static const struct _gl_ ## func ## _wrapper            \
205       {                                                       \
206         typedef rettype (*type) parameters;                   \
207                                                               \
208         inline operator type () const                         \
209         {                                                     \
210           return ::rpl_func;                                  \
211         }                                                     \
212       } func = {};                                            \
213     }                                                         \
214     _GL_EXTERN_C int _gl_cxxalias_dummy
215 #else
216 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
217     _GL_EXTERN_C int _gl_cxxalias_dummy
218 #endif
219 
220 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
221    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
222    except that the C function rpl_func may have a slightly different
223    declaration.  A cast is used to silence the "invalid conversion" error
224    that would otherwise occur.  */
225 #if defined __cplusplus && defined GNULIB_NAMESPACE
226 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
227     namespace GNULIB_NAMESPACE                                     \
228     {                                                              \
229       static const struct _gl_ ## func ## _wrapper                 \
230       {                                                            \
231         typedef rettype (*type) parameters;                        \
232                                                                    \
233         inline operator type () const                              \
234         {                                                          \
235           return reinterpret_cast<type>(::rpl_func);               \
236         }                                                          \
237       } func = {};                                                 \
238     }                                                              \
239     _GL_EXTERN_C int _gl_cxxalias_dummy
240 #else
241 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
242     _GL_EXTERN_C int _gl_cxxalias_dummy
243 #endif
244 
245 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
246    declares a C++ alias called GNULIB_NAMESPACE::func
247    that redirects to the system provided function func, if GNULIB_NAMESPACE
248    is defined.
249    Example:
250      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
251 
252    Wrapping func in an object with an inline conversion operator
253    avoids a reference to func unless GNULIB_NAMESPACE::func is
254    actually used in the program.  */
255 #if defined __cplusplus && defined GNULIB_NAMESPACE
256 # define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
257     namespace GNULIB_NAMESPACE                                \
258     {                                                         \
259       static const struct _gl_ ## func ## _wrapper            \
260       {                                                       \
261         typedef rettype (*type) parameters;                   \
262                                                               \
263         inline operator type () const                         \
264         {                                                     \
265           return ::func;                                      \
266         }                                                     \
267       } func = {};                                            \
268     }                                                         \
269     _GL_EXTERN_C int _gl_cxxalias_dummy
270 #else
271 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
272     _GL_EXTERN_C int _gl_cxxalias_dummy
273 #endif
274 
275 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
276    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
277    except that the C function func may have a slightly different declaration.
278    A cast is used to silence the "invalid conversion" error that would
279    otherwise occur.  */
280 #if defined __cplusplus && defined GNULIB_NAMESPACE
281 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
282     namespace GNULIB_NAMESPACE                          \
283     {                                                   \
284       static const struct _gl_ ## func ## _wrapper      \
285       {                                                 \
286         typedef rettype (*type) parameters;             \
287                                                         \
288         inline operator type () const                   \
289         {                                               \
290           return reinterpret_cast<type>(::func);        \
291         }                                               \
292       } func = {};                                      \
293     }                                                   \
294     _GL_EXTERN_C int _gl_cxxalias_dummy
295 #else
296 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
297     _GL_EXTERN_C int _gl_cxxalias_dummy
298 #endif
299 
300 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
301    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
302    except that the C function is picked among a set of overloaded functions,
303    namely the one with rettype2 and parameters2.  Two consecutive casts
304    are used to silence the "cannot find a match" and "invalid conversion"
305    errors that would otherwise occur.  */
306 #if defined __cplusplus && defined GNULIB_NAMESPACE
307   /* The outer cast must be a reinterpret_cast.
308      The inner cast: When the function is defined as a set of overloaded
309      functions, it works as a static_cast<>, choosing the designated variant.
310      When the function is defined as a single variant, it works as a
311      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
312 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
313     namespace GNULIB_NAMESPACE                                                \
314     {                                                                         \
315       static const struct _gl_ ## func ## _wrapper                            \
316       {                                                                       \
317         typedef rettype (*type) parameters;                                   \
318                                                                               \
319         inline operator type () const                                         \
320         {                                                                     \
321           return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
322         }                                                                     \
323       } func = {};                                                            \
324     }                                                                         \
325     _GL_EXTERN_C int _gl_cxxalias_dummy
326 #else
327 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
328     _GL_EXTERN_C int _gl_cxxalias_dummy
329 #endif
330 
331 /* _GL_CXXALIASWARN (func);
332    causes a warning to be emitted when ::func is used but not when
333    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
334    variants.  */
335 #if defined __cplusplus && defined GNULIB_NAMESPACE
336 # define _GL_CXXALIASWARN(func) \
337    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
338 # define _GL_CXXALIASWARN_1(func,namespace) \
339    _GL_CXXALIASWARN_2 (func, namespace)
340 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
341    we enable the warning only when not optimizing.  */
342 # if !__OPTIMIZE__
343 #  define _GL_CXXALIASWARN_2(func,namespace) \
344     _GL_WARN_ON_USE (func, \
345                      "The symbol ::" #func " refers to the system function. " \
346                      "Use " #namespace "::" #func " instead.")
347 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
348 #  define _GL_CXXALIASWARN_2(func,namespace) \
349      extern __typeof__ (func) func
350 # else
351 #  define _GL_CXXALIASWARN_2(func,namespace) \
352      _GL_EXTERN_C int _gl_cxxalias_dummy
353 # endif
354 #else
355 # define _GL_CXXALIASWARN(func) \
356     _GL_EXTERN_C int _gl_cxxalias_dummy
357 #endif
358 
359 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
360    causes a warning to be emitted when the given overloaded variant of ::func
361    is used but not when GNULIB_NAMESPACE::func is used.  */
362 #if defined __cplusplus && defined GNULIB_NAMESPACE
363 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
364    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
365                         GNULIB_NAMESPACE)
366 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
367    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
368 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
369    we enable the warning only when not optimizing.  */
370 # if !__OPTIMIZE__
371 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
372     _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
373                          "The symbol ::" #func " refers to the system function. " \
374                          "Use " #namespace "::" #func " instead.")
375 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
376 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
377      extern __typeof__ (func) func
378 # else
379 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
380      _GL_EXTERN_C int _gl_cxxalias_dummy
381 # endif
382 #else
383 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
384     _GL_EXTERN_C int _gl_cxxalias_dummy
385 #endif
386 
387 #endif /* _GL_CXXDEFS_H */
388 
389 /* The definition of _GL_ARG_NONNULL is copied here.  */
390 /* A C macro for declaring that specific arguments must not be NULL.
391    Copyright (C) 2009-2018 Free Software Foundation, Inc.
392 
393    This program is free software: you can redistribute it and/or modify it
394    under the terms of the GNU General Public License as published
395    by the Free Software Foundation; either version 3 of the License, or
396    (at your option) any later version.
397 
398    This program is distributed in the hope that it will be useful,
399    but WITHOUT ANY WARRANTY; without even the implied warranty of
400    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
401    General Public License for more details.
402 
403    You should have received a copy of the GNU General Public License
404    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
405 
406 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
407    that the values passed as arguments n, ..., m must be non-NULL pointers.
408    n = 1 stands for the first argument, n = 2 for the second argument etc.  */
409 #ifndef _GL_ARG_NONNULL
410 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
411 #  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
412 # else
413 #  define _GL_ARG_NONNULL(params)
414 # endif
415 #endif
416 
417 /* The definition of _GL_WARN_ON_USE is copied here.  */
418 /* A C macro for emitting warnings if a function is used.
419    Copyright (C) 2010-2018 Free Software Foundation, Inc.
420 
421    This program is free software: you can redistribute it and/or modify it
422    under the terms of the GNU General Public License as published
423    by the Free Software Foundation; either version 3 of the License, or
424    (at your option) any later version.
425 
426    This program is distributed in the hope that it will be useful,
427    but WITHOUT ANY WARRANTY; without even the implied warranty of
428    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
429    General Public License for more details.
430 
431    You should have received a copy of the GNU General Public License
432    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
433 
434 /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
435    for FUNCTION which will then trigger a compiler warning containing
436    the text of "literal string" anywhere that function is called, if
437    supported by the compiler.  If the compiler does not support this
438    feature, the macro expands to an unused extern declaration.
439 
440    _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
441    attribute used in _GL_WARN_ON_USE.  If the compiler does not support
442    this feature, it expands to empty.
443 
444    These macros are useful for marking a function as a potential
445    portability trap, with the intent that "literal string" include
446    instructions on the replacement function that should be used
447    instead.
448    _GL_WARN_ON_USE is for functions with 'extern' linkage.
449    _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
450    linkage.
451 
452    However, one of the reasons that a function is a portability trap is
453    if it has the wrong signature.  Declaring FUNCTION with a different
454    signature in C is a compilation error, so this macro must use the
455    same type as any existing declaration so that programs that avoid
456    the problematic FUNCTION do not fail to compile merely because they
457    included a header that poisoned the function.  But this implies that
458    _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
459    have a declaration.  Use of this macro implies that there must not
460    be any other macro hiding the declaration of FUNCTION; but
461    undefining FUNCTION first is part of the poisoning process anyway
462    (although for symbols that are provided only via a macro, the result
463    is a compilation error rather than a warning containing
464    "literal string").  Also note that in C++, it is only safe to use if
465    FUNCTION has no overloads.
466 
467    For an example, it is possible to poison 'getline' by:
468    - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
469      [getline]) in configure.ac, which potentially defines
470      HAVE_RAW_DECL_GETLINE
471    - adding this code to a header that wraps the system <stdio.h>:
472      #undef getline
473      #if HAVE_RAW_DECL_GETLINE
474      _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
475        "not universally present; use the gnulib module getline");
476      #endif
477 
478    It is not possible to directly poison global variables.  But it is
479    possible to write a wrapper accessor function, and poison that
480    (less common usage, like &environ, will cause a compilation error
481    rather than issue the nice warning, but the end result of informing
482    the developer about their portability problem is still achieved):
483      #if HAVE_RAW_DECL_ENVIRON
484      static char ***
485      rpl_environ (void) { return &environ; }
486      _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
487      # undef environ
488      # define environ (*rpl_environ ())
489      #endif
490    or better (avoiding contradictory use of 'static' and 'extern'):
491      #if HAVE_RAW_DECL_ENVIRON
492      static char ***
493      _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
494      rpl_environ (void) { return &environ; }
495      # undef environ
496      # define environ (*rpl_environ ())
497      #endif
498    */
499 #ifndef _GL_WARN_ON_USE
500 
501 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
502 /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
503 #  define _GL_WARN_ON_USE(function, message) \
504 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
505 #  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
506   __attribute__ ((__warning__ (message)))
507 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
508 /* Verify the existence of the function.  */
509 #  define _GL_WARN_ON_USE(function, message) \
510 extern __typeof__ (function) function
511 #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
512 # else /* Unsupported.  */
513 #  define _GL_WARN_ON_USE(function, message) \
514 _GL_WARN_EXTERN_C int _gl_warn_on_use
515 #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
516 # endif
517 #endif
518 
519 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
520    is like _GL_WARN_ON_USE (function, "string"), except that the function is
521    declared with the given prototype, consisting of return type, parameters,
522    and attributes.
523    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
524    not work in this case.  */
525 #ifndef _GL_WARN_ON_USE_CXX
526 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
527 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
528 extern rettype function parameters_and_attributes \
529      __attribute__ ((__warning__ (msg)))
530 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
531 /* Verify the existence of the function.  */
532 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
533 extern rettype function parameters_and_attributes
534 # else /* Unsupported.  */
535 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
536 _GL_WARN_EXTERN_C int _gl_warn_on_use
537 # endif
538 #endif
539 
540 /* _GL_WARN_EXTERN_C declaration;
541    performs the declaration with C linkage.  */
542 #ifndef _GL_WARN_EXTERN_C
543 # if defined __cplusplus
544 #  define _GL_WARN_EXTERN_C extern "C"
545 # else
546 #  define _GL_WARN_EXTERN_C extern
547 # endif
548 #endif
549 
550 
551 /* Clear a block of memory.  The compiler will not delete a call to
552    this function, even if the block is dead after the call.  */
553 #if 0
554 # if ! 1
555 _GL_FUNCDECL_SYS (explicit_bzero, void,
556                   (void *__dest, size_t __n) _GL_ARG_NONNULL ((1)));
557 # endif
558 _GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
559 _GL_CXXALIASWARN (explicit_bzero);
560 #elif defined GNULIB_POSIXCHECK
561 # undef explicit_bzero
562 # if HAVE_RAW_DECL_EXPLICIT_BZERO
563 _GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
564                  "use gnulib module explicit_bzero for portability");
565 # endif
566 #endif
567 
568 /* Find the index of the least-significant set bit.  */
569 #if 0
570 # if !1
571 _GL_FUNCDECL_SYS (ffsl, int, (long int i));
572 # endif
573 _GL_CXXALIAS_SYS (ffsl, int, (long int i));
574 _GL_CXXALIASWARN (ffsl);
575 #elif defined GNULIB_POSIXCHECK
576 # undef ffsl
577 # if HAVE_RAW_DECL_FFSL
578 _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
579 # endif
580 #endif
581 
582 
583 /* Find the index of the least-significant set bit.  */
584 #if 0
585 # if !1
586 _GL_FUNCDECL_SYS (ffsll, int, (long long int i));
587 # endif
588 _GL_CXXALIAS_SYS (ffsll, int, (long long int i));
589 _GL_CXXALIASWARN (ffsll);
590 #elif defined GNULIB_POSIXCHECK
591 # undef ffsll
592 # if HAVE_RAW_DECL_FFSLL
593 _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
594 # endif
595 #endif
596 
597 
598 /* Return the first instance of C within N bytes of S, or NULL.  */
599 #if 1
600 # if 0
601 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
602 #   define memchr rpl_memchr
603 #  endif
604 _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
605                                   _GL_ATTRIBUTE_PURE
606                                   _GL_ARG_NONNULL ((1)));
607 _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
608 # else
609 #  if ! 1
610 _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
611                                   _GL_ATTRIBUTE_PURE
612                                   _GL_ARG_NONNULL ((1)));
613 #  endif
614   /* On some systems, this function is defined as an overloaded function:
615        extern "C" { const void * std::memchr (const void *, int, size_t); }
616        extern "C++" { void * std::memchr (void *, int, size_t); }  */
617 _GL_CXXALIAS_SYS_CAST2 (memchr,
618                         void *, (void const *__s, int __c, size_t __n),
619                         void const *, (void const *__s, int __c, size_t __n));
620 # endif
621 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
622      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
623 _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
624 _GL_CXXALIASWARN1 (memchr, void const *,
625                    (void const *__s, int __c, size_t __n));
626 # else
627 _GL_CXXALIASWARN (memchr);
628 # endif
629 #elif defined GNULIB_POSIXCHECK
630 # undef memchr
631 /* Assume memchr is always declared.  */
632 _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
633                  "use gnulib module memchr for portability" );
634 #endif
635 
636 /* Return the first occurrence of NEEDLE in HAYSTACK.  */
637 #if 0
638 # if 0
639 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
640 #   define memmem rpl_memmem
641 #  endif
642 _GL_FUNCDECL_RPL (memmem, void *,
643                   (void const *__haystack, size_t __haystack_len,
644                    void const *__needle, size_t __needle_len)
645                   _GL_ATTRIBUTE_PURE
646                   _GL_ARG_NONNULL ((1, 3)));
647 _GL_CXXALIAS_RPL (memmem, void *,
648                   (void const *__haystack, size_t __haystack_len,
649                    void const *__needle, size_t __needle_len));
650 # else
651 #  if ! 1
652 _GL_FUNCDECL_SYS (memmem, void *,
653                   (void const *__haystack, size_t __haystack_len,
654                    void const *__needle, size_t __needle_len)
655                   _GL_ATTRIBUTE_PURE
656                   _GL_ARG_NONNULL ((1, 3)));
657 #  endif
658 _GL_CXXALIAS_SYS (memmem, void *,
659                   (void const *__haystack, size_t __haystack_len,
660                    void const *__needle, size_t __needle_len));
661 # endif
662 _GL_CXXALIASWARN (memmem);
663 #elif defined GNULIB_POSIXCHECK
664 # undef memmem
665 # if HAVE_RAW_DECL_MEMMEM
666 _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
667                  "use gnulib module memmem-simple for portability, "
668                  "and module memmem for speed" );
669 # endif
670 #endif
671 
672 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
673    last written byte.  */
674 #if 0
675 # if ! 1
676 _GL_FUNCDECL_SYS (mempcpy, void *,
677                   (void *restrict __dest, void const *restrict __src,
678                    size_t __n)
679                   _GL_ARG_NONNULL ((1, 2)));
680 # endif
681 _GL_CXXALIAS_SYS (mempcpy, void *,
682                   (void *restrict __dest, void const *restrict __src,
683                    size_t __n));
684 _GL_CXXALIASWARN (mempcpy);
685 #elif defined GNULIB_POSIXCHECK
686 # undef mempcpy
687 # if HAVE_RAW_DECL_MEMPCPY
688 _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
689                  "use gnulib module mempcpy for portability");
690 # endif
691 #endif
692 
693 /* Search backwards through a block for a byte (specified as an int).  */
694 #if 0
695 # if ! 1
696 _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
697                                    _GL_ATTRIBUTE_PURE
698                                    _GL_ARG_NONNULL ((1)));
699 # endif
700   /* On some systems, this function is defined as an overloaded function:
701        extern "C++" { const void * std::memrchr (const void *, int, size_t); }
702        extern "C++" { void * std::memrchr (void *, int, size_t); }  */
703 _GL_CXXALIAS_SYS_CAST2 (memrchr,
704                         void *, (void const *, int, size_t),
705                         void const *, (void const *, int, size_t));
706 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
707      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
708 _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
709 _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
710 # else
711 _GL_CXXALIASWARN (memrchr);
712 # endif
713 #elif defined GNULIB_POSIXCHECK
714 # undef memrchr
715 # if HAVE_RAW_DECL_MEMRCHR
716 _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
717                  "use gnulib module memrchr for portability");
718 # endif
719 #endif
720 
721 /* Find the first occurrence of C in S.  More efficient than
722    memchr(S,C,N), at the expense of undefined behavior if C does not
723    occur within N bytes.  */
724 #if 1
725 # if ! 0
726 _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
727                                      _GL_ATTRIBUTE_PURE
728                                      _GL_ARG_NONNULL ((1)));
729 # endif
730   /* On some systems, this function is defined as an overloaded function:
731        extern "C++" { const void * std::rawmemchr (const void *, int); }
732        extern "C++" { void * std::rawmemchr (void *, int); }  */
733 _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
734                         void *, (void const *__s, int __c_in),
735                         void const *, (void const *__s, int __c_in));
736 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
737      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
738 _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
739 _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
740 # else
741 _GL_CXXALIASWARN (rawmemchr);
742 # endif
743 #elif defined GNULIB_POSIXCHECK
744 # undef rawmemchr
745 # if HAVE_RAW_DECL_RAWMEMCHR
746 _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
747                  "use gnulib module rawmemchr for portability");
748 # endif
749 #endif
750 
751 /* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
752 #if 0
753 # if ! 1
754 _GL_FUNCDECL_SYS (stpcpy, char *,
755                   (char *restrict __dst, char const *restrict __src)
756                   _GL_ARG_NONNULL ((1, 2)));
757 # endif
758 _GL_CXXALIAS_SYS (stpcpy, char *,
759                   (char *restrict __dst, char const *restrict __src));
760 _GL_CXXALIASWARN (stpcpy);
761 #elif defined GNULIB_POSIXCHECK
762 # undef stpcpy
763 # if HAVE_RAW_DECL_STPCPY
764 _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
765                  "use gnulib module stpcpy for portability");
766 # endif
767 #endif
768 
769 /* Copy no more than N bytes of SRC to DST, returning a pointer past the
770    last non-NUL byte written into DST.  */
771 #if 0
772 # if 0
773 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
774 #   undef stpncpy
775 #   define stpncpy rpl_stpncpy
776 #  endif
777 _GL_FUNCDECL_RPL (stpncpy, char *,
778                   (char *restrict __dst, char const *restrict __src,
779                    size_t __n)
780                   _GL_ARG_NONNULL ((1, 2)));
781 _GL_CXXALIAS_RPL (stpncpy, char *,
782                   (char *restrict __dst, char const *restrict __src,
783                    size_t __n));
784 # else
785 #  if ! 1
786 _GL_FUNCDECL_SYS (stpncpy, char *,
787                   (char *restrict __dst, char const *restrict __src,
788                    size_t __n)
789                   _GL_ARG_NONNULL ((1, 2)));
790 #  endif
791 _GL_CXXALIAS_SYS (stpncpy, char *,
792                   (char *restrict __dst, char const *restrict __src,
793                    size_t __n));
794 # endif
795 _GL_CXXALIASWARN (stpncpy);
796 #elif defined GNULIB_POSIXCHECK
797 # undef stpncpy
798 # if HAVE_RAW_DECL_STPNCPY
799 _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
800                  "use gnulib module stpncpy for portability");
801 # endif
802 #endif
803 
804 #if defined GNULIB_POSIXCHECK
805 /* strchr() does not work with multibyte strings if the locale encoding is
806    GB18030 and the character to be searched is a digit.  */
807 # undef strchr
808 /* Assume strchr is always declared.  */
809 _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
810                  "in some multibyte locales - "
811                  "use mbschr if you care about internationalization");
812 #endif
813 
814 /* Find the first occurrence of C in S or the final NUL byte.  */
815 #if 0
816 # if 0
817 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
818 #   define strchrnul rpl_strchrnul
819 #  endif
820 _GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
821                                      _GL_ATTRIBUTE_PURE
822                                      _GL_ARG_NONNULL ((1)));
823 _GL_CXXALIAS_RPL (strchrnul, char *,
824                   (const char *str, int ch));
825 # else
826 #  if ! 1
827 _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
828                                      _GL_ATTRIBUTE_PURE
829                                      _GL_ARG_NONNULL ((1)));
830 #  endif
831   /* On some systems, this function is defined as an overloaded function:
832        extern "C++" { const char * std::strchrnul (const char *, int); }
833        extern "C++" { char * std::strchrnul (char *, int); }  */
834 _GL_CXXALIAS_SYS_CAST2 (strchrnul,
835                         char *, (char const *__s, int __c_in),
836                         char const *, (char const *__s, int __c_in));
837 # endif
838 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
839      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
840 _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
841 _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
842 # else
843 _GL_CXXALIASWARN (strchrnul);
844 # endif
845 #elif defined GNULIB_POSIXCHECK
846 # undef strchrnul
847 # if HAVE_RAW_DECL_STRCHRNUL
848 _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
849                  "use gnulib module strchrnul for portability");
850 # endif
851 #endif
852 
853 /* Duplicate S, returning an identical malloc'd string.  */
854 #if 0
855 # if 0
856 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
857 #   undef strdup
858 #   define strdup rpl_strdup
859 #  endif
860 _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
861 _GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
862 # else
863 #  if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
864     /* strdup exists as a function and as a macro.  Get rid of the macro.  */
865 #   undef strdup
866 #  endif
867 #  if !(1 || defined strdup)
868 _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
869 #  endif
870 _GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
871 # endif
872 _GL_CXXALIASWARN (strdup);
873 #elif defined GNULIB_POSIXCHECK
874 # undef strdup
875 # if HAVE_RAW_DECL_STRDUP
876 _GL_WARN_ON_USE (strdup, "strdup is unportable - "
877                  "use gnulib module strdup for portability");
878 # endif
879 #endif
880 
881 /* Append no more than N characters from SRC onto DEST.  */
882 #if 0
883 # if 0
884 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
885 #   undef strncat
886 #   define strncat rpl_strncat
887 #  endif
888 _GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
889                                    _GL_ARG_NONNULL ((1, 2)));
890 _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
891 # else
892 _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
893 # endif
894 _GL_CXXALIASWARN (strncat);
895 #elif defined GNULIB_POSIXCHECK
896 # undef strncat
897 # if HAVE_RAW_DECL_STRNCAT
898 _GL_WARN_ON_USE (strncat, "strncat is unportable - "
899                  "use gnulib module strncat for portability");
900 # endif
901 #endif
902 
903 /* Return a newly allocated copy of at most N bytes of STRING.  */
904 #if 1
905 # if 0
906 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
907 #   undef strndup
908 #   define strndup rpl_strndup
909 #  endif
910 _GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n)
911                                    _GL_ARG_NONNULL ((1)));
912 _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
913 # else
914 #  if ! 1
915 _GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n)
916                                    _GL_ARG_NONNULL ((1)));
917 #  endif
918 _GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
919 # endif
920 _GL_CXXALIASWARN (strndup);
921 #elif defined GNULIB_POSIXCHECK
922 # undef strndup
923 # if HAVE_RAW_DECL_STRNDUP
924 _GL_WARN_ON_USE (strndup, "strndup is unportable - "
925                  "use gnulib module strndup for portability");
926 # endif
927 #endif
928 
929 /* Find the length (number of bytes) of STRING, but scan at most
930    MAXLEN bytes.  If no '\0' terminator is found in that many bytes,
931    return MAXLEN.  */
932 #if 1
933 # if 0
934 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
935 #   undef strnlen
936 #   define strnlen rpl_strnlen
937 #  endif
938 _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)
939                                    _GL_ATTRIBUTE_PURE
940                                    _GL_ARG_NONNULL ((1)));
941 _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
942 # else
943 #  if ! 1
944 _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)
945                                    _GL_ATTRIBUTE_PURE
946                                    _GL_ARG_NONNULL ((1)));
947 #  endif
948 _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
949 # endif
950 _GL_CXXALIASWARN (strnlen);
951 #elif defined GNULIB_POSIXCHECK
952 # undef strnlen
953 # if HAVE_RAW_DECL_STRNLEN
954 _GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
955                  "use gnulib module strnlen for portability");
956 # endif
957 #endif
958 
959 #if defined GNULIB_POSIXCHECK
960 /* strcspn() assumes the second argument is a list of single-byte characters.
961    Even in this simple case, it does not work with multibyte strings if the
962    locale encoding is GB18030 and one of the characters to be searched is a
963    digit.  */
964 # undef strcspn
965 /* Assume strcspn is always declared.  */
966 _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
967                  "in multibyte locales - "
968                  "use mbscspn if you care about internationalization");
969 #endif
970 
971 /* Find the first occurrence in S of any character in ACCEPT.  */
972 #if 0
973 # if ! 1
974 _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
975                                    _GL_ATTRIBUTE_PURE
976                                    _GL_ARG_NONNULL ((1, 2)));
977 # endif
978   /* On some systems, this function is defined as an overloaded function:
979        extern "C" { const char * strpbrk (const char *, const char *); }
980        extern "C++" { char * strpbrk (char *, const char *); }  */
981 _GL_CXXALIAS_SYS_CAST2 (strpbrk,
982                         char *, (char const *__s, char const *__accept),
983                         const char *, (char const *__s, char const *__accept));
984 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
985      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
986 _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
987 _GL_CXXALIASWARN1 (strpbrk, char const *,
988                    (char const *__s, char const *__accept));
989 # else
990 _GL_CXXALIASWARN (strpbrk);
991 # endif
992 # if defined GNULIB_POSIXCHECK
993 /* strpbrk() assumes the second argument is a list of single-byte characters.
994    Even in this simple case, it does not work with multibyte strings if the
995    locale encoding is GB18030 and one of the characters to be searched is a
996    digit.  */
997 #  undef strpbrk
998 _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
999                  "in multibyte locales - "
1000                  "use mbspbrk if you care about internationalization");
1001 # endif
1002 #elif defined GNULIB_POSIXCHECK
1003 # undef strpbrk
1004 # if HAVE_RAW_DECL_STRPBRK
1005 _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
1006                  "use gnulib module strpbrk for portability");
1007 # endif
1008 #endif
1009 
1010 #if defined GNULIB_POSIXCHECK
1011 /* strspn() assumes the second argument is a list of single-byte characters.
1012    Even in this simple case, it cannot work with multibyte strings.  */
1013 # undef strspn
1014 /* Assume strspn is always declared.  */
1015 _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
1016                  "in multibyte locales - "
1017                  "use mbsspn if you care about internationalization");
1018 #endif
1019 
1020 #if defined GNULIB_POSIXCHECK
1021 /* strrchr() does not work with multibyte strings if the locale encoding is
1022    GB18030 and the character to be searched is a digit.  */
1023 # undef strrchr
1024 /* Assume strrchr is always declared.  */
1025 _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
1026                  "in some multibyte locales - "
1027                  "use mbsrchr if you care about internationalization");
1028 #endif
1029 
1030 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
1031    If one is found, overwrite it with a NUL, and advance *STRINGP
1032    to point to the next char after it.  Otherwise, set *STRINGP to NULL.
1033    If *STRINGP was already NULL, nothing happens.
1034    Return the old value of *STRINGP.
1035 
1036    This is a variant of strtok() that is multithread-safe and supports
1037    empty fields.
1038 
1039    Caveat: It modifies the original string.
1040    Caveat: These functions cannot be used on constant strings.
1041    Caveat: The identity of the delimiting character is lost.
1042    Caveat: It doesn't work with multibyte strings unless all of the delimiter
1043            characters are ASCII characters < 0x30.
1044 
1045    See also strtok_r().  */
1046 #if 0
1047 # if ! 1
1048 _GL_FUNCDECL_SYS (strsep, char *,
1049                   (char **restrict __stringp, char const *restrict __delim)
1050                   _GL_ARG_NONNULL ((1, 2)));
1051 # endif
1052 _GL_CXXALIAS_SYS (strsep, char *,
1053                   (char **restrict __stringp, char const *restrict __delim));
1054 _GL_CXXALIASWARN (strsep);
1055 # if defined GNULIB_POSIXCHECK
1056 #  undef strsep
1057 _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
1058                  "in multibyte locales - "
1059                  "use mbssep if you care about internationalization");
1060 # endif
1061 #elif defined GNULIB_POSIXCHECK
1062 # undef strsep
1063 # if HAVE_RAW_DECL_STRSEP
1064 _GL_WARN_ON_USE (strsep, "strsep is unportable - "
1065                  "use gnulib module strsep for portability");
1066 # endif
1067 #endif
1068 
1069 #if 0
1070 # if 0
1071 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1072 #   define strstr rpl_strstr
1073 #  endif
1074 _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
1075                                   _GL_ATTRIBUTE_PURE
1076                                   _GL_ARG_NONNULL ((1, 2)));
1077 _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
1078 # else
1079   /* On some systems, this function is defined as an overloaded function:
1080        extern "C++" { const char * strstr (const char *, const char *); }
1081        extern "C++" { char * strstr (char *, const char *); }  */
1082 _GL_CXXALIAS_SYS_CAST2 (strstr,
1083                         char *, (const char *haystack, const char *needle),
1084                         const char *, (const char *haystack, const char *needle));
1085 # endif
1086 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1087      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1088 _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
1089 _GL_CXXALIASWARN1 (strstr, const char *,
1090                    (const char *haystack, const char *needle));
1091 # else
1092 _GL_CXXALIASWARN (strstr);
1093 # endif
1094 #elif defined GNULIB_POSIXCHECK
1095 /* strstr() does not work with multibyte strings if the locale encoding is
1096    different from UTF-8:
1097    POSIX says that it operates on "strings", and "string" in POSIX is defined
1098    as a sequence of bytes, not of characters.  */
1099 # undef strstr
1100 /* Assume strstr is always declared.  */
1101 _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
1102                  "work correctly on character strings in most "
1103                  "multibyte locales - "
1104                  "use mbsstr if you care about internationalization, "
1105                  "or use strstr if you care about speed");
1106 #endif
1107 
1108 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
1109    comparison.  */
1110 #if 0
1111 # if 0
1112 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1113 #   define strcasestr rpl_strcasestr
1114 #  endif
1115 _GL_FUNCDECL_RPL (strcasestr, char *,
1116                   (const char *haystack, const char *needle)
1117                   _GL_ATTRIBUTE_PURE
1118                   _GL_ARG_NONNULL ((1, 2)));
1119 _GL_CXXALIAS_RPL (strcasestr, char *,
1120                   (const char *haystack, const char *needle));
1121 # else
1122 #  if ! 1
1123 _GL_FUNCDECL_SYS (strcasestr, char *,
1124                   (const char *haystack, const char *needle)
1125                   _GL_ATTRIBUTE_PURE
1126                   _GL_ARG_NONNULL ((1, 2)));
1127 #  endif
1128   /* On some systems, this function is defined as an overloaded function:
1129        extern "C++" { const char * strcasestr (const char *, const char *); }
1130        extern "C++" { char * strcasestr (char *, const char *); }  */
1131 _GL_CXXALIAS_SYS_CAST2 (strcasestr,
1132                         char *, (const char *haystack, const char *needle),
1133                         const char *, (const char *haystack, const char *needle));
1134 # endif
1135 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1136      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1137 _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
1138 _GL_CXXALIASWARN1 (strcasestr, const char *,
1139                    (const char *haystack, const char *needle));
1140 # else
1141 _GL_CXXALIASWARN (strcasestr);
1142 # endif
1143 #elif defined GNULIB_POSIXCHECK
1144 /* strcasestr() does not work with multibyte strings:
1145    It is a glibc extension, and glibc implements it only for unibyte
1146    locales.  */
1147 # undef strcasestr
1148 # if HAVE_RAW_DECL_STRCASESTR
1149 _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
1150                  "strings in multibyte locales - "
1151                  "use mbscasestr if you care about "
1152                  "internationalization, or use c-strcasestr if you want "
1153                  "a locale independent function");
1154 # endif
1155 #endif
1156 
1157 /* Parse S into tokens separated by characters in DELIM.
1158    If S is NULL, the saved pointer in SAVE_PTR is used as
1159    the next starting point.  For example:
1160         char s[] = "-abc-=-def";
1161         char *sp;
1162         x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
1163         x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
1164         x = strtok_r(NULL, "=", &sp);   // x = NULL
1165                 // s = "abc\0-def\0"
1166 
1167    This is a variant of strtok() that is multithread-safe.
1168 
1169    For the POSIX documentation for this function, see:
1170    http://www.opengroup.org/susv3xsh/strtok.html
1171 
1172    Caveat: It modifies the original string.
1173    Caveat: These functions cannot be used on constant strings.
1174    Caveat: The identity of the delimiting character is lost.
1175    Caveat: It doesn't work with multibyte strings unless all of the delimiter
1176            characters are ASCII characters < 0x30.
1177 
1178    See also strsep().  */
1179 #if 0
1180 # if 0
1181 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1182 #   undef strtok_r
1183 #   define strtok_r rpl_strtok_r
1184 #  endif
1185 _GL_FUNCDECL_RPL (strtok_r, char *,
1186                   (char *restrict s, char const *restrict delim,
1187                    char **restrict save_ptr)
1188                   _GL_ARG_NONNULL ((2, 3)));
1189 _GL_CXXALIAS_RPL (strtok_r, char *,
1190                   (char *restrict s, char const *restrict delim,
1191                    char **restrict save_ptr));
1192 # else
1193 #  if 0 || defined GNULIB_POSIXCHECK
1194 #   undef strtok_r
1195 #  endif
1196 #  if ! 1
1197 _GL_FUNCDECL_SYS (strtok_r, char *,
1198                   (char *restrict s, char const *restrict delim,
1199                    char **restrict save_ptr)
1200                   _GL_ARG_NONNULL ((2, 3)));
1201 #  endif
1202 _GL_CXXALIAS_SYS (strtok_r, char *,
1203                   (char *restrict s, char const *restrict delim,
1204                    char **restrict save_ptr));
1205 # endif
1206 _GL_CXXALIASWARN (strtok_r);
1207 # if defined GNULIB_POSIXCHECK
1208 _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
1209                  "strings in multibyte locales - "
1210                  "use mbstok_r if you care about internationalization");
1211 # endif
1212 #elif defined GNULIB_POSIXCHECK
1213 # undef strtok_r
1214 # if HAVE_RAW_DECL_STRTOK_R
1215 _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
1216                  "use gnulib module strtok_r for portability");
1217 # endif
1218 #endif
1219 
1220 
1221 /* The following functions are not specified by POSIX.  They are gnulib
1222    extensions.  */
1223 
1224 #if 1
1225 /* Return the number of multibyte characters in the character string STRING.
1226    This considers multibyte characters, unlike strlen, which counts bytes.  */
1227 # ifdef __MirBSD__  /* MirBSD defines mbslen as a macro.  Override it.  */
1228 #  undef mbslen
1229 # endif
1230 # if 0  /* AIX, OSF/1, MirBSD define mbslen already in libc.  */
1231 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1232 #   define mbslen rpl_mbslen
1233 #  endif
1234 _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string)
1235                                   _GL_ATTRIBUTE_PURE
1236                                   _GL_ARG_NONNULL ((1)));
1237 _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
1238 # else
1239 _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
1240                                   _GL_ATTRIBUTE_PURE
1241                                   _GL_ARG_NONNULL ((1)));
1242 _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
1243 # endif
1244 _GL_CXXALIASWARN (mbslen);
1245 #endif
1246 
1247 #if 0
1248 /* Return the number of multibyte characters in the character string starting
1249    at STRING and ending at STRING + LEN.  */
1250 _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
1251      _GL_ATTRIBUTE_PURE
1252      _GL_ARG_NONNULL ((1));
1253 #endif
1254 
1255 #if 0
1256 /* Locate the first single-byte character C in the character string STRING,
1257    and return a pointer to it.  Return NULL if C is not found in STRING.
1258    Unlike strchr(), this function works correctly in multibyte locales with
1259    encodings such as GB18030.  */
1260 # if defined __hpux
1261 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1262 #   define mbschr rpl_mbschr /* avoid collision with HP-UX function */
1263 #  endif
1264 _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
1265                                   _GL_ATTRIBUTE_PURE
1266                                   _GL_ARG_NONNULL ((1)));
1267 _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
1268 # else
1269 _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
1270                                   _GL_ATTRIBUTE_PURE
1271                                   _GL_ARG_NONNULL ((1)));
1272 _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
1273 # endif
1274 _GL_CXXALIASWARN (mbschr);
1275 #endif
1276 
1277 #if 0
1278 /* Locate the last single-byte character C in the character string STRING,
1279    and return a pointer to it.  Return NULL if C is not found in STRING.
1280    Unlike strrchr(), this function works correctly in multibyte locales with
1281    encodings such as GB18030.  */
1282 # if defined __hpux || defined __INTERIX
1283 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1284 #   define mbsrchr rpl_mbsrchr /* avoid collision with system function */
1285 #  endif
1286 _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
1287                                    _GL_ATTRIBUTE_PURE
1288                                    _GL_ARG_NONNULL ((1)));
1289 _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
1290 # else
1291 _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
1292                                    _GL_ATTRIBUTE_PURE
1293                                    _GL_ARG_NONNULL ((1)));
1294 _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
1295 # endif
1296 _GL_CXXALIASWARN (mbsrchr);
1297 #endif
1298 
1299 #if 1
1300 /* Find the first occurrence of the character string NEEDLE in the character
1301    string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
1302    Unlike strstr(), this function works correctly in multibyte locales with
1303    encodings different from UTF-8.  */
1304 _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
1305      _GL_ATTRIBUTE_PURE
1306      _GL_ARG_NONNULL ((1, 2));
1307 #endif
1308 
1309 #if 1
1310 /* Compare the character strings S1 and S2, ignoring case, returning less than,
1311    equal to or greater than zero if S1 is lexicographically less than, equal to
1312    or greater than S2.
1313    Note: This function may, in multibyte locales, return 0 for strings of
1314    different lengths!
1315    Unlike strcasecmp(), this function works correctly in multibyte locales.  */
1316 _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
1317      _GL_ATTRIBUTE_PURE
1318      _GL_ARG_NONNULL ((1, 2));
1319 #endif
1320 
1321 #if 0
1322 /* Compare the initial segment of the character string S1 consisting of at most
1323    N characters with the initial segment of the character string S2 consisting
1324    of at most N characters, ignoring case, returning less than, equal to or
1325    greater than zero if the initial segment of S1 is lexicographically less
1326    than, equal to or greater than the initial segment of S2.
1327    Note: This function may, in multibyte locales, return 0 for initial segments
1328    of different lengths!
1329    Unlike strncasecmp(), this function works correctly in multibyte locales.
1330    But beware that N is not a byte count but a character count!  */
1331 _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
1332      _GL_ATTRIBUTE_PURE
1333      _GL_ARG_NONNULL ((1, 2));
1334 #endif
1335 
1336 #if 0
1337 /* Compare the initial segment of the character string STRING consisting of
1338    at most mbslen (PREFIX) characters with the character string PREFIX,
1339    ignoring case.  If the two match, return a pointer to the first byte
1340    after this prefix in STRING.  Otherwise, return NULL.
1341    Note: This function may, in multibyte locales, return non-NULL if STRING
1342    is of smaller length than PREFIX!
1343    Unlike strncasecmp(), this function works correctly in multibyte
1344    locales.  */
1345 _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1346      _GL_ATTRIBUTE_PURE
1347      _GL_ARG_NONNULL ((1, 2));
1348 #endif
1349 
1350 #if 0
1351 /* Find the first occurrence of the character string NEEDLE in the character
1352    string HAYSTACK, using case-insensitive comparison.
1353    Note: This function may, in multibyte locales, return success even if
1354    strlen (haystack) < strlen (needle) !
1355    Unlike strcasestr(), this function works correctly in multibyte locales.  */
1356 _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
1357      _GL_ATTRIBUTE_PURE
1358      _GL_ARG_NONNULL ((1, 2));
1359 #endif
1360 
1361 #if 0
1362 /* Find the first occurrence in the character string STRING of any character
1363    in the character string ACCEPT.  Return the number of bytes from the
1364    beginning of the string to this occurrence, or to the end of the string
1365    if none exists.
1366    Unlike strcspn(), this function works correctly in multibyte locales.  */
1367 _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
1368      _GL_ATTRIBUTE_PURE
1369      _GL_ARG_NONNULL ((1, 2));
1370 #endif
1371 
1372 #if 0
1373 /* Find the first occurrence in the character string STRING of any character
1374    in the character string ACCEPT.  Return the pointer to it, or NULL if none
1375    exists.
1376    Unlike strpbrk(), this function works correctly in multibyte locales.  */
1377 # if defined __hpux
1378 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1379 #   define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
1380 #  endif
1381 _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
1382                                    _GL_ATTRIBUTE_PURE
1383                                    _GL_ARG_NONNULL ((1, 2)));
1384 _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
1385 # else
1386 _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
1387                                    _GL_ATTRIBUTE_PURE
1388                                    _GL_ARG_NONNULL ((1, 2)));
1389 _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
1390 # endif
1391 _GL_CXXALIASWARN (mbspbrk);
1392 #endif
1393 
1394 #if 0
1395 /* Find the first occurrence in the character string STRING of any character
1396    not in the character string REJECT.  Return the number of bytes from the
1397    beginning of the string to this occurrence, or to the end of the string
1398    if none exists.
1399    Unlike strspn(), this function works correctly in multibyte locales.  */
1400 _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
1401      _GL_ATTRIBUTE_PURE
1402      _GL_ARG_NONNULL ((1, 2));
1403 #endif
1404 
1405 #if 0
1406 /* Search the next delimiter (multibyte character listed in the character
1407    string DELIM) starting at the character string *STRINGP.
1408    If one is found, overwrite it with a NUL, and advance *STRINGP to point
1409    to the next multibyte character after it.  Otherwise, set *STRINGP to NULL.
1410    If *STRINGP was already NULL, nothing happens.
1411    Return the old value of *STRINGP.
1412 
1413    This is a variant of mbstok_r() that supports empty fields.
1414 
1415    Caveat: It modifies the original string.
1416    Caveat: These functions cannot be used on constant strings.
1417    Caveat: The identity of the delimiting character is lost.
1418 
1419    See also mbstok_r().  */
1420 _GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
1421      _GL_ARG_NONNULL ((1, 2));
1422 #endif
1423 
1424 #if 0
1425 /* Parse the character string STRING into tokens separated by characters in
1426    the character string DELIM.
1427    If STRING is NULL, the saved pointer in SAVE_PTR is used as
1428    the next starting point.  For example:
1429         char s[] = "-abc-=-def";
1430         char *sp;
1431         x = mbstok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
1432         x = mbstok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
1433         x = mbstok_r(NULL, "=", &sp);   // x = NULL
1434                 // s = "abc\0-def\0"
1435 
1436    Caveat: It modifies the original string.
1437    Caveat: These functions cannot be used on constant strings.
1438    Caveat: The identity of the delimiting character is lost.
1439 
1440    See also mbssep().  */
1441 _GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
1442      _GL_ARG_NONNULL ((2, 3));
1443 #endif
1444 
1445 /* Map any int, typically from errno, into an error message.  */
1446 #if 1
1447 # if 1
1448 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1449 #   undef strerror
1450 #   define strerror rpl_strerror
1451 #  endif
1452 _GL_FUNCDECL_RPL (strerror, char *, (int));
1453 _GL_CXXALIAS_RPL (strerror, char *, (int));
1454 # else
1455 _GL_CXXALIAS_SYS (strerror, char *, (int));
1456 # endif
1457 _GL_CXXALIASWARN (strerror);
1458 #elif defined GNULIB_POSIXCHECK
1459 # undef strerror
1460 /* Assume strerror is always declared.  */
1461 _GL_WARN_ON_USE (strerror, "strerror is unportable - "
1462                  "use gnulib module strerror to guarantee non-NULL result");
1463 #endif
1464 
1465 /* Map any int, typically from errno, into an error message.  Multithread-safe.
1466    Uses the POSIX declaration, not the glibc declaration.  */
1467 #if IN_DIFFUTILS_GNULIB_TESTS
1468 # if 1
1469 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1470 #   undef strerror_r
1471 #   define strerror_r rpl_strerror_r
1472 #  endif
1473 _GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
1474                                    _GL_ARG_NONNULL ((2)));
1475 _GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
1476 # else
1477 #  if !1
1478 _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
1479                                    _GL_ARG_NONNULL ((2)));
1480 #  endif
1481 _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
1482 # endif
1483 # if 1
1484 _GL_CXXALIASWARN (strerror_r);
1485 # endif
1486 #elif defined GNULIB_POSIXCHECK
1487 # undef strerror_r
1488 # if HAVE_RAW_DECL_STRERROR_R
1489 _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1490                  "use gnulib module strerror_r-posix for portability");
1491 # endif
1492 #endif
1493 
1494 #if 0
1495 # if 0
1496 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1497 #   define strsignal rpl_strsignal
1498 #  endif
1499 _GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
1500 _GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
1501 # else
1502 #  if ! 1
1503 _GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
1504 #  endif
1505 /* Need to cast, because on Cygwin 1.5.x systems, the return type is
1506    'const char *'.  */
1507 _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
1508 # endif
1509 _GL_CXXALIASWARN (strsignal);
1510 #elif defined GNULIB_POSIXCHECK
1511 # undef strsignal
1512 # if HAVE_RAW_DECL_STRSIGNAL
1513 _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
1514                  "use gnulib module strsignal for portability");
1515 # endif
1516 #endif
1517 
1518 #if 0
1519 # if !1
1520 _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
1521                                    _GL_ATTRIBUTE_PURE
1522                                    _GL_ARG_NONNULL ((1, 2)));
1523 # endif
1524 _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
1525 _GL_CXXALIASWARN (strverscmp);
1526 #elif defined GNULIB_POSIXCHECK
1527 # undef strverscmp
1528 # if HAVE_RAW_DECL_STRVERSCMP
1529 _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1530                  "use gnulib module strverscmp for portability");
1531 # endif
1532 #endif
1533 
1534 
1535 #endif /* _GL_STRING_H */
1536 #endif /* _GL_STRING_H */
1537 #endif
1538