1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A GNU-like <string.h>.
3 
4    Copyright (C) 1995-1996, 2001-2020 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-2020 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-2020 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-2020 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 # elif __GLIBC__ >= 2
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 1
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 1
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 0
725 # if ! 1
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 1
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 1
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 # if __GLIBC__ >= 2
895 _GL_CXXALIASWARN (strncat);
896 # endif
897 #elif defined GNULIB_POSIXCHECK
898 # undef strncat
899 # if HAVE_RAW_DECL_STRNCAT
900 _GL_WARN_ON_USE (strncat, "strncat is unportable - "
901                  "use gnulib module strncat for portability");
902 # endif
903 #endif
904 
905 /* Return a newly allocated copy of at most N bytes of STRING.  */
906 #if 0
907 # if 0
908 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
909 #   undef strndup
910 #   define strndup rpl_strndup
911 #  endif
912 _GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n)
913                                    _GL_ARG_NONNULL ((1)));
914 _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
915 # else
916 #  if ! 1
917 _GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n)
918                                    _GL_ARG_NONNULL ((1)));
919 #  endif
920 _GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
921 # endif
922 _GL_CXXALIASWARN (strndup);
923 #elif defined GNULIB_POSIXCHECK
924 # undef strndup
925 # if HAVE_RAW_DECL_STRNDUP
926 _GL_WARN_ON_USE (strndup, "strndup is unportable - "
927                  "use gnulib module strndup for portability");
928 # endif
929 #endif
930 
931 /* Find the length (number of bytes) of STRING, but scan at most
932    MAXLEN bytes.  If no '\0' terminator is found in that many bytes,
933    return MAXLEN.  */
934 #if 1
935 # if 0
936 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
937 #   undef strnlen
938 #   define strnlen rpl_strnlen
939 #  endif
940 _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)
941                                    _GL_ATTRIBUTE_PURE
942                                    _GL_ARG_NONNULL ((1)));
943 _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
944 # else
945 #  if ! 1
946 _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)
947                                    _GL_ATTRIBUTE_PURE
948                                    _GL_ARG_NONNULL ((1)));
949 #  endif
950 _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
951 # endif
952 _GL_CXXALIASWARN (strnlen);
953 #elif defined GNULIB_POSIXCHECK
954 # undef strnlen
955 # if HAVE_RAW_DECL_STRNLEN
956 _GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
957                  "use gnulib module strnlen for portability");
958 # endif
959 #endif
960 
961 #if defined GNULIB_POSIXCHECK
962 /* strcspn() assumes the second argument is a list of single-byte characters.
963    Even in this simple case, it does not work with multibyte strings if the
964    locale encoding is GB18030 and one of the characters to be searched is a
965    digit.  */
966 # undef strcspn
967 /* Assume strcspn is always declared.  */
968 _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
969                  "in multibyte locales - "
970                  "use mbscspn if you care about internationalization");
971 #endif
972 
973 /* Find the first occurrence in S of any character in ACCEPT.  */
974 #if 0
975 # if ! 1
976 _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
977                                    _GL_ATTRIBUTE_PURE
978                                    _GL_ARG_NONNULL ((1, 2)));
979 # endif
980   /* On some systems, this function is defined as an overloaded function:
981        extern "C" { const char * strpbrk (const char *, const char *); }
982        extern "C++" { char * strpbrk (char *, const char *); }  */
983 _GL_CXXALIAS_SYS_CAST2 (strpbrk,
984                         char *, (char const *__s, char const *__accept),
985                         const char *, (char const *__s, char const *__accept));
986 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
987      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
988 _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
989 _GL_CXXALIASWARN1 (strpbrk, char const *,
990                    (char const *__s, char const *__accept));
991 # elif __GLIBC__ >= 2
992 _GL_CXXALIASWARN (strpbrk);
993 # endif
994 # if defined GNULIB_POSIXCHECK
995 /* strpbrk() assumes the second argument is a list of single-byte characters.
996    Even in this simple case, it does not work with multibyte strings if the
997    locale encoding is GB18030 and one of the characters to be searched is a
998    digit.  */
999 #  undef strpbrk
1000 _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
1001                  "in multibyte locales - "
1002                  "use mbspbrk if you care about internationalization");
1003 # endif
1004 #elif defined GNULIB_POSIXCHECK
1005 # undef strpbrk
1006 # if HAVE_RAW_DECL_STRPBRK
1007 _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
1008                  "use gnulib module strpbrk for portability");
1009 # endif
1010 #endif
1011 
1012 #if defined GNULIB_POSIXCHECK
1013 /* strspn() assumes the second argument is a list of single-byte characters.
1014    Even in this simple case, it cannot work with multibyte strings.  */
1015 # undef strspn
1016 /* Assume strspn is always declared.  */
1017 _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
1018                  "in multibyte locales - "
1019                  "use mbsspn if you care about internationalization");
1020 #endif
1021 
1022 #if defined GNULIB_POSIXCHECK
1023 /* strrchr() does not work with multibyte strings if the locale encoding is
1024    GB18030 and the character to be searched is a digit.  */
1025 # undef strrchr
1026 /* Assume strrchr is always declared.  */
1027 _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
1028                  "in some multibyte locales - "
1029                  "use mbsrchr if you care about internationalization");
1030 #endif
1031 
1032 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
1033    If one is found, overwrite it with a NUL, and advance *STRINGP
1034    to point to the next char after it.  Otherwise, set *STRINGP to NULL.
1035    If *STRINGP was already NULL, nothing happens.
1036    Return the old value of *STRINGP.
1037 
1038    This is a variant of strtok() that is multithread-safe and supports
1039    empty fields.
1040 
1041    Caveat: It modifies the original string.
1042    Caveat: These functions cannot be used on constant strings.
1043    Caveat: The identity of the delimiting character is lost.
1044    Caveat: It doesn't work with multibyte strings unless all of the delimiter
1045            characters are ASCII characters < 0x30.
1046 
1047    See also strtok_r().  */
1048 #if 0
1049 # if ! 1
1050 _GL_FUNCDECL_SYS (strsep, char *,
1051                   (char **restrict __stringp, char const *restrict __delim)
1052                   _GL_ARG_NONNULL ((1, 2)));
1053 # endif
1054 _GL_CXXALIAS_SYS (strsep, char *,
1055                   (char **restrict __stringp, char const *restrict __delim));
1056 _GL_CXXALIASWARN (strsep);
1057 # if defined GNULIB_POSIXCHECK
1058 #  undef strsep
1059 _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
1060                  "in multibyte locales - "
1061                  "use mbssep if you care about internationalization");
1062 # endif
1063 #elif defined GNULIB_POSIXCHECK
1064 # undef strsep
1065 # if HAVE_RAW_DECL_STRSEP
1066 _GL_WARN_ON_USE (strsep, "strsep is unportable - "
1067                  "use gnulib module strsep for portability");
1068 # endif
1069 #endif
1070 
1071 #if 1
1072 # if 1
1073 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1074 #   define strstr rpl_strstr
1075 #  endif
1076 _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
1077                                   _GL_ATTRIBUTE_PURE
1078                                   _GL_ARG_NONNULL ((1, 2)));
1079 _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
1080 # else
1081   /* On some systems, this function is defined as an overloaded function:
1082        extern "C++" { const char * strstr (const char *, const char *); }
1083        extern "C++" { char * strstr (char *, const char *); }  */
1084 _GL_CXXALIAS_SYS_CAST2 (strstr,
1085                         char *, (const char *haystack, const char *needle),
1086                         const char *, (const char *haystack, const char *needle));
1087 # endif
1088 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1089      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1090 _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
1091 _GL_CXXALIASWARN1 (strstr, const char *,
1092                    (const char *haystack, const char *needle));
1093 # elif __GLIBC__ >= 2
1094 _GL_CXXALIASWARN (strstr);
1095 # endif
1096 #elif defined GNULIB_POSIXCHECK
1097 /* strstr() does not work with multibyte strings if the locale encoding is
1098    different from UTF-8:
1099    POSIX says that it operates on "strings", and "string" in POSIX is defined
1100    as a sequence of bytes, not of characters.  */
1101 # undef strstr
1102 /* Assume strstr is always declared.  */
1103 _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
1104                  "work correctly on character strings in most "
1105                  "multibyte locales - "
1106                  "use mbsstr if you care about internationalization, "
1107                  "or use strstr if you care about speed");
1108 #endif
1109 
1110 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
1111    comparison.  */
1112 #if 0
1113 # if 0
1114 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1115 #   define strcasestr rpl_strcasestr
1116 #  endif
1117 _GL_FUNCDECL_RPL (strcasestr, char *,
1118                   (const char *haystack, const char *needle)
1119                   _GL_ATTRIBUTE_PURE
1120                   _GL_ARG_NONNULL ((1, 2)));
1121 _GL_CXXALIAS_RPL (strcasestr, char *,
1122                   (const char *haystack, const char *needle));
1123 # else
1124 #  if ! 1
1125 _GL_FUNCDECL_SYS (strcasestr, char *,
1126                   (const char *haystack, const char *needle)
1127                   _GL_ATTRIBUTE_PURE
1128                   _GL_ARG_NONNULL ((1, 2)));
1129 #  endif
1130   /* On some systems, this function is defined as an overloaded function:
1131        extern "C++" { const char * strcasestr (const char *, const char *); }
1132        extern "C++" { char * strcasestr (char *, const char *); }  */
1133 _GL_CXXALIAS_SYS_CAST2 (strcasestr,
1134                         char *, (const char *haystack, const char *needle),
1135                         const char *, (const char *haystack, const char *needle));
1136 # endif
1137 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1138      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
1139 _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
1140 _GL_CXXALIASWARN1 (strcasestr, const char *,
1141                    (const char *haystack, const char *needle));
1142 # else
1143 _GL_CXXALIASWARN (strcasestr);
1144 # endif
1145 #elif defined GNULIB_POSIXCHECK
1146 /* strcasestr() does not work with multibyte strings:
1147    It is a glibc extension, and glibc implements it only for unibyte
1148    locales.  */
1149 # undef strcasestr
1150 # if HAVE_RAW_DECL_STRCASESTR
1151 _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
1152                  "strings in multibyte locales - "
1153                  "use mbscasestr if you care about "
1154                  "internationalization, or use c-strcasestr if you want "
1155                  "a locale independent function");
1156 # endif
1157 #endif
1158 
1159 /* Parse S into tokens separated by characters in DELIM.
1160    If S is NULL, the saved pointer in SAVE_PTR is used as
1161    the next starting point.  For example:
1162         char s[] = "-abc-=-def";
1163         char *sp;
1164         x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
1165         x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
1166         x = strtok_r(NULL, "=", &sp);   // x = NULL
1167                 // s = "abc\0-def\0"
1168 
1169    This is a variant of strtok() that is multithread-safe.
1170 
1171    For the POSIX documentation for this function, see:
1172    https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html
1173 
1174    Caveat: It modifies the original string.
1175    Caveat: These functions cannot be used on constant strings.
1176    Caveat: The identity of the delimiting character is lost.
1177    Caveat: It doesn't work with multibyte strings unless all of the delimiter
1178            characters are ASCII characters < 0x30.
1179 
1180    See also strsep().  */
1181 #if 0
1182 # if 0
1183 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1184 #   undef strtok_r
1185 #   define strtok_r rpl_strtok_r
1186 #  endif
1187 _GL_FUNCDECL_RPL (strtok_r, char *,
1188                   (char *restrict s, char const *restrict delim,
1189                    char **restrict save_ptr)
1190                   _GL_ARG_NONNULL ((2, 3)));
1191 _GL_CXXALIAS_RPL (strtok_r, char *,
1192                   (char *restrict s, char const *restrict delim,
1193                    char **restrict save_ptr));
1194 # else
1195 #  if 0 || defined GNULIB_POSIXCHECK
1196 #   undef strtok_r
1197 #  endif
1198 #  if ! 1
1199 _GL_FUNCDECL_SYS (strtok_r, char *,
1200                   (char *restrict s, char const *restrict delim,
1201                    char **restrict save_ptr)
1202                   _GL_ARG_NONNULL ((2, 3)));
1203 #  endif
1204 _GL_CXXALIAS_SYS (strtok_r, char *,
1205                   (char *restrict s, char const *restrict delim,
1206                    char **restrict save_ptr));
1207 # endif
1208 _GL_CXXALIASWARN (strtok_r);
1209 # if defined GNULIB_POSIXCHECK
1210 _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
1211                  "strings in multibyte locales - "
1212                  "use mbstok_r if you care about internationalization");
1213 # endif
1214 #elif defined GNULIB_POSIXCHECK
1215 # undef strtok_r
1216 # if HAVE_RAW_DECL_STRTOK_R
1217 _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
1218                  "use gnulib module strtok_r for portability");
1219 # endif
1220 #endif
1221 
1222 
1223 /* The following functions are not specified by POSIX.  They are gnulib
1224    extensions.  */
1225 
1226 #if 1
1227 /* Return the number of multibyte characters in the character string STRING.
1228    This considers multibyte characters, unlike strlen, which counts bytes.  */
1229 # ifdef __MirBSD__  /* MirBSD defines mbslen as a macro.  Override it.  */
1230 #  undef mbslen
1231 # endif
1232 # if 0  /* AIX, OSF/1, MirBSD define mbslen already in libc.  */
1233 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1234 #   define mbslen rpl_mbslen
1235 #  endif
1236 _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string)
1237                                   _GL_ATTRIBUTE_PURE
1238                                   _GL_ARG_NONNULL ((1)));
1239 _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
1240 # else
1241 _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
1242                                   _GL_ATTRIBUTE_PURE
1243                                   _GL_ARG_NONNULL ((1)));
1244 _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
1245 # endif
1246 _GL_CXXALIASWARN (mbslen);
1247 #endif
1248 
1249 #if 0
1250 /* Return the number of multibyte characters in the character string starting
1251    at STRING and ending at STRING + LEN.  */
1252 _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
1253      _GL_ATTRIBUTE_PURE
1254      _GL_ARG_NONNULL ((1));
1255 #endif
1256 
1257 #if 0
1258 /* Locate the first single-byte character C in the character string STRING,
1259    and return a pointer to it.  Return NULL if C is not found in STRING.
1260    Unlike strchr(), this function works correctly in multibyte locales with
1261    encodings such as GB18030.  */
1262 # if defined __hpux
1263 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1264 #   define mbschr rpl_mbschr /* avoid collision with HP-UX function */
1265 #  endif
1266 _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
1267                                   _GL_ATTRIBUTE_PURE
1268                                   _GL_ARG_NONNULL ((1)));
1269 _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
1270 # else
1271 _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
1272                                   _GL_ATTRIBUTE_PURE
1273                                   _GL_ARG_NONNULL ((1)));
1274 _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
1275 # endif
1276 _GL_CXXALIASWARN (mbschr);
1277 #endif
1278 
1279 #if 0
1280 /* Locate the last single-byte character C in the character string STRING,
1281    and return a pointer to it.  Return NULL if C is not found in STRING.
1282    Unlike strrchr(), this function works correctly in multibyte locales with
1283    encodings such as GB18030.  */
1284 # if defined __hpux || defined __INTERIX
1285 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1286 #   define mbsrchr rpl_mbsrchr /* avoid collision with system function */
1287 #  endif
1288 _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
1289                                    _GL_ATTRIBUTE_PURE
1290                                    _GL_ARG_NONNULL ((1)));
1291 _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
1292 # else
1293 _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
1294                                    _GL_ATTRIBUTE_PURE
1295                                    _GL_ARG_NONNULL ((1)));
1296 _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
1297 # endif
1298 _GL_CXXALIASWARN (mbsrchr);
1299 #endif
1300 
1301 #if 1
1302 /* Find the first occurrence of the character string NEEDLE in the character
1303    string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
1304    Unlike strstr(), this function works correctly in multibyte locales with
1305    encodings different from UTF-8.  */
1306 _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
1307      _GL_ATTRIBUTE_PURE
1308      _GL_ARG_NONNULL ((1, 2));
1309 #endif
1310 
1311 #if 1
1312 /* Compare the character strings S1 and S2, ignoring case, returning less than,
1313    equal to or greater than zero if S1 is lexicographically less than, equal to
1314    or greater than S2.
1315    Note: This function may, in multibyte locales, return 0 for strings of
1316    different lengths!
1317    Unlike strcasecmp(), this function works correctly in multibyte locales.  */
1318 _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
1319      _GL_ATTRIBUTE_PURE
1320      _GL_ARG_NONNULL ((1, 2));
1321 #endif
1322 
1323 #if 0
1324 /* Compare the initial segment of the character string S1 consisting of at most
1325    N characters with the initial segment of the character string S2 consisting
1326    of at most N characters, ignoring case, returning less than, equal to or
1327    greater than zero if the initial segment of S1 is lexicographically less
1328    than, equal to or greater than the initial segment of S2.
1329    Note: This function may, in multibyte locales, return 0 for initial segments
1330    of different lengths!
1331    Unlike strncasecmp(), this function works correctly in multibyte locales.
1332    But beware that N is not a byte count but a character count!  */
1333 _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
1334      _GL_ATTRIBUTE_PURE
1335      _GL_ARG_NONNULL ((1, 2));
1336 #endif
1337 
1338 #if 0
1339 /* Compare the initial segment of the character string STRING consisting of
1340    at most mbslen (PREFIX) characters with the character string PREFIX,
1341    ignoring case.  If the two match, return a pointer to the first byte
1342    after this prefix in STRING.  Otherwise, return NULL.
1343    Note: This function may, in multibyte locales, return non-NULL if STRING
1344    is of smaller length than PREFIX!
1345    Unlike strncasecmp(), this function works correctly in multibyte
1346    locales.  */
1347 _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1348      _GL_ATTRIBUTE_PURE
1349      _GL_ARG_NONNULL ((1, 2));
1350 #endif
1351 
1352 #if 0
1353 /* Find the first occurrence of the character string NEEDLE in the character
1354    string HAYSTACK, using case-insensitive comparison.
1355    Note: This function may, in multibyte locales, return success even if
1356    strlen (haystack) < strlen (needle) !
1357    Unlike strcasestr(), this function works correctly in multibyte locales.  */
1358 _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
1359      _GL_ATTRIBUTE_PURE
1360      _GL_ARG_NONNULL ((1, 2));
1361 #endif
1362 
1363 #if 0
1364 /* Find the first occurrence in the character string STRING of any character
1365    in the character string ACCEPT.  Return the number of bytes from the
1366    beginning of the string to this occurrence, or to the end of the string
1367    if none exists.
1368    Unlike strcspn(), this function works correctly in multibyte locales.  */
1369 _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
1370      _GL_ATTRIBUTE_PURE
1371      _GL_ARG_NONNULL ((1, 2));
1372 #endif
1373 
1374 #if 0
1375 /* Find the first occurrence in the character string STRING of any character
1376    in the character string ACCEPT.  Return the pointer to it, or NULL if none
1377    exists.
1378    Unlike strpbrk(), this function works correctly in multibyte locales.  */
1379 # if defined __hpux
1380 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1381 #   define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
1382 #  endif
1383 _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
1384                                    _GL_ATTRIBUTE_PURE
1385                                    _GL_ARG_NONNULL ((1, 2)));
1386 _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
1387 # else
1388 _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
1389                                    _GL_ATTRIBUTE_PURE
1390                                    _GL_ARG_NONNULL ((1, 2)));
1391 _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
1392 # endif
1393 _GL_CXXALIASWARN (mbspbrk);
1394 #endif
1395 
1396 #if 0
1397 /* Find the first occurrence in the character string STRING of any character
1398    not in the character string REJECT.  Return the number of bytes from the
1399    beginning of the string to this occurrence, or to the end of the string
1400    if none exists.
1401    Unlike strspn(), this function works correctly in multibyte locales.  */
1402 _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
1403      _GL_ATTRIBUTE_PURE
1404      _GL_ARG_NONNULL ((1, 2));
1405 #endif
1406 
1407 #if 0
1408 /* Search the next delimiter (multibyte character listed in the character
1409    string DELIM) starting at the character string *STRINGP.
1410    If one is found, overwrite it with a NUL, and advance *STRINGP to point
1411    to the next multibyte character after it.  Otherwise, set *STRINGP to NULL.
1412    If *STRINGP was already NULL, nothing happens.
1413    Return the old value of *STRINGP.
1414 
1415    This is a variant of mbstok_r() that supports empty fields.
1416 
1417    Caveat: It modifies the original string.
1418    Caveat: These functions cannot be used on constant strings.
1419    Caveat: The identity of the delimiting character is lost.
1420 
1421    See also mbstok_r().  */
1422 _GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
1423      _GL_ARG_NONNULL ((1, 2));
1424 #endif
1425 
1426 #if 0
1427 /* Parse the character string STRING into tokens separated by characters in
1428    the character string DELIM.
1429    If STRING is NULL, the saved pointer in SAVE_PTR is used as
1430    the next starting point.  For example:
1431         char s[] = "-abc-=-def";
1432         char *sp;
1433         x = mbstok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
1434         x = mbstok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
1435         x = mbstok_r(NULL, "=", &sp);   // x = NULL
1436                 // s = "abc\0-def\0"
1437 
1438    Caveat: It modifies the original string.
1439    Caveat: These functions cannot be used on constant strings.
1440    Caveat: The identity of the delimiting character is lost.
1441 
1442    See also mbssep().  */
1443 _GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
1444      _GL_ARG_NONNULL ((2, 3));
1445 #endif
1446 
1447 /* Map any int, typically from errno, into an error message.  */
1448 #if 1
1449 # if 1
1450 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1451 #   undef strerror
1452 #   define strerror rpl_strerror
1453 #  endif
1454 _GL_FUNCDECL_RPL (strerror, char *, (int));
1455 _GL_CXXALIAS_RPL (strerror, char *, (int));
1456 # else
1457 _GL_CXXALIAS_SYS (strerror, char *, (int));
1458 # endif
1459 # if __GLIBC__ >= 2
1460 _GL_CXXALIASWARN (strerror);
1461 # endif
1462 #elif defined GNULIB_POSIXCHECK
1463 # undef strerror
1464 /* Assume strerror is always declared.  */
1465 _GL_WARN_ON_USE (strerror, "strerror is unportable - "
1466                  "use gnulib module strerror to guarantee non-NULL result");
1467 #endif
1468 
1469 /* Map any int, typically from errno, into an error message.  Multithread-safe.
1470    Uses the POSIX declaration, not the glibc declaration.  */
1471 #if IN_GREP_GNULIB_TESTS
1472 # if 1
1473 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1474 #   undef strerror_r
1475 #   define strerror_r rpl_strerror_r
1476 #  endif
1477 _GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
1478                                    _GL_ARG_NONNULL ((2)));
1479 _GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
1480 # else
1481 #  if !1
1482 _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
1483                                    _GL_ARG_NONNULL ((2)));
1484 #  endif
1485 _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
1486 # endif
1487 # if 1
1488 _GL_CXXALIASWARN (strerror_r);
1489 # endif
1490 #elif defined GNULIB_POSIXCHECK
1491 # undef strerror_r
1492 # if HAVE_RAW_DECL_STRERROR_R
1493 _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1494                  "use gnulib module strerror_r-posix for portability");
1495 # endif
1496 #endif
1497 
1498 #if 0
1499 # if 0
1500 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1501 #   define strsignal rpl_strsignal
1502 #  endif
1503 _GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
1504 _GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
1505 # else
1506 #  if ! 1
1507 _GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
1508 #  endif
1509 /* Need to cast, because on Cygwin 1.5.x systems, the return type is
1510    'const char *'.  */
1511 _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
1512 # endif
1513 _GL_CXXALIASWARN (strsignal);
1514 #elif defined GNULIB_POSIXCHECK
1515 # undef strsignal
1516 # if HAVE_RAW_DECL_STRSIGNAL
1517 _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
1518                  "use gnulib module strsignal for portability");
1519 # endif
1520 #endif
1521 
1522 #if 0
1523 # if !1
1524 _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
1525                                    _GL_ATTRIBUTE_PURE
1526                                    _GL_ARG_NONNULL ((1, 2)));
1527 # endif
1528 _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
1529 _GL_CXXALIASWARN (strverscmp);
1530 #elif defined GNULIB_POSIXCHECK
1531 # undef strverscmp
1532 # if HAVE_RAW_DECL_STRVERSCMP
1533 _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1534                  "use gnulib module strverscmp for portability");
1535 # endif
1536 #endif
1537 
1538 
1539 #endif /* _GL_STRING_H */
1540 #endif /* _GL_STRING_H */
1541 #endif
1542