1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A GNU-like <string.h>.
4 Copyright (C) 1995-1996, 2001-2015 Free Software Foundation, Inc.
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)
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.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
20 #pragma GCC system_header
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. */
31 #include_next <string.h>
34 /* Normal invocation convention. */
38 #define _GL_ALREADY_INCLUDING_STRING_H
40 /* The include_next requires a split double-inclusion guard. */
41 #include_next <string.h>
43 #undef _GL_ALREADY_INCLUDING_STRING_H
48 /* NetBSD 5.0 mis-defines NULL. */
51 /* MirBSD defines mbslen as a macro. */
52 #if 1 && defined __MirBSD__
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__))
61 # define _GL_ATTRIBUTE_PURE /* empty */
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__
71 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
75 /* The three most frequent use cases of these macros are:
77 * For providing a substitute for a function that is missing on some
78 platforms, but is declared and works fine on the platforms on which
83 _GL_FUNCDECL_SYS (foo, ...);
85 _GL_CXXALIAS_SYS (foo, ...);
86 _GL_CXXALIASWARN (foo);
87 #elif defined GNULIB_POSIXCHECK
91 * For providing a replacement for a function that exists on all platforms,
92 but is broken/insufficient and needs to be replaced on some platforms:
96 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
100 _GL_FUNCDECL_RPL (foo, ...);
101 _GL_CXXALIAS_RPL (foo, ...);
103 _GL_CXXALIAS_SYS (foo, ...);
105 _GL_CXXALIASWARN (foo);
106 #elif defined GNULIB_POSIXCHECK
110 * For providing a replacement for a function that exists on some platforms
111 but is broken/insufficient and needs to be replaced on some of them and
112 is additionally either missing or undeclared on some other platforms:
116 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
120 _GL_FUNCDECL_RPL (foo, ...);
121 _GL_CXXALIAS_RPL (foo, ...);
123 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
124 _GL_FUNCDECL_SYS (foo, ...);
126 _GL_CXXALIAS_SYS (foo, ...);
128 _GL_CXXALIASWARN (foo);
129 #elif defined GNULIB_POSIXCHECK
134 /* _GL_EXTERN_C declaration;
135 performs the declaration with C linkage. */
136 #if defined __cplusplus
137 # define _GL_EXTERN_C extern "C"
139 # define _GL_EXTERN_C extern
142 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
143 declares a replacement function, named rpl_func, with the given prototype,
144 consisting of return type, parameters, and attributes.
146 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
147 _GL_ARG_NONNULL ((1)));
149 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
150 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
151 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
152 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
154 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
155 declares the system function, named func, with the given prototype,
156 consisting of return type, parameters, and attributes.
158 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
159 _GL_ARG_NONNULL ((1)));
161 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
162 _GL_EXTERN_C rettype func parameters_and_attributes
164 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
165 declares a C++ alias called GNULIB_NAMESPACE::func
166 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
168 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
170 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
171 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
172 #if defined __cplusplus && defined GNULIB_NAMESPACE
173 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
174 namespace GNULIB_NAMESPACE \
176 rettype (*const func) parameters = ::rpl_func; \
178 _GL_EXTERN_C int _gl_cxxalias_dummy
180 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
181 _GL_EXTERN_C int _gl_cxxalias_dummy
184 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
185 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
186 except that the C function rpl_func may have a slightly different
187 declaration. A cast is used to silence the "invalid conversion" error
188 that would otherwise occur. */
189 #if defined __cplusplus && defined GNULIB_NAMESPACE
190 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
191 namespace GNULIB_NAMESPACE \
193 rettype (*const func) parameters = \
194 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
196 _GL_EXTERN_C int _gl_cxxalias_dummy
198 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
199 _GL_EXTERN_C int _gl_cxxalias_dummy
202 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
203 declares a C++ alias called GNULIB_NAMESPACE::func
204 that redirects to the system provided function func, if GNULIB_NAMESPACE
207 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
209 #if defined __cplusplus && defined GNULIB_NAMESPACE
210 /* If we were to write
211 rettype (*const func) parameters = ::func;
212 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
213 better (remove an indirection through a 'static' pointer variable),
214 but then the _GL_CXXALIASWARN macro below would cause a warning not only
215 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
216 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
217 namespace GNULIB_NAMESPACE \
219 static rettype (*func) parameters = ::func; \
221 _GL_EXTERN_C int _gl_cxxalias_dummy
223 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
224 _GL_EXTERN_C int _gl_cxxalias_dummy
227 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
228 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
229 except that the C function func may have a slightly different declaration.
230 A cast is used to silence the "invalid conversion" error that would
232 #if defined __cplusplus && defined GNULIB_NAMESPACE
233 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
234 namespace GNULIB_NAMESPACE \
236 static rettype (*func) parameters = \
237 reinterpret_cast<rettype(*)parameters>(::func); \
239 _GL_EXTERN_C int _gl_cxxalias_dummy
241 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
242 _GL_EXTERN_C int _gl_cxxalias_dummy
245 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
246 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
247 except that the C function is picked among a set of overloaded functions,
248 namely the one with rettype2 and parameters2. Two consecutive casts
249 are used to silence the "cannot find a match" and "invalid conversion"
250 errors that would otherwise occur. */
251 #if defined __cplusplus && defined GNULIB_NAMESPACE
252 /* The outer cast must be a reinterpret_cast.
253 The inner cast: When the function is defined as a set of overloaded
254 functions, it works as a static_cast<>, choosing the designated variant.
255 When the function is defined as a single variant, it works as a
256 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
257 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
258 namespace GNULIB_NAMESPACE \
260 static rettype (*func) parameters = \
261 reinterpret_cast<rettype(*)parameters>( \
262 (rettype2(*)parameters2)(::func)); \
264 _GL_EXTERN_C int _gl_cxxalias_dummy
266 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
267 _GL_EXTERN_C int _gl_cxxalias_dummy
270 /* _GL_CXXALIASWARN (func);
271 causes a warning to be emitted when ::func is used but not when
272 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
274 #if defined __cplusplus && defined GNULIB_NAMESPACE
275 # define _GL_CXXALIASWARN(func) \
276 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
277 # define _GL_CXXALIASWARN_1(func,namespace) \
278 _GL_CXXALIASWARN_2 (func, namespace)
279 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
280 we enable the warning only when not optimizing. */
282 # define _GL_CXXALIASWARN_2(func,namespace) \
283 _GL_WARN_ON_USE (func, \
284 "The symbol ::" #func " refers to the system function. " \
285 "Use " #namespace "::" #func " instead.")
286 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
287 # define _GL_CXXALIASWARN_2(func,namespace) \
288 extern __typeof__ (func) func
290 # define _GL_CXXALIASWARN_2(func,namespace) \
291 _GL_EXTERN_C int _gl_cxxalias_dummy
294 # define _GL_CXXALIASWARN(func) \
295 _GL_EXTERN_C int _gl_cxxalias_dummy
298 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
299 causes a warning to be emitted when the given overloaded variant of ::func
300 is used but not when GNULIB_NAMESPACE::func is used. */
301 #if defined __cplusplus && defined GNULIB_NAMESPACE
302 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
303 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
305 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
306 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
307 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
308 we enable the warning only when not optimizing. */
310 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
311 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
312 "The symbol ::" #func " refers to the system function. " \
313 "Use " #namespace "::" #func " instead.")
314 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
315 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
316 extern __typeof__ (func) func
318 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
319 _GL_EXTERN_C int _gl_cxxalias_dummy
322 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
323 _GL_EXTERN_C int _gl_cxxalias_dummy
326 #endif /* _GL_CXXDEFS_H */
328 /* The definition of _GL_ARG_NONNULL is copied here. */
329 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
330 that the values passed as arguments n, ..., m must be non-NULL pointers.
331 n = 1 stands for the first argument, n = 2 for the second argument etc. */
332 #ifndef _GL_ARG_NONNULL
333 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
334 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
336 # define _GL_ARG_NONNULL(params)
340 /* The definition of _GL_WARN_ON_USE is copied here. */
341 #ifndef _GL_WARN_ON_USE
343 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
344 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
345 # define _GL_WARN_ON_USE(function, message) \
346 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
347 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
348 /* Verify the existence of the function. */
349 # define _GL_WARN_ON_USE(function, message) \
350 extern __typeof__ (function) function
351 # else /* Unsupported. */
352 # define _GL_WARN_ON_USE(function, message) \
353 _GL_WARN_EXTERN_C int _gl_warn_on_use
357 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
358 is like _GL_WARN_ON_USE (function, "string"), except that the function is
359 declared with the given prototype, consisting of return type, parameters,
361 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
362 not work in this case. */
363 #ifndef _GL_WARN_ON_USE_CXX
364 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
365 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
366 extern rettype function parameters_and_attributes \
367 __attribute__ ((__warning__ (msg)))
368 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
369 /* Verify the existence of the function. */
370 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
371 extern rettype function parameters_and_attributes
372 # else /* Unsupported. */
373 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
374 _GL_WARN_EXTERN_C int _gl_warn_on_use
378 /* _GL_WARN_EXTERN_C declaration;
379 performs the declaration with C linkage. */
380 #ifndef _GL_WARN_EXTERN_C
381 # if defined __cplusplus
382 # define _GL_WARN_EXTERN_C extern "C"
384 # define _GL_WARN_EXTERN_C extern
389 /* Find the index of the least-significant set bit. */
392 _GL_FUNCDECL_SYS (ffsl, int, (long int i));
394 _GL_CXXALIAS_SYS (ffsl, int, (long int i));
395 _GL_CXXALIASWARN (ffsl);
396 #elif defined GNULIB_POSIXCHECK
398 # if HAVE_RAW_DECL_FFSL
399 _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
404 /* Find the index of the least-significant set bit. */
407 _GL_FUNCDECL_SYS (ffsll, int, (long long int i));
409 _GL_CXXALIAS_SYS (ffsll, int, (long long int i));
410 _GL_CXXALIASWARN (ffsll);
411 #elif defined GNULIB_POSIXCHECK
413 # if HAVE_RAW_DECL_FFSLL
414 _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
419 /* Return the first instance of C within N bytes of S, or NULL. */
422 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
423 # define memchr rpl_memchr
425 _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
427 _GL_ARG_NONNULL ((1)));
428 _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
431 _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
433 _GL_ARG_NONNULL ((1)));
435 /* On some systems, this function is defined as an overloaded function:
436 extern "C" { const void * std::memchr (const void *, int, size_t); }
437 extern "C++" { void * std::memchr (void *, int, size_t); } */
438 _GL_CXXALIAS_SYS_CAST2 (memchr,
439 void *, (void const *__s, int __c, size_t __n),
440 void const *, (void const *__s, int __c, size_t __n));
442 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
443 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
444 _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
445 _GL_CXXALIASWARN1 (memchr, void const *,
446 (void const *__s, int __c, size_t __n));
448 _GL_CXXALIASWARN (memchr);
450 #elif defined GNULIB_POSIXCHECK
452 /* Assume memchr is always declared. */
453 _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
454 "use gnulib module memchr for portability" );
457 /* Return the first occurrence of NEEDLE in HAYSTACK. */
460 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
461 # define memmem rpl_memmem
463 _GL_FUNCDECL_RPL (memmem, void *,
464 (void const *__haystack, size_t __haystack_len,
465 void const *__needle, size_t __needle_len)
467 _GL_ARG_NONNULL ((1, 3)));
468 _GL_CXXALIAS_RPL (memmem, void *,
469 (void const *__haystack, size_t __haystack_len,
470 void const *__needle, size_t __needle_len));
473 _GL_FUNCDECL_SYS (memmem, void *,
474 (void const *__haystack, size_t __haystack_len,
475 void const *__needle, size_t __needle_len)
477 _GL_ARG_NONNULL ((1, 3)));
479 _GL_CXXALIAS_SYS (memmem, void *,
480 (void const *__haystack, size_t __haystack_len,
481 void const *__needle, size_t __needle_len));
483 _GL_CXXALIASWARN (memmem);
484 #elif defined GNULIB_POSIXCHECK
486 # if HAVE_RAW_DECL_MEMMEM
487 _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
488 "use gnulib module memmem-simple for portability, "
489 "and module memmem for speed" );
493 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
494 last written byte. */
497 _GL_FUNCDECL_SYS (mempcpy, void *,
498 (void *restrict __dest, void const *restrict __src,
500 _GL_ARG_NONNULL ((1, 2)));
502 _GL_CXXALIAS_SYS (mempcpy, void *,
503 (void *restrict __dest, void const *restrict __src,
505 _GL_CXXALIASWARN (mempcpy);
506 #elif defined GNULIB_POSIXCHECK
508 # if HAVE_RAW_DECL_MEMPCPY
509 _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
510 "use gnulib module mempcpy for portability");
514 /* Search backwards through a block for a byte (specified as an int). */
517 _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
519 _GL_ARG_NONNULL ((1)));
521 /* On some systems, this function is defined as an overloaded function:
522 extern "C++" { const void * std::memrchr (const void *, int, size_t); }
523 extern "C++" { void * std::memrchr (void *, int, size_t); } */
524 _GL_CXXALIAS_SYS_CAST2 (memrchr,
525 void *, (void const *, int, size_t),
526 void const *, (void const *, int, size_t));
527 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
528 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
529 _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
530 _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
532 _GL_CXXALIASWARN (memrchr);
534 #elif defined GNULIB_POSIXCHECK
536 # if HAVE_RAW_DECL_MEMRCHR
537 _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
538 "use gnulib module memrchr for portability");
542 /* Find the first occurrence of C in S. More efficient than
543 memchr(S,C,N), at the expense of undefined behavior if C does not
544 occur within N bytes. */
547 _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
549 _GL_ARG_NONNULL ((1)));
551 /* On some systems, this function is defined as an overloaded function:
552 extern "C++" { const void * std::rawmemchr (const void *, int); }
553 extern "C++" { void * std::rawmemchr (void *, int); } */
554 _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
555 void *, (void const *__s, int __c_in),
556 void const *, (void const *__s, int __c_in));
557 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
558 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
559 _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
560 _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
562 _GL_CXXALIASWARN (rawmemchr);
564 #elif defined GNULIB_POSIXCHECK
566 # if HAVE_RAW_DECL_RAWMEMCHR
567 _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
568 "use gnulib module rawmemchr for portability");
572 /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
575 _GL_FUNCDECL_SYS (stpcpy, char *,
576 (char *restrict __dst, char const *restrict __src)
577 _GL_ARG_NONNULL ((1, 2)));
579 _GL_CXXALIAS_SYS (stpcpy, char *,
580 (char *restrict __dst, char const *restrict __src));
581 _GL_CXXALIASWARN (stpcpy);
582 #elif defined GNULIB_POSIXCHECK
584 # if HAVE_RAW_DECL_STPCPY
585 _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
586 "use gnulib module stpcpy for portability");
590 /* Copy no more than N bytes of SRC to DST, returning a pointer past the
591 last non-NUL byte written into DST. */
594 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
596 # define stpncpy rpl_stpncpy
598 _GL_FUNCDECL_RPL (stpncpy, char *,
599 (char *restrict __dst, char const *restrict __src,
601 _GL_ARG_NONNULL ((1, 2)));
602 _GL_CXXALIAS_RPL (stpncpy, char *,
603 (char *restrict __dst, char const *restrict __src,
607 _GL_FUNCDECL_SYS (stpncpy, char *,
608 (char *restrict __dst, char const *restrict __src,
610 _GL_ARG_NONNULL ((1, 2)));
612 _GL_CXXALIAS_SYS (stpncpy, char *,
613 (char *restrict __dst, char const *restrict __src,
616 _GL_CXXALIASWARN (stpncpy);
617 #elif defined GNULIB_POSIXCHECK
619 # if HAVE_RAW_DECL_STPNCPY
620 _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
621 "use gnulib module stpncpy for portability");
625 #if defined GNULIB_POSIXCHECK
626 /* strchr() does not work with multibyte strings if the locale encoding is
627 GB18030 and the character to be searched is a digit. */
629 /* Assume strchr is always declared. */
630 _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
631 "in some multibyte locales - "
632 "use mbschr if you care about internationalization");
635 /* Find the first occurrence of C in S or the final NUL byte. */
638 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
639 # define strchrnul rpl_strchrnul
641 _GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
643 _GL_ARG_NONNULL ((1)));
644 _GL_CXXALIAS_RPL (strchrnul, char *,
645 (const char *str, int ch));
648 _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
650 _GL_ARG_NONNULL ((1)));
652 /* On some systems, this function is defined as an overloaded function:
653 extern "C++" { const char * std::strchrnul (const char *, int); }
654 extern "C++" { char * std::strchrnul (char *, int); } */
655 _GL_CXXALIAS_SYS_CAST2 (strchrnul,
656 char *, (char const *__s, int __c_in),
657 char const *, (char const *__s, int __c_in));
659 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
660 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
661 _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
662 _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
664 _GL_CXXALIASWARN (strchrnul);
666 #elif defined GNULIB_POSIXCHECK
668 # if HAVE_RAW_DECL_STRCHRNUL
669 _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
670 "use gnulib module strchrnul for portability");
674 /* Duplicate S, returning an identical malloc'd string. */
677 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
679 # define strdup rpl_strdup
681 _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
682 _GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
684 # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
685 /* strdup exists as a function and as a macro. Get rid of the macro. */
688 # if !(1 || defined strdup)
689 _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
691 _GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
693 _GL_CXXALIASWARN (strdup);
694 #elif defined GNULIB_POSIXCHECK
696 # if HAVE_RAW_DECL_STRDUP
697 _GL_WARN_ON_USE (strdup, "strdup is unportable - "
698 "use gnulib module strdup for portability");
702 /* Append no more than N characters from SRC onto DEST. */
705 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
707 # define strncat rpl_strncat
709 _GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
710 _GL_ARG_NONNULL ((1, 2)));
711 _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
713 _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
715 _GL_CXXALIASWARN (strncat);
716 #elif defined GNULIB_POSIXCHECK
718 # if HAVE_RAW_DECL_STRNCAT
719 _GL_WARN_ON_USE (strncat, "strncat is unportable - "
720 "use gnulib module strncat for portability");
724 /* Return a newly allocated copy of at most N bytes of STRING. */
727 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
729 # define strndup rpl_strndup
731 _GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n)
732 _GL_ARG_NONNULL ((1)));
733 _GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n));
736 _GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
737 _GL_ARG_NONNULL ((1)));
739 _GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
741 _GL_CXXALIASWARN (strndup);
742 #elif defined GNULIB_POSIXCHECK
744 # if HAVE_RAW_DECL_STRNDUP
745 _GL_WARN_ON_USE (strndup, "strndup is unportable - "
746 "use gnulib module strndup for portability");
750 /* Find the length (number of bytes) of STRING, but scan at most
751 MAXLEN bytes. If no '\0' terminator is found in that many bytes,
755 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
757 # define strnlen rpl_strnlen
759 _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
761 _GL_ARG_NONNULL ((1)));
762 _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
765 _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
767 _GL_ARG_NONNULL ((1)));
769 _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
771 _GL_CXXALIASWARN (strnlen);
772 #elif defined GNULIB_POSIXCHECK
774 # if HAVE_RAW_DECL_STRNLEN
775 _GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
776 "use gnulib module strnlen for portability");
780 #if defined GNULIB_POSIXCHECK
781 /* strcspn() assumes the second argument is a list of single-byte characters.
782 Even in this simple case, it does not work with multibyte strings if the
783 locale encoding is GB18030 and one of the characters to be searched is a
786 /* Assume strcspn is always declared. */
787 _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
788 "in multibyte locales - "
789 "use mbscspn if you care about internationalization");
792 /* Find the first occurrence in S of any character in ACCEPT. */
795 _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
797 _GL_ARG_NONNULL ((1, 2)));
799 /* On some systems, this function is defined as an overloaded function:
800 extern "C" { const char * strpbrk (const char *, const char *); }
801 extern "C++" { char * strpbrk (char *, const char *); } */
802 _GL_CXXALIAS_SYS_CAST2 (strpbrk,
803 char *, (char const *__s, char const *__accept),
804 const char *, (char const *__s, char const *__accept));
805 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
806 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
807 _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
808 _GL_CXXALIASWARN1 (strpbrk, char const *,
809 (char const *__s, char const *__accept));
811 _GL_CXXALIASWARN (strpbrk);
813 # if defined GNULIB_POSIXCHECK
814 /* strpbrk() assumes the second argument is a list of single-byte characters.
815 Even in this simple case, it does not work with multibyte strings if the
816 locale encoding is GB18030 and one of the characters to be searched is a
819 _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
820 "in multibyte locales - "
821 "use mbspbrk if you care about internationalization");
823 #elif defined GNULIB_POSIXCHECK
825 # if HAVE_RAW_DECL_STRPBRK
826 _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
827 "use gnulib module strpbrk for portability");
831 #if defined GNULIB_POSIXCHECK
832 /* strspn() assumes the second argument is a list of single-byte characters.
833 Even in this simple case, it cannot work with multibyte strings. */
835 /* Assume strspn is always declared. */
836 _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
837 "in multibyte locales - "
838 "use mbsspn if you care about internationalization");
841 #if defined GNULIB_POSIXCHECK
842 /* strrchr() does not work with multibyte strings if the locale encoding is
843 GB18030 and the character to be searched is a digit. */
845 /* Assume strrchr is always declared. */
846 _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
847 "in some multibyte locales - "
848 "use mbsrchr if you care about internationalization");
851 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
852 If one is found, overwrite it with a NUL, and advance *STRINGP
853 to point to the next char after it. Otherwise, set *STRINGP to NULL.
854 If *STRINGP was already NULL, nothing happens.
855 Return the old value of *STRINGP.
857 This is a variant of strtok() that is multithread-safe and supports
860 Caveat: It modifies the original string.
861 Caveat: These functions cannot be used on constant strings.
862 Caveat: The identity of the delimiting character is lost.
863 Caveat: It doesn't work with multibyte strings unless all of the delimiter
864 characters are ASCII characters < 0x30.
866 See also strtok_r(). */
869 _GL_FUNCDECL_SYS (strsep, char *,
870 (char **restrict __stringp, char const *restrict __delim)
871 _GL_ARG_NONNULL ((1, 2)));
873 _GL_CXXALIAS_SYS (strsep, char *,
874 (char **restrict __stringp, char const *restrict __delim));
875 _GL_CXXALIASWARN (strsep);
876 # if defined GNULIB_POSIXCHECK
878 _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
879 "in multibyte locales - "
880 "use mbssep if you care about internationalization");
882 #elif defined GNULIB_POSIXCHECK
884 # if HAVE_RAW_DECL_STRSEP
885 _GL_WARN_ON_USE (strsep, "strsep is unportable - "
886 "use gnulib module strsep for portability");
892 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
893 # define strstr rpl_strstr
895 _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
897 _GL_ARG_NONNULL ((1, 2)));
898 _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
900 /* On some systems, this function is defined as an overloaded function:
901 extern "C++" { const char * strstr (const char *, const char *); }
902 extern "C++" { char * strstr (char *, const char *); } */
903 _GL_CXXALIAS_SYS_CAST2 (strstr,
904 char *, (const char *haystack, const char *needle),
905 const char *, (const char *haystack, const char *needle));
907 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
908 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
909 _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
910 _GL_CXXALIASWARN1 (strstr, const char *,
911 (const char *haystack, const char *needle));
913 _GL_CXXALIASWARN (strstr);
915 #elif defined GNULIB_POSIXCHECK
916 /* strstr() does not work with multibyte strings if the locale encoding is
917 different from UTF-8:
918 POSIX says that it operates on "strings", and "string" in POSIX is defined
919 as a sequence of bytes, not of characters. */
921 /* Assume strstr is always declared. */
922 _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
923 "work correctly on character strings in most "
924 "multibyte locales - "
925 "use mbsstr if you care about internationalization, "
926 "or use strstr if you care about speed");
929 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
933 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
934 # define strcasestr rpl_strcasestr
936 _GL_FUNCDECL_RPL (strcasestr, char *,
937 (const char *haystack, const char *needle)
939 _GL_ARG_NONNULL ((1, 2)));
940 _GL_CXXALIAS_RPL (strcasestr, char *,
941 (const char *haystack, const char *needle));
944 _GL_FUNCDECL_SYS (strcasestr, char *,
945 (const char *haystack, const char *needle)
947 _GL_ARG_NONNULL ((1, 2)));
949 /* On some systems, this function is defined as an overloaded function:
950 extern "C++" { const char * strcasestr (const char *, const char *); }
951 extern "C++" { char * strcasestr (char *, const char *); } */
952 _GL_CXXALIAS_SYS_CAST2 (strcasestr,
953 char *, (const char *haystack, const char *needle),
954 const char *, (const char *haystack, const char *needle));
956 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
957 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
958 _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
959 _GL_CXXALIASWARN1 (strcasestr, const char *,
960 (const char *haystack, const char *needle));
962 _GL_CXXALIASWARN (strcasestr);
964 #elif defined GNULIB_POSIXCHECK
965 /* strcasestr() does not work with multibyte strings:
966 It is a glibc extension, and glibc implements it only for unibyte
969 # if HAVE_RAW_DECL_STRCASESTR
970 _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
971 "strings in multibyte locales - "
972 "use mbscasestr if you care about "
973 "internationalization, or use c-strcasestr if you want "
974 "a locale independent function");
978 /* Parse S into tokens separated by characters in DELIM.
979 If S is NULL, the saved pointer in SAVE_PTR is used as
980 the next starting point. For example:
981 char s[] = "-abc-=-def";
983 x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
984 x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
985 x = strtok_r(NULL, "=", &sp); // x = NULL
988 This is a variant of strtok() that is multithread-safe.
990 For the POSIX documentation for this function, see:
991 http://www.opengroup.org/susv3xsh/strtok.html
993 Caveat: It modifies the original string.
994 Caveat: These functions cannot be used on constant strings.
995 Caveat: The identity of the delimiting character is lost.
996 Caveat: It doesn't work with multibyte strings unless all of the delimiter
997 characters are ASCII characters < 0x30.
999 See also strsep(). */
1002 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1004 # define strtok_r rpl_strtok_r
1006 _GL_FUNCDECL_RPL (strtok_r, char *,
1007 (char *restrict s, char const *restrict delim,
1008 char **restrict save_ptr)
1009 _GL_ARG_NONNULL ((2, 3)));
1010 _GL_CXXALIAS_RPL (strtok_r, char *,
1011 (char *restrict s, char const *restrict delim,
1012 char **restrict save_ptr));
1014 # if 0 || defined GNULIB_POSIXCHECK
1018 _GL_FUNCDECL_SYS (strtok_r, char *,
1019 (char *restrict s, char const *restrict delim,
1020 char **restrict save_ptr)
1021 _GL_ARG_NONNULL ((2, 3)));
1023 _GL_CXXALIAS_SYS (strtok_r, char *,
1024 (char *restrict s, char const *restrict delim,
1025 char **restrict save_ptr));
1027 _GL_CXXALIASWARN (strtok_r);
1028 # if defined GNULIB_POSIXCHECK
1029 _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
1030 "strings in multibyte locales - "
1031 "use mbstok_r if you care about internationalization");
1033 #elif defined GNULIB_POSIXCHECK
1035 # if HAVE_RAW_DECL_STRTOK_R
1036 _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
1037 "use gnulib module strtok_r for portability");
1042 /* The following functions are not specified by POSIX. They are gnulib
1046 /* Return the number of multibyte characters in the character string STRING.
1047 This considers multibyte characters, unlike strlen, which counts bytes. */
1048 # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
1051 # if 0 /* AIX, OSF/1, MirBSD define mbslen already in libc. */
1052 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1053 # define mbslen rpl_mbslen
1055 _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string)
1057 _GL_ARG_NONNULL ((1)));
1058 _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
1060 _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
1062 _GL_ARG_NONNULL ((1)));
1063 _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
1065 _GL_CXXALIASWARN (mbslen);
1069 /* Return the number of multibyte characters in the character string starting
1070 at STRING and ending at STRING + LEN. */
1071 _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
1073 _GL_ARG_NONNULL ((1));
1077 /* Locate the first single-byte character C in the character string STRING,
1078 and return a pointer to it. Return NULL if C is not found in STRING.
1079 Unlike strchr(), this function works correctly in multibyte locales with
1080 encodings such as GB18030. */
1082 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1083 # define mbschr rpl_mbschr /* avoid collision with HP-UX function */
1085 _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
1087 _GL_ARG_NONNULL ((1)));
1088 _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
1090 _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
1092 _GL_ARG_NONNULL ((1)));
1093 _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
1095 _GL_CXXALIASWARN (mbschr);
1099 /* Locate the last single-byte character C in the character string STRING,
1100 and return a pointer to it. Return NULL if C is not found in STRING.
1101 Unlike strrchr(), this function works correctly in multibyte locales with
1102 encodings such as GB18030. */
1103 # if defined __hpux || defined __INTERIX
1104 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1105 # define mbsrchr rpl_mbsrchr /* avoid collision with system function */
1107 _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
1109 _GL_ARG_NONNULL ((1)));
1110 _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
1112 _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
1114 _GL_ARG_NONNULL ((1)));
1115 _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
1117 _GL_CXXALIASWARN (mbsrchr);
1121 /* Find the first occurrence of the character string NEEDLE in the character
1122 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
1123 Unlike strstr(), this function works correctly in multibyte locales with
1124 encodings different from UTF-8. */
1125 _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
1127 _GL_ARG_NONNULL ((1, 2));
1131 /* Compare the character strings S1 and S2, ignoring case, returning less than,
1132 equal to or greater than zero if S1 is lexicographically less than, equal to
1134 Note: This function may, in multibyte locales, return 0 for strings of
1136 Unlike strcasecmp(), this function works correctly in multibyte locales. */
1137 _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
1139 _GL_ARG_NONNULL ((1, 2));
1143 /* Compare the initial segment of the character string S1 consisting of at most
1144 N characters with the initial segment of the character string S2 consisting
1145 of at most N characters, ignoring case, returning less than, equal to or
1146 greater than zero if the initial segment of S1 is lexicographically less
1147 than, equal to or greater than the initial segment of S2.
1148 Note: This function may, in multibyte locales, return 0 for initial segments
1149 of different lengths!
1150 Unlike strncasecmp(), this function works correctly in multibyte locales.
1151 But beware that N is not a byte count but a character count! */
1152 _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
1154 _GL_ARG_NONNULL ((1, 2));
1158 /* Compare the initial segment of the character string STRING consisting of
1159 at most mbslen (PREFIX) characters with the character string PREFIX,
1160 ignoring case. If the two match, return a pointer to the first byte
1161 after this prefix in STRING. Otherwise, return NULL.
1162 Note: This function may, in multibyte locales, return non-NULL if STRING
1163 is of smaller length than PREFIX!
1164 Unlike strncasecmp(), this function works correctly in multibyte
1166 _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1168 _GL_ARG_NONNULL ((1, 2));
1172 /* Find the first occurrence of the character string NEEDLE in the character
1173 string HAYSTACK, using case-insensitive comparison.
1174 Note: This function may, in multibyte locales, return success even if
1175 strlen (haystack) < strlen (needle) !
1176 Unlike strcasestr(), this function works correctly in multibyte locales. */
1177 _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
1179 _GL_ARG_NONNULL ((1, 2));
1183 /* Find the first occurrence in the character string STRING of any character
1184 in the character string ACCEPT. Return the number of bytes from the
1185 beginning of the string to this occurrence, or to the end of the string
1187 Unlike strcspn(), this function works correctly in multibyte locales. */
1188 _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
1190 _GL_ARG_NONNULL ((1, 2));
1194 /* Find the first occurrence in the character string STRING of any character
1195 in the character string ACCEPT. Return the pointer to it, or NULL if none
1197 Unlike strpbrk(), this function works correctly in multibyte locales. */
1199 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1200 # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
1202 _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
1204 _GL_ARG_NONNULL ((1, 2)));
1205 _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
1207 _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
1209 _GL_ARG_NONNULL ((1, 2)));
1210 _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
1212 _GL_CXXALIASWARN (mbspbrk);
1216 /* Find the first occurrence in the character string STRING of any character
1217 not in the character string REJECT. Return the number of bytes from the
1218 beginning of the string to this occurrence, or to the end of the string
1220 Unlike strspn(), this function works correctly in multibyte locales. */
1221 _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
1223 _GL_ARG_NONNULL ((1, 2));
1227 /* Search the next delimiter (multibyte character listed in the character
1228 string DELIM) starting at the character string *STRINGP.
1229 If one is found, overwrite it with a NUL, and advance *STRINGP to point
1230 to the next multibyte character after it. Otherwise, set *STRINGP to NULL.
1231 If *STRINGP was already NULL, nothing happens.
1232 Return the old value of *STRINGP.
1234 This is a variant of mbstok_r() that supports empty fields.
1236 Caveat: It modifies the original string.
1237 Caveat: These functions cannot be used on constant strings.
1238 Caveat: The identity of the delimiting character is lost.
1240 See also mbstok_r(). */
1241 _GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
1242 _GL_ARG_NONNULL ((1, 2));
1246 /* Parse the character string STRING into tokens separated by characters in
1247 the character string DELIM.
1248 If STRING is NULL, the saved pointer in SAVE_PTR is used as
1249 the next starting point. For example:
1250 char s[] = "-abc-=-def";
1252 x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
1253 x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
1254 x = mbstok_r(NULL, "=", &sp); // x = NULL
1255 // s = "abc\0-def\0"
1257 Caveat: It modifies the original string.
1258 Caveat: These functions cannot be used on constant strings.
1259 Caveat: The identity of the delimiting character is lost.
1261 See also mbssep(). */
1262 _GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
1263 _GL_ARG_NONNULL ((2, 3));
1266 /* Map any int, typically from errno, into an error message. */
1269 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1271 # define strerror rpl_strerror
1273 _GL_FUNCDECL_RPL (strerror, char *, (int));
1274 _GL_CXXALIAS_RPL (strerror, char *, (int));
1276 _GL_CXXALIAS_SYS (strerror, char *, (int));
1278 _GL_CXXALIASWARN (strerror);
1279 #elif defined GNULIB_POSIXCHECK
1281 /* Assume strerror is always declared. */
1282 _GL_WARN_ON_USE (strerror, "strerror is unportable - "
1283 "use gnulib module strerror to guarantee non-NULL result");
1286 /* Map any int, typically from errno, into an error message. Multithread-safe.
1287 Uses the POSIX declaration, not the glibc declaration. */
1290 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1292 # define strerror_r rpl_strerror_r
1294 _GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
1295 _GL_ARG_NONNULL ((2)));
1296 _GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
1299 _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
1300 _GL_ARG_NONNULL ((2)));
1302 _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
1305 _GL_CXXALIASWARN (strerror_r);
1307 #elif defined GNULIB_POSIXCHECK
1309 # if HAVE_RAW_DECL_STRERROR_R
1310 _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1311 "use gnulib module strerror_r-posix for portability");
1317 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1318 # define strsignal rpl_strsignal
1320 _GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
1321 _GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
1324 _GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
1326 /* Need to cast, because on Cygwin 1.5.x systems, the return type is
1328 _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
1330 _GL_CXXALIASWARN (strsignal);
1331 #elif defined GNULIB_POSIXCHECK
1333 # if HAVE_RAW_DECL_STRSIGNAL
1334 _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
1335 "use gnulib module strsignal for portability");
1341 _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
1343 _GL_ARG_NONNULL ((1, 2)));
1345 _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
1346 _GL_CXXALIASWARN (strverscmp);
1347 #elif defined GNULIB_POSIXCHECK
1349 # if HAVE_RAW_DECL_STRVERSCMP
1350 _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1351 "use gnulib module strverscmp for portability");
1356 #endif /* _GL_STRING_H */
1357 #endif /* _GL_STRING_H */