1 /* A GNU-like <string.h>.
2 
3    Copyright (C) 1995-1996, 2001-2021 Free Software Foundation, Inc.
4 
5    This file is free software: you can redistribute it and/or modify
6    it under the terms of the GNU Lesser General Public License as
7    published by the Free Software Foundation; either version 2.1 of the
8    License, or (at your option) any later version.
9 
10    This file is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public License
16    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
17 
18 #if __GNUC__ >= 3
19 @PRAGMA_SYSTEM_HEADER@
20 #endif
21 @PRAGMA_COLUMNS@
22 
23 #if defined _GL_ALREADY_INCLUDING_STRING_H
24 /* Special invocation convention:
25    - On OS X/NetBSD we have a sequence of nested includes
26        <string.h> -> <strings.h> -> "string.h"
27      In this situation system _chk variants due to -D_FORTIFY_SOURCE
28      might be used after any replacements defined here.  */
29 
30 #@INCLUDE_NEXT@ @NEXT_STRING_H@
31 
32 #else
33 /* Normal invocation convention.  */
34 
35 #ifndef _@GUARD_PREFIX@_STRING_H
36 
37 #define _GL_ALREADY_INCLUDING_STRING_H
38 
39 /* The include_next requires a split double-inclusion guard.  */
40 #@INCLUDE_NEXT@ @NEXT_STRING_H@
41 
42 #undef _GL_ALREADY_INCLUDING_STRING_H
43 
44 #ifndef _@GUARD_PREFIX@_STRING_H
45 #define _@GUARD_PREFIX@_STRING_H
46 
47 /* NetBSD 5.0 mis-defines NULL.  */
48 #include <stddef.h>
49 
50 /* MirBSD defines mbslen as a macro.  */
51 #if @GNULIB_MBSLEN@ && defined __MirBSD__
52 # include <wchar.h>
53 #endif
54 
55 /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>.  */
56 /* But in any case avoid namespace pollution on glibc systems.  */
57 #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
58     && ! defined __GLIBC__
59 # include <unistd.h>
60 #endif
61 
62 /* AIX 7.2 declares ffsl and ffsll in <strings.h>, not in <string.h>.  */
63 /* But in any case avoid namespace pollution on glibc systems.  */
64 #if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \
65      && defined _AIX) \
66     && ! defined __GLIBC__
67 # include <strings.h>
68 #endif
69 
70 /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
71    that can be freed by passing them as the Ith argument to the
72    function F.  */
73 #ifndef _GL_ATTRIBUTE_DEALLOC
74 # if __GNUC__ >= 11
75 #  define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
76 # else
77 #  define _GL_ATTRIBUTE_DEALLOC(f, i)
78 # endif
79 #endif
80 
81 /* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
82    can be freed via 'free'; it can be used only after declaring 'free'.  */
83 /* Applies to: functions.  Cannot be used on inline functions.  */
84 #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
85 # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
86 #endif
87 
88 /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
89    allocated memory.  */
90 /* Applies to: functions.  */
91 #ifndef _GL_ATTRIBUTE_MALLOC
92 # if __GNUC__ >= 3 || defined __clang__
93 #  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
94 # else
95 #  define _GL_ATTRIBUTE_MALLOC
96 # endif
97 #endif
98 
99 /* The __attribute__ feature is available in gcc versions 2.5 and later.
100    The attribute __pure__ was added in gcc 2.96.  */
101 #ifndef _GL_ATTRIBUTE_PURE
102 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
103 #  define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
104 # else
105 #  define _GL_ATTRIBUTE_PURE /* empty */
106 # endif
107 #endif
108 
109 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
110 
111 /* The definition of _GL_ARG_NONNULL is copied here.  */
112 
113 /* The definition of _GL_WARN_ON_USE is copied here.  */
114 
115 /* Declare 'free' if needed for _GL_ATTRIBUTE_DEALLOC_FREE.  */
116 _GL_EXTERN_C void free (void *);
117 #if @GNULIB_FREE_POSIX@
118 # if (@REPLACE_FREE@ && !defined free \
119       && !(defined __cplusplus && defined GNULIB_NAMESPACE))
120 #  define free rpl_free
121 _GL_EXTERN_C void free (void *);
122 # endif
123 #endif
124 
125 /* Clear a block of memory.  The compiler will not delete a call to
126    this function, even if the block is dead after the call.  */
127 #if @GNULIB_EXPLICIT_BZERO@
128 # if ! @HAVE_EXPLICIT_BZERO@
129 _GL_FUNCDECL_SYS (explicit_bzero, void,
130                   (void *__dest, size_t __n) _GL_ARG_NONNULL ((1)));
131 # endif
132 _GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
133 _GL_CXXALIASWARN (explicit_bzero);
134 #elif defined GNULIB_POSIXCHECK
135 # undef explicit_bzero
136 # if HAVE_RAW_DECL_EXPLICIT_BZERO
137 _GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
138                  "use gnulib module explicit_bzero for portability");
139 # endif
140 #endif
141 
142 /* Find the index of the least-significant set bit.  */
143 #if @GNULIB_FFSL@
144 # if !@HAVE_FFSL@
145 _GL_FUNCDECL_SYS (ffsl, int, (long int i));
146 # endif
147 _GL_CXXALIAS_SYS (ffsl, int, (long int i));
148 _GL_CXXALIASWARN (ffsl);
149 #elif defined GNULIB_POSIXCHECK
150 # undef ffsl
151 # if HAVE_RAW_DECL_FFSL
152 _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
153 # endif
154 #endif
155 
156 
157 /* Find the index of the least-significant set bit.  */
158 #if @GNULIB_FFSLL@
159 # if @REPLACE_FFSLL@
160 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
161 #   define ffsll rpl_ffsll
162 #  endif
163 _GL_FUNCDECL_RPL (ffsll, int, (long long int i));
164 _GL_CXXALIAS_RPL (ffsll, int, (long long int i));
165 # else
166 #  if !@HAVE_FFSLL@
167 _GL_FUNCDECL_SYS (ffsll, int, (long long int i));
168 #  endif
169 _GL_CXXALIAS_SYS (ffsll, int, (long long int i));
170 # endif
171 _GL_CXXALIASWARN (ffsll);
172 #elif defined GNULIB_POSIXCHECK
173 # undef ffsll
174 # if HAVE_RAW_DECL_FFSLL
175 _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
176 # endif
177 #endif
178 
179 
180 #if @GNULIB_MDA_MEMCCPY@
181 /* On native Windows, map 'memccpy' to '_memccpy', so that -loldnames is not
182    required.  In C++ with GNULIB_NAMESPACE, avoid differences between
183    platforms by defining GNULIB_NAMESPACE::memccpy always.  */
184 # if defined _WIN32 && !defined __CYGWIN__
185 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
186 #   undef memccpy
187 #   define memccpy _memccpy
188 #  endif
189 _GL_CXXALIAS_MDA (memccpy, void *,
190                   (void *dest, const void *src, int c, size_t n));
191 # else
192 _GL_CXXALIAS_SYS (memccpy, void *,
193                   (void *dest, const void *src, int c, size_t n));
194 # endif
195 _GL_CXXALIASWARN (memccpy);
196 #endif
197 
198 
199 /* Return the first instance of C within N bytes of S, or NULL.  */
200 #if @GNULIB_MEMCHR@
201 # if @REPLACE_MEMCHR@
202 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
203 #   undef memchr
204 #   define memchr rpl_memchr
205 #  endif
206 _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
207                                   _GL_ATTRIBUTE_PURE
208                                   _GL_ARG_NONNULL ((1)));
209 _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
210 # else
211   /* On some systems, this function is defined as an overloaded function:
212        extern "C" { const void * std::memchr (const void *, int, size_t); }
213        extern "C++" { void * std::memchr (void *, int, size_t); }  */
214 _GL_CXXALIAS_SYS_CAST2 (memchr,
215                         void *, (void const *__s, int __c, size_t __n),
216                         void const *, (void const *__s, int __c, size_t __n));
217 # endif
218 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
219      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
220 _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
221 _GL_CXXALIASWARN1 (memchr, void const *,
222                    (void const *__s, int __c, size_t __n));
223 # elif __GLIBC__ >= 2
224 _GL_CXXALIASWARN (memchr);
225 # endif
226 #elif defined GNULIB_POSIXCHECK
227 # undef memchr
228 /* Assume memchr is always declared.  */
229 _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
230                  "use gnulib module memchr for portability" );
231 #endif
232 
233 /* Return the first occurrence of NEEDLE in HAYSTACK.  */
234 #if @GNULIB_MEMMEM@
235 # if @REPLACE_MEMMEM@
236 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
237 #   define memmem rpl_memmem
238 #  endif
239 _GL_FUNCDECL_RPL (memmem, void *,
240                   (void const *__haystack, size_t __haystack_len,
241                    void const *__needle, size_t __needle_len)
242                   _GL_ATTRIBUTE_PURE
243                   _GL_ARG_NONNULL ((1, 3)));
244 _GL_CXXALIAS_RPL (memmem, void *,
245                   (void const *__haystack, size_t __haystack_len,
246                    void const *__needle, size_t __needle_len));
247 # else
248 #  if ! @HAVE_DECL_MEMMEM@
249 _GL_FUNCDECL_SYS (memmem, void *,
250                   (void const *__haystack, size_t __haystack_len,
251                    void const *__needle, size_t __needle_len)
252                   _GL_ATTRIBUTE_PURE
253                   _GL_ARG_NONNULL ((1, 3)));
254 #  endif
255 _GL_CXXALIAS_SYS (memmem, void *,
256                   (void const *__haystack, size_t __haystack_len,
257                    void const *__needle, size_t __needle_len));
258 # endif
259 _GL_CXXALIASWARN (memmem);
260 #elif defined GNULIB_POSIXCHECK
261 # undef memmem
262 # if HAVE_RAW_DECL_MEMMEM
263 _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
264                  "use gnulib module memmem-simple for portability, "
265                  "and module memmem for speed" );
266 # endif
267 #endif
268 
269 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
270    last written byte.  */
271 #if @GNULIB_MEMPCPY@
272 # if ! @HAVE_MEMPCPY@
273 _GL_FUNCDECL_SYS (mempcpy, void *,
274                   (void *restrict __dest, void const *restrict __src,
275                    size_t __n)
276                   _GL_ARG_NONNULL ((1, 2)));
277 # endif
278 _GL_CXXALIAS_SYS (mempcpy, void *,
279                   (void *restrict __dest, void const *restrict __src,
280                    size_t __n));
281 _GL_CXXALIASWARN (mempcpy);
282 #elif defined GNULIB_POSIXCHECK
283 # undef mempcpy
284 # if HAVE_RAW_DECL_MEMPCPY
285 _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
286                  "use gnulib module mempcpy for portability");
287 # endif
288 #endif
289 
290 /* Search backwards through a block for a byte (specified as an int).  */
291 #if @GNULIB_MEMRCHR@
292 # if ! @HAVE_DECL_MEMRCHR@
293 _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
294                                    _GL_ATTRIBUTE_PURE
295                                    _GL_ARG_NONNULL ((1)));
296 # endif
297   /* On some systems, this function is defined as an overloaded function:
298        extern "C++" { const void * std::memrchr (const void *, int, size_t); }
299        extern "C++" { void * std::memrchr (void *, int, size_t); }  */
300 _GL_CXXALIAS_SYS_CAST2 (memrchr,
301                         void *, (void const *, int, size_t),
302                         void const *, (void const *, int, size_t));
303 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
304      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
305 _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
306 _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
307 # else
308 _GL_CXXALIASWARN (memrchr);
309 # endif
310 #elif defined GNULIB_POSIXCHECK
311 # undef memrchr
312 # if HAVE_RAW_DECL_MEMRCHR
313 _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
314                  "use gnulib module memrchr for portability");
315 # endif
316 #endif
317 
318 /* Find the first occurrence of C in S.  More efficient than
319    memchr(S,C,N), at the expense of undefined behavior if C does not
320    occur within N bytes.  */
321 #if @GNULIB_RAWMEMCHR@
322 # if ! @HAVE_RAWMEMCHR@
323 _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
324                                      _GL_ATTRIBUTE_PURE
325                                      _GL_ARG_NONNULL ((1)));
326 # endif
327   /* On some systems, this function is defined as an overloaded function:
328        extern "C++" { const void * std::rawmemchr (const void *, int); }
329        extern "C++" { void * std::rawmemchr (void *, int); }  */
330 _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
331                         void *, (void const *__s, int __c_in),
332                         void const *, (void const *__s, int __c_in));
333 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
334      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
335 _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
336 _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
337 # else
338 _GL_CXXALIASWARN (rawmemchr);
339 # endif
340 #elif defined GNULIB_POSIXCHECK
341 # undef rawmemchr
342 # if HAVE_RAW_DECL_RAWMEMCHR
343 _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
344                  "use gnulib module rawmemchr for portability");
345 # endif
346 #endif
347 
348 /* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
349 #if @GNULIB_STPCPY@
350 # if ! @HAVE_STPCPY@
351 _GL_FUNCDECL_SYS (stpcpy, char *,
352                   (char *restrict __dst, char const *restrict __src)
353                   _GL_ARG_NONNULL ((1, 2)));
354 # endif
355 _GL_CXXALIAS_SYS (stpcpy, char *,
356                   (char *restrict __dst, char const *restrict __src));
357 _GL_CXXALIASWARN (stpcpy);
358 #elif defined GNULIB_POSIXCHECK
359 # undef stpcpy
360 # if HAVE_RAW_DECL_STPCPY
361 _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
362                  "use gnulib module stpcpy for portability");
363 # endif
364 #endif
365 
366 /* Copy no more than N bytes of SRC to DST, returning a pointer past the
367    last non-NUL byte written into DST.  */
368 #if @GNULIB_STPNCPY@
369 # if @REPLACE_STPNCPY@
370 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
371 #   undef stpncpy
372 #   define stpncpy rpl_stpncpy
373 #  endif
374 _GL_FUNCDECL_RPL (stpncpy, char *,
375                   (char *restrict __dst, char const *restrict __src,
376                    size_t __n)
377                   _GL_ARG_NONNULL ((1, 2)));
378 _GL_CXXALIAS_RPL (stpncpy, char *,
379                   (char *restrict __dst, char const *restrict __src,
380                    size_t __n));
381 # else
382 #  if ! @HAVE_STPNCPY@
383 _GL_FUNCDECL_SYS (stpncpy, char *,
384                   (char *restrict __dst, char const *restrict __src,
385                    size_t __n)
386                   _GL_ARG_NONNULL ((1, 2)));
387 #  endif
388 _GL_CXXALIAS_SYS (stpncpy, char *,
389                   (char *restrict __dst, char const *restrict __src,
390                    size_t __n));
391 # endif
392 _GL_CXXALIASWARN (stpncpy);
393 #elif defined GNULIB_POSIXCHECK
394 # undef stpncpy
395 # if HAVE_RAW_DECL_STPNCPY
396 _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
397                  "use gnulib module stpncpy for portability");
398 # endif
399 #endif
400 
401 #if defined GNULIB_POSIXCHECK
402 /* strchr() does not work with multibyte strings if the locale encoding is
403    GB18030 and the character to be searched is a digit.  */
404 # undef strchr
405 /* Assume strchr is always declared.  */
406 _GL_WARN_ON_USE_CXX (strchr,
407                      const char *, char *, (const char *, int),
408                      "strchr cannot work correctly on character strings "
409                      "in some multibyte locales - "
410                      "use mbschr if you care about internationalization");
411 #endif
412 
413 /* Find the first occurrence of C in S or the final NUL byte.  */
414 #if @GNULIB_STRCHRNUL@
415 # if @REPLACE_STRCHRNUL@
416 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
417 #   define strchrnul rpl_strchrnul
418 #  endif
419 _GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
420                                      _GL_ATTRIBUTE_PURE
421                                      _GL_ARG_NONNULL ((1)));
422 _GL_CXXALIAS_RPL (strchrnul, char *,
423                   (const char *str, int ch));
424 # else
425 #  if ! @HAVE_STRCHRNUL@
426 _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
427                                      _GL_ATTRIBUTE_PURE
428                                      _GL_ARG_NONNULL ((1)));
429 #  endif
430   /* On some systems, this function is defined as an overloaded function:
431        extern "C++" { const char * std::strchrnul (const char *, int); }
432        extern "C++" { char * std::strchrnul (char *, int); }  */
433 _GL_CXXALIAS_SYS_CAST2 (strchrnul,
434                         char *, (char const *__s, int __c_in),
435                         char const *, (char const *__s, int __c_in));
436 # endif
437 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
438      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
439 _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
440 _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
441 # else
442 _GL_CXXALIASWARN (strchrnul);
443 # endif
444 #elif defined GNULIB_POSIXCHECK
445 # undef strchrnul
446 # if HAVE_RAW_DECL_STRCHRNUL
447 _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
448                  "use gnulib module strchrnul for portability");
449 # endif
450 #endif
451 
452 /* Duplicate S, returning an identical malloc'd string.  */
453 #if @GNULIB_STRDUP@
454 # if @REPLACE_STRDUP@
455 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
456 #   undef strdup
457 #   define strdup rpl_strdup
458 #  endif
459 _GL_FUNCDECL_RPL (strdup, char *,
460                   (char const *__s)
461                   _GL_ARG_NONNULL ((1))
462                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
463 _GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
464 # elif defined _WIN32 && !defined __CYGWIN__
465 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
466 #   undef strdup
467 #   define strdup _strdup
468 #  endif
469 _GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
470 # else
471 #  if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
472     /* strdup exists as a function and as a macro.  Get rid of the macro.  */
473 #   undef strdup
474 #  endif
475 #  if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup
476 _GL_FUNCDECL_SYS (strdup, char *,
477                   (char const *__s)
478                   _GL_ARG_NONNULL ((1))
479                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
480 #  endif
481 _GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
482 # endif
483 _GL_CXXALIASWARN (strdup);
484 #else
485 # if __GNUC__ >= 11 && !defined strdup
486 /* For -Wmismatched-dealloc: Associate strdup with free or rpl_free.  */
487 _GL_FUNCDECL_SYS (strdup, char *,
488                   (char const *__s)
489                   _GL_ARG_NONNULL ((1))
490                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
491 # endif
492 # if defined GNULIB_POSIXCHECK
493 #  undef strdup
494 #  if HAVE_RAW_DECL_STRDUP
495 _GL_WARN_ON_USE (strdup, "strdup is unportable - "
496                  "use gnulib module strdup for portability");
497 #  endif
498 # elif @GNULIB_MDA_STRDUP@
499 /* On native Windows, map 'creat' to '_creat', so that -loldnames is not
500    required.  In C++ with GNULIB_NAMESPACE, avoid differences between
501    platforms by defining GNULIB_NAMESPACE::strdup always.  */
502 #  if defined _WIN32 && !defined __CYGWIN__
503 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
504 #    undef strdup
505 #    define strdup _strdup
506 #   endif
507 _GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
508 #  else
509 #   if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
510 #    undef strdup
511 #   endif
512 _GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
513 #  endif
514 _GL_CXXALIASWARN (strdup);
515 # endif
516 #endif
517 
518 /* Append no more than N characters from SRC onto DEST.  */
519 #if @GNULIB_STRNCAT@
520 # if @REPLACE_STRNCAT@
521 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
522 #   undef strncat
523 #   define strncat rpl_strncat
524 #  endif
525 _GL_FUNCDECL_RPL (strncat, char *,
526                   (char *restrict dest, const char *restrict src, size_t n)
527                   _GL_ARG_NONNULL ((1, 2)));
528 _GL_CXXALIAS_RPL (strncat, char *,
529                   (char *restrict dest, const char *restrict src, size_t n));
530 # else
531 _GL_CXXALIAS_SYS (strncat, char *,
532                   (char *restrict dest, const char *restrict src, size_t n));
533 # endif
534 # if __GLIBC__ >= 2
535 _GL_CXXALIASWARN (strncat);
536 # endif
537 #elif defined GNULIB_POSIXCHECK
538 # undef strncat
539 # if HAVE_RAW_DECL_STRNCAT
540 _GL_WARN_ON_USE (strncat, "strncat is unportable - "
541                  "use gnulib module strncat for portability");
542 # endif
543 #endif
544 
545 /* Return a newly allocated copy of at most N bytes of STRING.  */
546 #if @GNULIB_STRNDUP@
547 # if @REPLACE_STRNDUP@
548 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
549 #   undef strndup
550 #   define strndup rpl_strndup
551 #  endif
552 _GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n)
553                                    _GL_ARG_NONNULL ((1)));
554 _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
555 # else
556 #  if ! @HAVE_DECL_STRNDUP@
557 _GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n)
558                                    _GL_ARG_NONNULL ((1)));
559 #  endif
560 _GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
561 # endif
562 _GL_CXXALIASWARN (strndup);
563 #elif defined GNULIB_POSIXCHECK
564 # undef strndup
565 # if HAVE_RAW_DECL_STRNDUP
566 _GL_WARN_ON_USE (strndup, "strndup is unportable - "
567                  "use gnulib module strndup for portability");
568 # endif
569 #endif
570 
571 /* Find the length (number of bytes) of STRING, but scan at most
572    MAXLEN bytes.  If no '\0' terminator is found in that many bytes,
573    return MAXLEN.  */
574 #if @GNULIB_STRNLEN@
575 # if @REPLACE_STRNLEN@
576 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
577 #   undef strnlen
578 #   define strnlen rpl_strnlen
579 #  endif
580 _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)
581                                    _GL_ATTRIBUTE_PURE
582                                    _GL_ARG_NONNULL ((1)));
583 _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
584 # else
585 #  if ! @HAVE_DECL_STRNLEN@
586 _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)
587                                    _GL_ATTRIBUTE_PURE
588                                    _GL_ARG_NONNULL ((1)));
589 #  endif
590 _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
591 # endif
592 _GL_CXXALIASWARN (strnlen);
593 #elif defined GNULIB_POSIXCHECK
594 # undef strnlen
595 # if HAVE_RAW_DECL_STRNLEN
596 _GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
597                  "use gnulib module strnlen for portability");
598 # endif
599 #endif
600 
601 #if defined GNULIB_POSIXCHECK
602 /* strcspn() assumes the second argument is a list of single-byte characters.
603    Even in this simple case, it does not work with multibyte strings if the
604    locale encoding is GB18030 and one of the characters to be searched is a
605    digit.  */
606 # undef strcspn
607 /* Assume strcspn is always declared.  */
608 _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
609                  "in multibyte locales - "
610                  "use mbscspn if you care about internationalization");
611 #endif
612 
613 /* Find the first occurrence in S of any character in ACCEPT.  */
614 #if @GNULIB_STRPBRK@
615 # if ! @HAVE_STRPBRK@
616 _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
617                                    _GL_ATTRIBUTE_PURE
618                                    _GL_ARG_NONNULL ((1, 2)));
619 # endif
620   /* On some systems, this function is defined as an overloaded function:
621        extern "C" { const char * strpbrk (const char *, const char *); }
622        extern "C++" { char * strpbrk (char *, const char *); }  */
623 _GL_CXXALIAS_SYS_CAST2 (strpbrk,
624                         char *, (char const *__s, char const *__accept),
625                         const char *, (char const *__s, char const *__accept));
626 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
627      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
628 _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
629 _GL_CXXALIASWARN1 (strpbrk, char const *,
630                    (char const *__s, char const *__accept));
631 # elif __GLIBC__ >= 2
632 _GL_CXXALIASWARN (strpbrk);
633 # endif
634 # if defined GNULIB_POSIXCHECK
635 /* strpbrk() assumes the second argument is a list of single-byte characters.
636    Even in this simple case, it does not work with multibyte strings if the
637    locale encoding is GB18030 and one of the characters to be searched is a
638    digit.  */
639 #  undef strpbrk
640 _GL_WARN_ON_USE_CXX (strpbrk,
641                      const char *, char *, (const char *, const char *),
642                      "strpbrk cannot work correctly on character strings "
643                      "in multibyte locales - "
644                      "use mbspbrk if you care about internationalization");
645 # endif
646 #elif defined GNULIB_POSIXCHECK
647 # undef strpbrk
648 # if HAVE_RAW_DECL_STRPBRK
649 _GL_WARN_ON_USE_CXX (strpbrk,
650                      const char *, char *, (const char *, const char *),
651                      "strpbrk is unportable - "
652                      "use gnulib module strpbrk for portability");
653 # endif
654 #endif
655 
656 #if defined GNULIB_POSIXCHECK
657 /* strspn() assumes the second argument is a list of single-byte characters.
658    Even in this simple case, it cannot work with multibyte strings.  */
659 # undef strspn
660 /* Assume strspn is always declared.  */
661 _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
662                  "in multibyte locales - "
663                  "use mbsspn if you care about internationalization");
664 #endif
665 
666 #if defined GNULIB_POSIXCHECK
667 /* strrchr() does not work with multibyte strings if the locale encoding is
668    GB18030 and the character to be searched is a digit.  */
669 # undef strrchr
670 /* Assume strrchr is always declared.  */
671 _GL_WARN_ON_USE_CXX (strrchr,
672                      const char *, char *, (const char *, int),
673                      "strrchr cannot work correctly on character strings "
674                      "in some multibyte locales - "
675                      "use mbsrchr if you care about internationalization");
676 #endif
677 
678 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
679    If one is found, overwrite it with a NUL, and advance *STRINGP
680    to point to the next char after it.  Otherwise, set *STRINGP to NULL.
681    If *STRINGP was already NULL, nothing happens.
682    Return the old value of *STRINGP.
683 
684    This is a variant of strtok() that is multithread-safe and supports
685    empty fields.
686 
687    Caveat: It modifies the original string.
688    Caveat: These functions cannot be used on constant strings.
689    Caveat: The identity of the delimiting character is lost.
690    Caveat: It doesn't work with multibyte strings unless all of the delimiter
691            characters are ASCII characters < 0x30.
692 
693    See also strtok_r().  */
694 #if @GNULIB_STRSEP@
695 # if ! @HAVE_STRSEP@
696 _GL_FUNCDECL_SYS (strsep, char *,
697                   (char **restrict __stringp, char const *restrict __delim)
698                   _GL_ARG_NONNULL ((1, 2)));
699 # endif
700 _GL_CXXALIAS_SYS (strsep, char *,
701                   (char **restrict __stringp, char const *restrict __delim));
702 _GL_CXXALIASWARN (strsep);
703 # if defined GNULIB_POSIXCHECK
704 #  undef strsep
705 _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
706                  "in multibyte locales - "
707                  "use mbssep if you care about internationalization");
708 # endif
709 #elif defined GNULIB_POSIXCHECK
710 # undef strsep
711 # if HAVE_RAW_DECL_STRSEP
712 _GL_WARN_ON_USE (strsep, "strsep is unportable - "
713                  "use gnulib module strsep for portability");
714 # endif
715 #endif
716 
717 #if @GNULIB_STRSTR@
718 # if @REPLACE_STRSTR@
719 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
720 #   define strstr rpl_strstr
721 #  endif
722 _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
723                                   _GL_ATTRIBUTE_PURE
724                                   _GL_ARG_NONNULL ((1, 2)));
725 _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
726 # else
727   /* On some systems, this function is defined as an overloaded function:
728        extern "C++" { const char * strstr (const char *, const char *); }
729        extern "C++" { char * strstr (char *, const char *); }  */
730 _GL_CXXALIAS_SYS_CAST2 (strstr,
731                         char *, (const char *haystack, const char *needle),
732                         const char *, (const char *haystack, const char *needle));
733 # endif
734 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
735      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
736 _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
737 _GL_CXXALIASWARN1 (strstr, const char *,
738                    (const char *haystack, const char *needle));
739 # elif __GLIBC__ >= 2
740 _GL_CXXALIASWARN (strstr);
741 # endif
742 #elif defined GNULIB_POSIXCHECK
743 /* strstr() does not work with multibyte strings if the locale encoding is
744    different from UTF-8:
745    POSIX says that it operates on "strings", and "string" in POSIX is defined
746    as a sequence of bytes, not of characters.  */
747 # undef strstr
748 /* Assume strstr is always declared.  */
749 _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
750                  "work correctly on character strings in most "
751                  "multibyte locales - "
752                  "use mbsstr if you care about internationalization, "
753                  "or use strstr if you care about speed");
754 #endif
755 
756 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
757    comparison.  */
758 #if @GNULIB_STRCASESTR@
759 # if @REPLACE_STRCASESTR@
760 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
761 #   define strcasestr rpl_strcasestr
762 #  endif
763 _GL_FUNCDECL_RPL (strcasestr, char *,
764                   (const char *haystack, const char *needle)
765                   _GL_ATTRIBUTE_PURE
766                   _GL_ARG_NONNULL ((1, 2)));
767 _GL_CXXALIAS_RPL (strcasestr, char *,
768                   (const char *haystack, const char *needle));
769 # else
770 #  if ! @HAVE_STRCASESTR@
771 _GL_FUNCDECL_SYS (strcasestr, char *,
772                   (const char *haystack, const char *needle)
773                   _GL_ATTRIBUTE_PURE
774                   _GL_ARG_NONNULL ((1, 2)));
775 #  endif
776   /* On some systems, this function is defined as an overloaded function:
777        extern "C++" { const char * strcasestr (const char *, const char *); }
778        extern "C++" { char * strcasestr (char *, const char *); }  */
779 _GL_CXXALIAS_SYS_CAST2 (strcasestr,
780                         char *, (const char *haystack, const char *needle),
781                         const char *, (const char *haystack, const char *needle));
782 # endif
783 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
784      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
785 _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
786 _GL_CXXALIASWARN1 (strcasestr, const char *,
787                    (const char *haystack, const char *needle));
788 # else
789 _GL_CXXALIASWARN (strcasestr);
790 # endif
791 #elif defined GNULIB_POSIXCHECK
792 /* strcasestr() does not work with multibyte strings:
793    It is a glibc extension, and glibc implements it only for unibyte
794    locales.  */
795 # undef strcasestr
796 # if HAVE_RAW_DECL_STRCASESTR
797 _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
798                  "strings in multibyte locales - "
799                  "use mbscasestr if you care about "
800                  "internationalization, or use c-strcasestr if you want "
801                  "a locale independent function");
802 # endif
803 #endif
804 
805 /* Parse S into tokens separated by characters in DELIM.
806    If S is NULL, the saved pointer in SAVE_PTR is used as
807    the next starting point.  For example:
808         char s[] = "-abc-=-def";
809         char *sp;
810         x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
811         x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
812         x = strtok_r(NULL, "=", &sp);   // x = NULL
813                 // s = "abc\0-def\0"
814 
815    This is a variant of strtok() that is multithread-safe.
816 
817    For the POSIX documentation for this function, see:
818    https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html
819 
820    Caveat: It modifies the original string.
821    Caveat: These functions cannot be used on constant strings.
822    Caveat: The identity of the delimiting character is lost.
823    Caveat: It doesn't work with multibyte strings unless all of the delimiter
824            characters are ASCII characters < 0x30.
825 
826    See also strsep().  */
827 #if @GNULIB_STRTOK_R@
828 # if @REPLACE_STRTOK_R@
829 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
830 #   undef strtok_r
831 #   define strtok_r rpl_strtok_r
832 #  endif
833 _GL_FUNCDECL_RPL (strtok_r, char *,
834                   (char *restrict s, char const *restrict delim,
835                    char **restrict save_ptr)
836                   _GL_ARG_NONNULL ((2, 3)));
837 _GL_CXXALIAS_RPL (strtok_r, char *,
838                   (char *restrict s, char const *restrict delim,
839                    char **restrict save_ptr));
840 # else
841 #  if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
842 #   undef strtok_r
843 #  endif
844 #  if ! @HAVE_DECL_STRTOK_R@
845 _GL_FUNCDECL_SYS (strtok_r, char *,
846                   (char *restrict s, char const *restrict delim,
847                    char **restrict save_ptr)
848                   _GL_ARG_NONNULL ((2, 3)));
849 #  endif
850 _GL_CXXALIAS_SYS (strtok_r, char *,
851                   (char *restrict s, char const *restrict delim,
852                    char **restrict save_ptr));
853 # endif
854 _GL_CXXALIASWARN (strtok_r);
855 # if defined GNULIB_POSIXCHECK
856 _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
857                  "strings in multibyte locales - "
858                  "use mbstok_r if you care about internationalization");
859 # endif
860 #elif defined GNULIB_POSIXCHECK
861 # undef strtok_r
862 # if HAVE_RAW_DECL_STRTOK_R
863 _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
864                  "use gnulib module strtok_r for portability");
865 # endif
866 #endif
867 
868 
869 /* The following functions are not specified by POSIX.  They are gnulib
870    extensions.  */
871 
872 #if @GNULIB_MBSLEN@
873 /* Return the number of multibyte characters in the character string STRING.
874    This considers multibyte characters, unlike strlen, which counts bytes.  */
875 # ifdef __MirBSD__  /* MirBSD defines mbslen as a macro.  Override it.  */
876 #  undef mbslen
877 # endif
878 # if @HAVE_MBSLEN@  /* AIX, OSF/1, MirBSD define mbslen already in libc.  */
879 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
880 #   define mbslen rpl_mbslen
881 #  endif
882 _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string)
883                                   _GL_ATTRIBUTE_PURE
884                                   _GL_ARG_NONNULL ((1)));
885 _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
886 # else
887 _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
888                                   _GL_ATTRIBUTE_PURE
889                                   _GL_ARG_NONNULL ((1)));
890 _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
891 # endif
892 _GL_CXXALIASWARN (mbslen);
893 #endif
894 
895 #if @GNULIB_MBSNLEN@
896 /* Return the number of multibyte characters in the character string starting
897    at STRING and ending at STRING + LEN.  */
898 _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
899      _GL_ATTRIBUTE_PURE
900      _GL_ARG_NONNULL ((1));
901 #endif
902 
903 #if @GNULIB_MBSCHR@
904 /* Locate the first single-byte character C in the character string STRING,
905    and return a pointer to it.  Return NULL if C is not found in STRING.
906    Unlike strchr(), this function works correctly in multibyte locales with
907    encodings such as GB18030.  */
908 # if defined __hpux
909 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
910 #   define mbschr rpl_mbschr /* avoid collision with HP-UX function */
911 #  endif
912 _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
913                                   _GL_ATTRIBUTE_PURE
914                                   _GL_ARG_NONNULL ((1)));
915 _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
916 # else
917 _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
918                                   _GL_ATTRIBUTE_PURE
919                                   _GL_ARG_NONNULL ((1)));
920 _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
921 # endif
922 _GL_CXXALIASWARN (mbschr);
923 #endif
924 
925 #if @GNULIB_MBSRCHR@
926 /* Locate the last single-byte character C in the character string STRING,
927    and return a pointer to it.  Return NULL if C is not found in STRING.
928    Unlike strrchr(), this function works correctly in multibyte locales with
929    encodings such as GB18030.  */
930 # if defined __hpux || defined __INTERIX
931 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
932 #   define mbsrchr rpl_mbsrchr /* avoid collision with system function */
933 #  endif
934 _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
935                                    _GL_ATTRIBUTE_PURE
936                                    _GL_ARG_NONNULL ((1)));
937 _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
938 # else
939 _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
940                                    _GL_ATTRIBUTE_PURE
941                                    _GL_ARG_NONNULL ((1)));
942 _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
943 # endif
944 _GL_CXXALIASWARN (mbsrchr);
945 #endif
946 
947 #if @GNULIB_MBSSTR@
948 /* Find the first occurrence of the character string NEEDLE in the character
949    string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
950    Unlike strstr(), this function works correctly in multibyte locales with
951    encodings different from UTF-8.  */
952 _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
953      _GL_ATTRIBUTE_PURE
954      _GL_ARG_NONNULL ((1, 2));
955 #endif
956 
957 #if @GNULIB_MBSCASECMP@
958 /* Compare the character strings S1 and S2, ignoring case, returning less than,
959    equal to or greater than zero if S1 is lexicographically less than, equal to
960    or greater than S2.
961    Note: This function may, in multibyte locales, return 0 for strings of
962    different lengths!
963    Unlike strcasecmp(), this function works correctly in multibyte locales.  */
964 _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
965      _GL_ATTRIBUTE_PURE
966      _GL_ARG_NONNULL ((1, 2));
967 #endif
968 
969 #if @GNULIB_MBSNCASECMP@
970 /* Compare the initial segment of the character string S1 consisting of at most
971    N characters with the initial segment of the character string S2 consisting
972    of at most N characters, ignoring case, returning less than, equal to or
973    greater than zero if the initial segment of S1 is lexicographically less
974    than, equal to or greater than the initial segment of S2.
975    Note: This function may, in multibyte locales, return 0 for initial segments
976    of different lengths!
977    Unlike strncasecmp(), this function works correctly in multibyte locales.
978    But beware that N is not a byte count but a character count!  */
979 _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
980      _GL_ATTRIBUTE_PURE
981      _GL_ARG_NONNULL ((1, 2));
982 #endif
983 
984 #if @GNULIB_MBSPCASECMP@
985 /* Compare the initial segment of the character string STRING consisting of
986    at most mbslen (PREFIX) characters with the character string PREFIX,
987    ignoring case.  If the two match, return a pointer to the first byte
988    after this prefix in STRING.  Otherwise, return NULL.
989    Note: This function may, in multibyte locales, return non-NULL if STRING
990    is of smaller length than PREFIX!
991    Unlike strncasecmp(), this function works correctly in multibyte
992    locales.  */
993 _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
994      _GL_ATTRIBUTE_PURE
995      _GL_ARG_NONNULL ((1, 2));
996 #endif
997 
998 #if @GNULIB_MBSCASESTR@
999 /* Find the first occurrence of the character string NEEDLE in the character
1000    string HAYSTACK, using case-insensitive comparison.
1001    Note: This function may, in multibyte locales, return success even if
1002    strlen (haystack) < strlen (needle) !
1003    Unlike strcasestr(), this function works correctly in multibyte locales.  */
1004 _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
1005      _GL_ATTRIBUTE_PURE
1006      _GL_ARG_NONNULL ((1, 2));
1007 #endif
1008 
1009 #if @GNULIB_MBSCSPN@
1010 /* Find the first occurrence in the character string STRING of any character
1011    in the character string ACCEPT.  Return the number of bytes from the
1012    beginning of the string to this occurrence, or to the end of the string
1013    if none exists.
1014    Unlike strcspn(), this function works correctly in multibyte locales.  */
1015 _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
1016      _GL_ATTRIBUTE_PURE
1017      _GL_ARG_NONNULL ((1, 2));
1018 #endif
1019 
1020 #if @GNULIB_MBSPBRK@
1021 /* Find the first occurrence in the character string STRING of any character
1022    in the character string ACCEPT.  Return the pointer to it, or NULL if none
1023    exists.
1024    Unlike strpbrk(), this function works correctly in multibyte locales.  */
1025 # if defined __hpux
1026 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1027 #   define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
1028 #  endif
1029 _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
1030                                    _GL_ATTRIBUTE_PURE
1031                                    _GL_ARG_NONNULL ((1, 2)));
1032 _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
1033 # else
1034 _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
1035                                    _GL_ATTRIBUTE_PURE
1036                                    _GL_ARG_NONNULL ((1, 2)));
1037 _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
1038 # endif
1039 _GL_CXXALIASWARN (mbspbrk);
1040 #endif
1041 
1042 #if @GNULIB_MBSSPN@
1043 /* Find the first occurrence in the character string STRING of any character
1044    not in the character string REJECT.  Return the number of bytes from the
1045    beginning of the string to this occurrence, or to the end of the string
1046    if none exists.
1047    Unlike strspn(), this function works correctly in multibyte locales.  */
1048 _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
1049      _GL_ATTRIBUTE_PURE
1050      _GL_ARG_NONNULL ((1, 2));
1051 #endif
1052 
1053 #if @GNULIB_MBSSEP@
1054 /* Search the next delimiter (multibyte character listed in the character
1055    string DELIM) starting at the character string *STRINGP.
1056    If one is found, overwrite it with a NUL, and advance *STRINGP to point
1057    to the next multibyte character after it.  Otherwise, set *STRINGP to NULL.
1058    If *STRINGP was already NULL, nothing happens.
1059    Return the old value of *STRINGP.
1060 
1061    This is a variant of mbstok_r() that supports empty fields.
1062 
1063    Caveat: It modifies the original string.
1064    Caveat: These functions cannot be used on constant strings.
1065    Caveat: The identity of the delimiting character is lost.
1066 
1067    See also mbstok_r().  */
1068 _GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
1069      _GL_ARG_NONNULL ((1, 2));
1070 #endif
1071 
1072 #if @GNULIB_MBSTOK_R@
1073 /* Parse the character string STRING into tokens separated by characters in
1074    the character string DELIM.
1075    If STRING is NULL, the saved pointer in SAVE_PTR is used as
1076    the next starting point.  For example:
1077         char s[] = "-abc-=-def";
1078         char *sp;
1079         x = mbstok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
1080         x = mbstok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
1081         x = mbstok_r(NULL, "=", &sp);   // x = NULL
1082                 // s = "abc\0-def\0"
1083 
1084    Caveat: It modifies the original string.
1085    Caveat: These functions cannot be used on constant strings.
1086    Caveat: The identity of the delimiting character is lost.
1087 
1088    See also mbssep().  */
1089 _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
1090                               char **save_ptr)
1091      _GL_ARG_NONNULL ((2, 3));
1092 #endif
1093 
1094 /* Map any int, typically from errno, into an error message.  */
1095 #if @GNULIB_STRERROR@
1096 # if @REPLACE_STRERROR@
1097 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1098 #   undef strerror
1099 #   define strerror rpl_strerror
1100 #  endif
1101 _GL_FUNCDECL_RPL (strerror, char *, (int));
1102 _GL_CXXALIAS_RPL (strerror, char *, (int));
1103 # else
1104 _GL_CXXALIAS_SYS (strerror, char *, (int));
1105 # endif
1106 # if __GLIBC__ >= 2
1107 _GL_CXXALIASWARN (strerror);
1108 # endif
1109 #elif defined GNULIB_POSIXCHECK
1110 # undef strerror
1111 /* Assume strerror is always declared.  */
1112 _GL_WARN_ON_USE (strerror, "strerror is unportable - "
1113                  "use gnulib module strerror to guarantee non-NULL result");
1114 #endif
1115 
1116 /* Map any int, typically from errno, into an error message.  Multithread-safe.
1117    Uses the POSIX declaration, not the glibc declaration.  */
1118 #if @GNULIB_STRERROR_R@
1119 # if @REPLACE_STRERROR_R@
1120 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1121 #   undef strerror_r
1122 #   define strerror_r rpl_strerror_r
1123 #  endif
1124 _GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
1125                                    _GL_ARG_NONNULL ((2)));
1126 _GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
1127 # else
1128 #  if !@HAVE_DECL_STRERROR_R@
1129 _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
1130                                    _GL_ARG_NONNULL ((2)));
1131 #  endif
1132 _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
1133 # endif
1134 # if @HAVE_DECL_STRERROR_R@
1135 _GL_CXXALIASWARN (strerror_r);
1136 # endif
1137 #elif defined GNULIB_POSIXCHECK
1138 # undef strerror_r
1139 # if HAVE_RAW_DECL_STRERROR_R
1140 _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1141                  "use gnulib module strerror_r-posix for portability");
1142 # endif
1143 #endif
1144 
1145 /* Return the name of the system error code ERRNUM.  */
1146 #if @GNULIB_STRERRORNAME_NP@
1147 # if @REPLACE_STRERRORNAME_NP@
1148 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1149 #   undef strerrorname_np
1150 #   define strerrorname_np rpl_strerrorname_np
1151 #  endif
1152 _GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum));
1153 _GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum));
1154 # else
1155 #  if !@HAVE_STRERRORNAME_NP@
1156 _GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum));
1157 #  endif
1158 _GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum));
1159 # endif
1160 _GL_CXXALIASWARN (strerrorname_np);
1161 #elif defined GNULIB_POSIXCHECK
1162 # undef strerrorname_np
1163 # if HAVE_RAW_DECL_STRERRORNAME_NP
1164 _GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - "
1165                  "use gnulib module strerrorname_np for portability");
1166 # endif
1167 #endif
1168 
1169 /* Return an abbreviation string for the signal number SIG.  */
1170 #if @GNULIB_SIGABBREV_NP@
1171 # if ! @HAVE_SIGABBREV_NP@
1172 _GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig));
1173 # endif
1174 _GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig));
1175 _GL_CXXALIASWARN (sigabbrev_np);
1176 #elif defined GNULIB_POSIXCHECK
1177 # undef sigabbrev_np
1178 # if HAVE_RAW_DECL_SIGABBREV_NP
1179 _GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - "
1180                  "use gnulib module sigabbrev_np for portability");
1181 # endif
1182 #endif
1183 
1184 /* Return an English description string for the signal number SIG.  */
1185 #if @GNULIB_SIGDESCR_NP@
1186 # if ! @HAVE_SIGDESCR_NP@
1187 _GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig));
1188 # endif
1189 _GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig));
1190 _GL_CXXALIASWARN (sigdescr_np);
1191 #elif defined GNULIB_POSIXCHECK
1192 # undef sigdescr_np
1193 # if HAVE_RAW_DECL_SIGDESCR_NP
1194 _GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - "
1195                  "use gnulib module sigdescr_np for portability");
1196 # endif
1197 #endif
1198 
1199 #if @GNULIB_STRSIGNAL@
1200 # if @REPLACE_STRSIGNAL@
1201 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1202 #   define strsignal rpl_strsignal
1203 #  endif
1204 _GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
1205 _GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
1206 # else
1207 #  if ! @HAVE_DECL_STRSIGNAL@
1208 _GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
1209 #  endif
1210 /* Need to cast, because on Cygwin 1.5.x systems, the return type is
1211    'const char *'.  */
1212 _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
1213 # endif
1214 _GL_CXXALIASWARN (strsignal);
1215 #elif defined GNULIB_POSIXCHECK
1216 # undef strsignal
1217 # if HAVE_RAW_DECL_STRSIGNAL
1218 _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
1219                  "use gnulib module strsignal for portability");
1220 # endif
1221 #endif
1222 
1223 #if @GNULIB_STRVERSCMP@
1224 # if !@HAVE_STRVERSCMP@
1225 _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
1226                                    _GL_ATTRIBUTE_PURE
1227                                    _GL_ARG_NONNULL ((1, 2)));
1228 # endif
1229 _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
1230 _GL_CXXALIASWARN (strverscmp);
1231 #elif defined GNULIB_POSIXCHECK
1232 # undef strverscmp
1233 # if HAVE_RAW_DECL_STRVERSCMP
1234 _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1235                  "use gnulib module strverscmp for portability");
1236 # endif
1237 #endif
1238 
1239 
1240 #endif /* _@GUARD_PREFIX@_STRING_H */
1241 #endif /* _@GUARD_PREFIX@_STRING_H */
1242 #endif
1243