1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A GNU-like <string.h>.
4 Copyright (C) 1995-1996, 2001-2014 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/>. */
22 #pragma GCC system_header
26 /* The include_next requires a split double-inclusion guard. */
27 #include_next <string.h>
32 /* NetBSD 5.0 mis-defines NULL. */
35 /* MirBSD defines mbslen as a macro. */
36 #if 1 && defined __MirBSD__
40 /* The __attribute__ feature is available in gcc versions 2.5 and later.
41 The attribute __pure__ was added in gcc 2.96. */
42 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
43 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
45 # define _GL_ATTRIBUTE_PURE /* empty */
48 /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */
49 /* But in any case avoid namespace pollution on glibc systems. */
50 #if (0 || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
51 && ! defined __GLIBC__
55 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
59 /* The three most frequent use cases of these macros are:
61 * For providing a substitute for a function that is missing on some
62 platforms, but is declared and works fine on the platforms on which
67 _GL_FUNCDECL_SYS (foo, ...);
69 _GL_CXXALIAS_SYS (foo, ...);
70 _GL_CXXALIASWARN (foo);
71 #elif defined GNULIB_POSIXCHECK
75 * For providing a replacement for a function that exists on all platforms,
76 but is broken/insufficient and needs to be replaced on some platforms:
80 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
84 _GL_FUNCDECL_RPL (foo, ...);
85 _GL_CXXALIAS_RPL (foo, ...);
87 _GL_CXXALIAS_SYS (foo, ...);
89 _GL_CXXALIASWARN (foo);
90 #elif defined GNULIB_POSIXCHECK
94 * For providing a replacement for a function that exists on some platforms
95 but is broken/insufficient and needs to be replaced on some of them and
96 is additionally either missing or undeclared on some other platforms:
100 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
104 _GL_FUNCDECL_RPL (foo, ...);
105 _GL_CXXALIAS_RPL (foo, ...);
107 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
108 _GL_FUNCDECL_SYS (foo, ...);
110 _GL_CXXALIAS_SYS (foo, ...);
112 _GL_CXXALIASWARN (foo);
113 #elif defined GNULIB_POSIXCHECK
118 /* _GL_EXTERN_C declaration;
119 performs the declaration with C linkage. */
120 #if defined __cplusplus
121 # define _GL_EXTERN_C extern "C"
123 # define _GL_EXTERN_C extern
126 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
127 declares a replacement function, named rpl_func, with the given prototype,
128 consisting of return type, parameters, and attributes.
130 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
131 _GL_ARG_NONNULL ((1)));
133 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
134 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
135 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
136 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
138 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
139 declares the system function, named func, with the given prototype,
140 consisting of return type, parameters, and attributes.
142 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
143 _GL_ARG_NONNULL ((1)));
145 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
146 _GL_EXTERN_C rettype func parameters_and_attributes
148 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
149 declares a C++ alias called GNULIB_NAMESPACE::func
150 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
152 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
154 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
155 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
156 #if defined __cplusplus && defined GNULIB_NAMESPACE
157 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
158 namespace GNULIB_NAMESPACE \
160 rettype (*const func) parameters = ::rpl_func; \
162 _GL_EXTERN_C int _gl_cxxalias_dummy
164 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
165 _GL_EXTERN_C int _gl_cxxalias_dummy
168 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
169 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
170 except that the C function rpl_func may have a slightly different
171 declaration. A cast is used to silence the "invalid conversion" error
172 that would otherwise occur. */
173 #if defined __cplusplus && defined GNULIB_NAMESPACE
174 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
175 namespace GNULIB_NAMESPACE \
177 rettype (*const func) parameters = \
178 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
180 _GL_EXTERN_C int _gl_cxxalias_dummy
182 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
183 _GL_EXTERN_C int _gl_cxxalias_dummy
186 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
187 declares a C++ alias called GNULIB_NAMESPACE::func
188 that redirects to the system provided function func, if GNULIB_NAMESPACE
191 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
193 #if defined __cplusplus && defined GNULIB_NAMESPACE
194 /* If we were to write
195 rettype (*const func) parameters = ::func;
196 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
197 better (remove an indirection through a 'static' pointer variable),
198 but then the _GL_CXXALIASWARN macro below would cause a warning not only
199 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
200 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
201 namespace GNULIB_NAMESPACE \
203 static rettype (*func) parameters = ::func; \
205 _GL_EXTERN_C int _gl_cxxalias_dummy
207 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
208 _GL_EXTERN_C int _gl_cxxalias_dummy
211 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
212 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
213 except that the C function func may have a slightly different declaration.
214 A cast is used to silence the "invalid conversion" error that would
216 #if defined __cplusplus && defined GNULIB_NAMESPACE
217 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
218 namespace GNULIB_NAMESPACE \
220 static rettype (*func) parameters = \
221 reinterpret_cast<rettype(*)parameters>(::func); \
223 _GL_EXTERN_C int _gl_cxxalias_dummy
225 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
226 _GL_EXTERN_C int _gl_cxxalias_dummy
229 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
230 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
231 except that the C function is picked among a set of overloaded functions,
232 namely the one with rettype2 and parameters2. Two consecutive casts
233 are used to silence the "cannot find a match" and "invalid conversion"
234 errors that would otherwise occur. */
235 #if defined __cplusplus && defined GNULIB_NAMESPACE
236 /* The outer cast must be a reinterpret_cast.
237 The inner cast: When the function is defined as a set of overloaded
238 functions, it works as a static_cast<>, choosing the designated variant.
239 When the function is defined as a single variant, it works as a
240 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
241 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
242 namespace GNULIB_NAMESPACE \
244 static rettype (*func) parameters = \
245 reinterpret_cast<rettype(*)parameters>( \
246 (rettype2(*)parameters2)(::func)); \
248 _GL_EXTERN_C int _gl_cxxalias_dummy
250 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
251 _GL_EXTERN_C int _gl_cxxalias_dummy
254 /* _GL_CXXALIASWARN (func);
255 causes a warning to be emitted when ::func is used but not when
256 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
258 #if defined __cplusplus && defined GNULIB_NAMESPACE
259 # define _GL_CXXALIASWARN(func) \
260 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
261 # define _GL_CXXALIASWARN_1(func,namespace) \
262 _GL_CXXALIASWARN_2 (func, namespace)
263 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
264 we enable the warning only when not optimizing. */
266 # define _GL_CXXALIASWARN_2(func,namespace) \
267 _GL_WARN_ON_USE (func, \
268 "The symbol ::" #func " refers to the system function. " \
269 "Use " #namespace "::" #func " instead.")
270 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
271 # define _GL_CXXALIASWARN_2(func,namespace) \
272 extern __typeof__ (func) func
274 # define _GL_CXXALIASWARN_2(func,namespace) \
275 _GL_EXTERN_C int _gl_cxxalias_dummy
278 # define _GL_CXXALIASWARN(func) \
279 _GL_EXTERN_C int _gl_cxxalias_dummy
282 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
283 causes a warning to be emitted when the given overloaded variant of ::func
284 is used but not when GNULIB_NAMESPACE::func is used. */
285 #if defined __cplusplus && defined GNULIB_NAMESPACE
286 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
287 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
289 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
290 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
291 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
292 we enable the warning only when not optimizing. */
294 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
295 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
296 "The symbol ::" #func " refers to the system function. " \
297 "Use " #namespace "::" #func " instead.")
298 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
299 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
300 extern __typeof__ (func) func
302 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
303 _GL_EXTERN_C int _gl_cxxalias_dummy
306 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
307 _GL_EXTERN_C int _gl_cxxalias_dummy
310 #endif /* _GL_CXXDEFS_H */
312 /* The definition of _GL_ARG_NONNULL is copied here. */
313 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
314 that the values passed as arguments n, ..., m must be non-NULL pointers.
315 n = 1 stands for the first argument, n = 2 for the second argument etc. */
316 #ifndef _GL_ARG_NONNULL
317 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
318 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
320 # define _GL_ARG_NONNULL(params)
324 /* The definition of _GL_WARN_ON_USE is copied here. */
325 #ifndef _GL_WARN_ON_USE
327 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
328 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
329 # define _GL_WARN_ON_USE(function, message) \
330 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
331 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
332 /* Verify the existence of the function. */
333 # define _GL_WARN_ON_USE(function, message) \
334 extern __typeof__ (function) function
335 # else /* Unsupported. */
336 # define _GL_WARN_ON_USE(function, message) \
337 _GL_WARN_EXTERN_C int _gl_warn_on_use
341 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
342 is like _GL_WARN_ON_USE (function, "string"), except that the function is
343 declared with the given prototype, consisting of return type, parameters,
345 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
346 not work in this case. */
347 #ifndef _GL_WARN_ON_USE_CXX
348 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
349 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
350 extern rettype function parameters_and_attributes \
351 __attribute__ ((__warning__ (msg)))
352 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
353 /* Verify the existence of the function. */
354 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
355 extern rettype function parameters_and_attributes
356 # else /* Unsupported. */
357 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
358 _GL_WARN_EXTERN_C int _gl_warn_on_use
362 /* _GL_WARN_EXTERN_C declaration;
363 performs the declaration with C linkage. */
364 #ifndef _GL_WARN_EXTERN_C
365 # if defined __cplusplus
366 # define _GL_WARN_EXTERN_C extern "C"
368 # define _GL_WARN_EXTERN_C extern
373 /* Find the index of the least-significant set bit. */
376 _GL_FUNCDECL_SYS (ffsl, int, (long int i));
378 _GL_CXXALIAS_SYS (ffsl, int, (long int i));
379 _GL_CXXALIASWARN (ffsl);
380 #elif defined GNULIB_POSIXCHECK
382 # if HAVE_RAW_DECL_FFSL
383 _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
388 /* Find the index of the least-significant set bit. */
391 _GL_FUNCDECL_SYS (ffsll, int, (long long int i));
393 _GL_CXXALIAS_SYS (ffsll, int, (long long int i));
394 _GL_CXXALIASWARN (ffsll);
395 #elif defined GNULIB_POSIXCHECK
397 # if HAVE_RAW_DECL_FFSLL
398 _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
403 /* Return the first instance of C within N bytes of S, or NULL. */
406 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
407 # define memchr rpl_memchr
409 _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
411 _GL_ARG_NONNULL ((1)));
412 _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
415 _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
417 _GL_ARG_NONNULL ((1)));
419 /* On some systems, this function is defined as an overloaded function:
420 extern "C" { const void * std::memchr (const void *, int, size_t); }
421 extern "C++" { void * std::memchr (void *, int, size_t); } */
422 _GL_CXXALIAS_SYS_CAST2 (memchr,
423 void *, (void const *__s, int __c, size_t __n),
424 void const *, (void const *__s, int __c, size_t __n));
426 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
427 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
428 _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
429 _GL_CXXALIASWARN1 (memchr, void const *,
430 (void const *__s, int __c, size_t __n));
432 _GL_CXXALIASWARN (memchr);
434 #elif defined GNULIB_POSIXCHECK
436 /* Assume memchr is always declared. */
437 _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
438 "use gnulib module memchr for portability" );
441 /* Return the first occurrence of NEEDLE in HAYSTACK. */
444 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
445 # define memmem rpl_memmem
447 _GL_FUNCDECL_RPL (memmem, void *,
448 (void const *__haystack, size_t __haystack_len,
449 void const *__needle, size_t __needle_len)
451 _GL_ARG_NONNULL ((1, 3)));
452 _GL_CXXALIAS_RPL (memmem, void *,
453 (void const *__haystack, size_t __haystack_len,
454 void const *__needle, size_t __needle_len));
457 _GL_FUNCDECL_SYS (memmem, void *,
458 (void const *__haystack, size_t __haystack_len,
459 void const *__needle, size_t __needle_len)
461 _GL_ARG_NONNULL ((1, 3)));
463 _GL_CXXALIAS_SYS (memmem, void *,
464 (void const *__haystack, size_t __haystack_len,
465 void const *__needle, size_t __needle_len));
467 _GL_CXXALIASWARN (memmem);
468 #elif defined GNULIB_POSIXCHECK
470 # if HAVE_RAW_DECL_MEMMEM
471 _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
472 "use gnulib module memmem-simple for portability, "
473 "and module memmem for speed" );
477 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
478 last written byte. */
481 _GL_FUNCDECL_SYS (mempcpy, void *,
482 (void *restrict __dest, void const *restrict __src,
484 _GL_ARG_NONNULL ((1, 2)));
486 _GL_CXXALIAS_SYS (mempcpy, void *,
487 (void *restrict __dest, void const *restrict __src,
489 _GL_CXXALIASWARN (mempcpy);
490 #elif defined GNULIB_POSIXCHECK
492 # if HAVE_RAW_DECL_MEMPCPY
493 _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
494 "use gnulib module mempcpy for portability");
498 /* Search backwards through a block for a byte (specified as an int). */
501 _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
503 _GL_ARG_NONNULL ((1)));
505 /* On some systems, this function is defined as an overloaded function:
506 extern "C++" { const void * std::memrchr (const void *, int, size_t); }
507 extern "C++" { void * std::memrchr (void *, int, size_t); } */
508 _GL_CXXALIAS_SYS_CAST2 (memrchr,
509 void *, (void const *, int, size_t),
510 void const *, (void const *, int, size_t));
511 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
512 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
513 _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
514 _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
516 _GL_CXXALIASWARN (memrchr);
518 #elif defined GNULIB_POSIXCHECK
520 # if HAVE_RAW_DECL_MEMRCHR
521 _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
522 "use gnulib module memrchr for portability");
526 /* Find the first occurrence of C in S. More efficient than
527 memchr(S,C,N), at the expense of undefined behavior if C does not
528 occur within N bytes. */
531 _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
533 _GL_ARG_NONNULL ((1)));
535 /* On some systems, this function is defined as an overloaded function:
536 extern "C++" { const void * std::rawmemchr (const void *, int); }
537 extern "C++" { void * std::rawmemchr (void *, int); } */
538 _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
539 void *, (void const *__s, int __c_in),
540 void const *, (void const *__s, int __c_in));
541 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
542 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
543 _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
544 _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
546 _GL_CXXALIASWARN (rawmemchr);
548 #elif defined GNULIB_POSIXCHECK
550 # if HAVE_RAW_DECL_RAWMEMCHR
551 _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
552 "use gnulib module rawmemchr for portability");
556 /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
559 _GL_FUNCDECL_SYS (stpcpy, char *,
560 (char *restrict __dst, char const *restrict __src)
561 _GL_ARG_NONNULL ((1, 2)));
563 _GL_CXXALIAS_SYS (stpcpy, char *,
564 (char *restrict __dst, char const *restrict __src));
565 _GL_CXXALIASWARN (stpcpy);
566 #elif defined GNULIB_POSIXCHECK
568 # if HAVE_RAW_DECL_STPCPY
569 _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
570 "use gnulib module stpcpy for portability");
574 /* Copy no more than N bytes of SRC to DST, returning a pointer past the
575 last non-NUL byte written into DST. */
578 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
580 # define stpncpy rpl_stpncpy
582 _GL_FUNCDECL_RPL (stpncpy, char *,
583 (char *restrict __dst, char const *restrict __src,
585 _GL_ARG_NONNULL ((1, 2)));
586 _GL_CXXALIAS_RPL (stpncpy, char *,
587 (char *restrict __dst, char const *restrict __src,
591 _GL_FUNCDECL_SYS (stpncpy, char *,
592 (char *restrict __dst, char const *restrict __src,
594 _GL_ARG_NONNULL ((1, 2)));
596 _GL_CXXALIAS_SYS (stpncpy, char *,
597 (char *restrict __dst, char const *restrict __src,
600 _GL_CXXALIASWARN (stpncpy);
601 #elif defined GNULIB_POSIXCHECK
603 # if HAVE_RAW_DECL_STPNCPY
604 _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
605 "use gnulib module stpncpy for portability");
609 #if defined GNULIB_POSIXCHECK
610 /* strchr() does not work with multibyte strings if the locale encoding is
611 GB18030 and the character to be searched is a digit. */
613 /* Assume strchr is always declared. */
614 _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
615 "in some multibyte locales - "
616 "use mbschr if you care about internationalization");
619 /* Find the first occurrence of C in S or the final NUL byte. */
622 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
623 # define strchrnul rpl_strchrnul
625 _GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
627 _GL_ARG_NONNULL ((1)));
628 _GL_CXXALIAS_RPL (strchrnul, char *,
629 (const char *str, int ch));
632 _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
634 _GL_ARG_NONNULL ((1)));
636 /* On some systems, this function is defined as an overloaded function:
637 extern "C++" { const char * std::strchrnul (const char *, int); }
638 extern "C++" { char * std::strchrnul (char *, int); } */
639 _GL_CXXALIAS_SYS_CAST2 (strchrnul,
640 char *, (char const *__s, int __c_in),
641 char const *, (char const *__s, int __c_in));
643 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
644 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
645 _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
646 _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
648 _GL_CXXALIASWARN (strchrnul);
650 #elif defined GNULIB_POSIXCHECK
652 # if HAVE_RAW_DECL_STRCHRNUL
653 _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
654 "use gnulib module strchrnul for portability");
658 /* Duplicate S, returning an identical malloc'd string. */
661 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
663 # define strdup rpl_strdup
665 _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
666 _GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
668 # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
669 /* strdup exists as a function and as a macro. Get rid of the macro. */
672 # if !(1 || defined strdup)
673 _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
675 _GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
677 _GL_CXXALIASWARN (strdup);
678 #elif defined GNULIB_POSIXCHECK
680 # if HAVE_RAW_DECL_STRDUP
681 _GL_WARN_ON_USE (strdup, "strdup is unportable - "
682 "use gnulib module strdup for portability");
686 /* Append no more than N characters from SRC onto DEST. */
689 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
691 # define strncat rpl_strncat
693 _GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
694 _GL_ARG_NONNULL ((1, 2)));
695 _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
697 _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
699 _GL_CXXALIASWARN (strncat);
700 #elif defined GNULIB_POSIXCHECK
702 # if HAVE_RAW_DECL_STRNCAT
703 _GL_WARN_ON_USE (strncat, "strncat is unportable - "
704 "use gnulib module strncat for portability");
708 /* Return a newly allocated copy of at most N bytes of STRING. */
711 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
713 # define strndup rpl_strndup
715 _GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n)
716 _GL_ARG_NONNULL ((1)));
717 _GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n));
720 _GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
721 _GL_ARG_NONNULL ((1)));
723 _GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
725 _GL_CXXALIASWARN (strndup);
726 #elif defined GNULIB_POSIXCHECK
728 # if HAVE_RAW_DECL_STRNDUP
729 _GL_WARN_ON_USE (strndup, "strndup is unportable - "
730 "use gnulib module strndup for portability");
734 /* Find the length (number of bytes) of STRING, but scan at most
735 MAXLEN bytes. If no '\0' terminator is found in that many bytes,
739 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
741 # define strnlen rpl_strnlen
743 _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
745 _GL_ARG_NONNULL ((1)));
746 _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
749 _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
751 _GL_ARG_NONNULL ((1)));
753 _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
755 _GL_CXXALIASWARN (strnlen);
756 #elif defined GNULIB_POSIXCHECK
758 # if HAVE_RAW_DECL_STRNLEN
759 _GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
760 "use gnulib module strnlen for portability");
764 #if defined GNULIB_POSIXCHECK
765 /* strcspn() assumes the second argument is a list of single-byte characters.
766 Even in this simple case, it does not work with multibyte strings if the
767 locale encoding is GB18030 and one of the characters to be searched is a
770 /* Assume strcspn is always declared. */
771 _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
772 "in multibyte locales - "
773 "use mbscspn if you care about internationalization");
776 /* Find the first occurrence in S of any character in ACCEPT. */
779 _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
781 _GL_ARG_NONNULL ((1, 2)));
783 /* On some systems, this function is defined as an overloaded function:
784 extern "C" { const char * strpbrk (const char *, const char *); }
785 extern "C++" { char * strpbrk (char *, const char *); } */
786 _GL_CXXALIAS_SYS_CAST2 (strpbrk,
787 char *, (char const *__s, char const *__accept),
788 const char *, (char const *__s, char const *__accept));
789 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
790 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
791 _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
792 _GL_CXXALIASWARN1 (strpbrk, char const *,
793 (char const *__s, char const *__accept));
795 _GL_CXXALIASWARN (strpbrk);
797 # if defined GNULIB_POSIXCHECK
798 /* strpbrk() assumes the second argument is a list of single-byte characters.
799 Even in this simple case, it does not work with multibyte strings if the
800 locale encoding is GB18030 and one of the characters to be searched is a
803 _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
804 "in multibyte locales - "
805 "use mbspbrk if you care about internationalization");
807 #elif defined GNULIB_POSIXCHECK
809 # if HAVE_RAW_DECL_STRPBRK
810 _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
811 "use gnulib module strpbrk for portability");
815 #if defined GNULIB_POSIXCHECK
816 /* strspn() assumes the second argument is a list of single-byte characters.
817 Even in this simple case, it cannot work with multibyte strings. */
819 /* Assume strspn is always declared. */
820 _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
821 "in multibyte locales - "
822 "use mbsspn if you care about internationalization");
825 #if defined GNULIB_POSIXCHECK
826 /* strrchr() does not work with multibyte strings if the locale encoding is
827 GB18030 and the character to be searched is a digit. */
829 /* Assume strrchr is always declared. */
830 _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
831 "in some multibyte locales - "
832 "use mbsrchr if you care about internationalization");
835 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
836 If one is found, overwrite it with a NUL, and advance *STRINGP
837 to point to the next char after it. Otherwise, set *STRINGP to NULL.
838 If *STRINGP was already NULL, nothing happens.
839 Return the old value of *STRINGP.
841 This is a variant of strtok() that is multithread-safe and supports
844 Caveat: It modifies the original string.
845 Caveat: These functions cannot be used on constant strings.
846 Caveat: The identity of the delimiting character is lost.
847 Caveat: It doesn't work with multibyte strings unless all of the delimiter
848 characters are ASCII characters < 0x30.
850 See also strtok_r(). */
853 _GL_FUNCDECL_SYS (strsep, char *,
854 (char **restrict __stringp, char const *restrict __delim)
855 _GL_ARG_NONNULL ((1, 2)));
857 _GL_CXXALIAS_SYS (strsep, char *,
858 (char **restrict __stringp, char const *restrict __delim));
859 _GL_CXXALIASWARN (strsep);
860 # if defined GNULIB_POSIXCHECK
862 _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
863 "in multibyte locales - "
864 "use mbssep if you care about internationalization");
866 #elif defined GNULIB_POSIXCHECK
868 # if HAVE_RAW_DECL_STRSEP
869 _GL_WARN_ON_USE (strsep, "strsep is unportable - "
870 "use gnulib module strsep for portability");
876 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
877 # define strstr rpl_strstr
879 _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
881 _GL_ARG_NONNULL ((1, 2)));
882 _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
884 /* On some systems, this function is defined as an overloaded function:
885 extern "C++" { const char * strstr (const char *, const char *); }
886 extern "C++" { char * strstr (char *, const char *); } */
887 _GL_CXXALIAS_SYS_CAST2 (strstr,
888 char *, (const char *haystack, const char *needle),
889 const char *, (const char *haystack, const char *needle));
891 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
892 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
893 _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
894 _GL_CXXALIASWARN1 (strstr, const char *,
895 (const char *haystack, const char *needle));
897 _GL_CXXALIASWARN (strstr);
899 #elif defined GNULIB_POSIXCHECK
900 /* strstr() does not work with multibyte strings if the locale encoding is
901 different from UTF-8:
902 POSIX says that it operates on "strings", and "string" in POSIX is defined
903 as a sequence of bytes, not of characters. */
905 /* Assume strstr is always declared. */
906 _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
907 "work correctly on character strings in most "
908 "multibyte locales - "
909 "use mbsstr if you care about internationalization, "
910 "or use strstr if you care about speed");
913 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
917 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
918 # define strcasestr rpl_strcasestr
920 _GL_FUNCDECL_RPL (strcasestr, char *,
921 (const char *haystack, const char *needle)
923 _GL_ARG_NONNULL ((1, 2)));
924 _GL_CXXALIAS_RPL (strcasestr, char *,
925 (const char *haystack, const char *needle));
928 _GL_FUNCDECL_SYS (strcasestr, char *,
929 (const char *haystack, const char *needle)
931 _GL_ARG_NONNULL ((1, 2)));
933 /* On some systems, this function is defined as an overloaded function:
934 extern "C++" { const char * strcasestr (const char *, const char *); }
935 extern "C++" { char * strcasestr (char *, const char *); } */
936 _GL_CXXALIAS_SYS_CAST2 (strcasestr,
937 char *, (const char *haystack, const char *needle),
938 const char *, (const char *haystack, const char *needle));
940 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
941 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
942 _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
943 _GL_CXXALIASWARN1 (strcasestr, const char *,
944 (const char *haystack, const char *needle));
946 _GL_CXXALIASWARN (strcasestr);
948 #elif defined GNULIB_POSIXCHECK
949 /* strcasestr() does not work with multibyte strings:
950 It is a glibc extension, and glibc implements it only for unibyte
953 # if HAVE_RAW_DECL_STRCASESTR
954 _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
955 "strings in multibyte locales - "
956 "use mbscasestr if you care about "
957 "internationalization, or use c-strcasestr if you want "
958 "a locale independent function");
962 /* Parse S into tokens separated by characters in DELIM.
963 If S is NULL, the saved pointer in SAVE_PTR is used as
964 the next starting point. For example:
965 char s[] = "-abc-=-def";
967 x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
968 x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
969 x = strtok_r(NULL, "=", &sp); // x = NULL
972 This is a variant of strtok() that is multithread-safe.
974 For the POSIX documentation for this function, see:
975 http://www.opengroup.org/susv3xsh/strtok.html
977 Caveat: It modifies the original string.
978 Caveat: These functions cannot be used on constant strings.
979 Caveat: The identity of the delimiting character is lost.
980 Caveat: It doesn't work with multibyte strings unless all of the delimiter
981 characters are ASCII characters < 0x30.
983 See also strsep(). */
986 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
988 # define strtok_r rpl_strtok_r
990 _GL_FUNCDECL_RPL (strtok_r, char *,
991 (char *restrict s, char const *restrict delim,
992 char **restrict save_ptr)
993 _GL_ARG_NONNULL ((2, 3)));
994 _GL_CXXALIAS_RPL (strtok_r, char *,
995 (char *restrict s, char const *restrict delim,
996 char **restrict save_ptr));
998 # if 0 || defined GNULIB_POSIXCHECK
1002 _GL_FUNCDECL_SYS (strtok_r, char *,
1003 (char *restrict s, char const *restrict delim,
1004 char **restrict save_ptr)
1005 _GL_ARG_NONNULL ((2, 3)));
1007 _GL_CXXALIAS_SYS (strtok_r, char *,
1008 (char *restrict s, char const *restrict delim,
1009 char **restrict save_ptr));
1011 _GL_CXXALIASWARN (strtok_r);
1012 # if defined GNULIB_POSIXCHECK
1013 _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
1014 "strings in multibyte locales - "
1015 "use mbstok_r if you care about internationalization");
1017 #elif defined GNULIB_POSIXCHECK
1019 # if HAVE_RAW_DECL_STRTOK_R
1020 _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
1021 "use gnulib module strtok_r for portability");
1026 /* The following functions are not specified by POSIX. They are gnulib
1030 /* Return the number of multibyte characters in the character string STRING.
1031 This considers multibyte characters, unlike strlen, which counts bytes. */
1032 # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
1035 # if 0 /* AIX, OSF/1, MirBSD define mbslen already in libc. */
1036 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1037 # define mbslen rpl_mbslen
1039 _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string)
1041 _GL_ARG_NONNULL ((1)));
1042 _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
1044 _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
1046 _GL_ARG_NONNULL ((1)));
1047 _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
1049 _GL_CXXALIASWARN (mbslen);
1053 /* Return the number of multibyte characters in the character string starting
1054 at STRING and ending at STRING + LEN. */
1055 _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
1057 _GL_ARG_NONNULL ((1));
1061 /* Locate the first single-byte character C in the character string STRING,
1062 and return a pointer to it. Return NULL if C is not found in STRING.
1063 Unlike strchr(), this function works correctly in multibyte locales with
1064 encodings such as GB18030. */
1066 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1067 # define mbschr rpl_mbschr /* avoid collision with HP-UX function */
1069 _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
1071 _GL_ARG_NONNULL ((1)));
1072 _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
1074 _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
1076 _GL_ARG_NONNULL ((1)));
1077 _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
1079 _GL_CXXALIASWARN (mbschr);
1083 /* Locate the last single-byte character C in the character string STRING,
1084 and return a pointer to it. Return NULL if C is not found in STRING.
1085 Unlike strrchr(), this function works correctly in multibyte locales with
1086 encodings such as GB18030. */
1087 # if defined __hpux || defined __INTERIX
1088 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1089 # define mbsrchr rpl_mbsrchr /* avoid collision with system function */
1091 _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
1093 _GL_ARG_NONNULL ((1)));
1094 _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
1096 _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
1098 _GL_ARG_NONNULL ((1)));
1099 _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
1101 _GL_CXXALIASWARN (mbsrchr);
1105 /* Find the first occurrence of the character string NEEDLE in the character
1106 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
1107 Unlike strstr(), this function works correctly in multibyte locales with
1108 encodings different from UTF-8. */
1109 _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
1111 _GL_ARG_NONNULL ((1, 2));
1115 /* Compare the character strings S1 and S2, ignoring case, returning less than,
1116 equal to or greater than zero if S1 is lexicographically less than, equal to
1118 Note: This function may, in multibyte locales, return 0 for strings of
1120 Unlike strcasecmp(), this function works correctly in multibyte locales. */
1121 _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
1123 _GL_ARG_NONNULL ((1, 2));
1127 /* Compare the initial segment of the character string S1 consisting of at most
1128 N characters with the initial segment of the character string S2 consisting
1129 of at most N characters, ignoring case, returning less than, equal to or
1130 greater than zero if the initial segment of S1 is lexicographically less
1131 than, equal to or greater than the initial segment of S2.
1132 Note: This function may, in multibyte locales, return 0 for initial segments
1133 of different lengths!
1134 Unlike strncasecmp(), this function works correctly in multibyte locales.
1135 But beware that N is not a byte count but a character count! */
1136 _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
1138 _GL_ARG_NONNULL ((1, 2));
1142 /* Compare the initial segment of the character string STRING consisting of
1143 at most mbslen (PREFIX) characters with the character string PREFIX,
1144 ignoring case. If the two match, return a pointer to the first byte
1145 after this prefix in STRING. Otherwise, return NULL.
1146 Note: This function may, in multibyte locales, return non-NULL if STRING
1147 is of smaller length than PREFIX!
1148 Unlike strncasecmp(), this function works correctly in multibyte
1150 _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1152 _GL_ARG_NONNULL ((1, 2));
1156 /* Find the first occurrence of the character string NEEDLE in the character
1157 string HAYSTACK, using case-insensitive comparison.
1158 Note: This function may, in multibyte locales, return success even if
1159 strlen (haystack) < strlen (needle) !
1160 Unlike strcasestr(), this function works correctly in multibyte locales. */
1161 _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
1163 _GL_ARG_NONNULL ((1, 2));
1167 /* Find the first occurrence in the character string STRING of any character
1168 in the character string ACCEPT. Return the number of bytes from the
1169 beginning of the string to this occurrence, or to the end of the string
1171 Unlike strcspn(), this function works correctly in multibyte locales. */
1172 _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
1174 _GL_ARG_NONNULL ((1, 2));
1178 /* Find the first occurrence in the character string STRING of any character
1179 in the character string ACCEPT. Return the pointer to it, or NULL if none
1181 Unlike strpbrk(), this function works correctly in multibyte locales. */
1183 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1184 # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
1186 _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
1188 _GL_ARG_NONNULL ((1, 2)));
1189 _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
1191 _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
1193 _GL_ARG_NONNULL ((1, 2)));
1194 _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
1196 _GL_CXXALIASWARN (mbspbrk);
1200 /* Find the first occurrence in the character string STRING of any character
1201 not in the character string REJECT. Return the number of bytes from the
1202 beginning of the string to this occurrence, or to the end of the string
1204 Unlike strspn(), this function works correctly in multibyte locales. */
1205 _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
1207 _GL_ARG_NONNULL ((1, 2));
1211 /* Search the next delimiter (multibyte character listed in the character
1212 string DELIM) starting at the character string *STRINGP.
1213 If one is found, overwrite it with a NUL, and advance *STRINGP to point
1214 to the next multibyte character after it. Otherwise, set *STRINGP to NULL.
1215 If *STRINGP was already NULL, nothing happens.
1216 Return the old value of *STRINGP.
1218 This is a variant of mbstok_r() that supports empty fields.
1220 Caveat: It modifies the original string.
1221 Caveat: These functions cannot be used on constant strings.
1222 Caveat: The identity of the delimiting character is lost.
1224 See also mbstok_r(). */
1225 _GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
1226 _GL_ARG_NONNULL ((1, 2));
1230 /* Parse the character string STRING into tokens separated by characters in
1231 the character string DELIM.
1232 If STRING is NULL, the saved pointer in SAVE_PTR is used as
1233 the next starting point. For example:
1234 char s[] = "-abc-=-def";
1236 x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
1237 x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
1238 x = mbstok_r(NULL, "=", &sp); // x = NULL
1239 // s = "abc\0-def\0"
1241 Caveat: It modifies the original string.
1242 Caveat: These functions cannot be used on constant strings.
1243 Caveat: The identity of the delimiting character is lost.
1245 See also mbssep(). */
1246 _GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
1247 _GL_ARG_NONNULL ((2, 3));
1250 /* Map any int, typically from errno, into an error message. */
1253 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1255 # define strerror rpl_strerror
1257 _GL_FUNCDECL_RPL (strerror, char *, (int));
1258 _GL_CXXALIAS_RPL (strerror, char *, (int));
1260 _GL_CXXALIAS_SYS (strerror, char *, (int));
1262 _GL_CXXALIASWARN (strerror);
1263 #elif defined GNULIB_POSIXCHECK
1265 /* Assume strerror is always declared. */
1266 _GL_WARN_ON_USE (strerror, "strerror is unportable - "
1267 "use gnulib module strerror to guarantee non-NULL result");
1270 /* Map any int, typically from errno, into an error message. Multithread-safe.
1271 Uses the POSIX declaration, not the glibc declaration. */
1274 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1276 # define strerror_r rpl_strerror_r
1278 _GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
1279 _GL_ARG_NONNULL ((2)));
1280 _GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
1283 _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
1284 _GL_ARG_NONNULL ((2)));
1286 _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
1289 _GL_CXXALIASWARN (strerror_r);
1291 #elif defined GNULIB_POSIXCHECK
1293 # if HAVE_RAW_DECL_STRERROR_R
1294 _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1295 "use gnulib module strerror_r-posix for portability");
1301 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1302 # define strsignal rpl_strsignal
1304 _GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
1305 _GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
1308 _GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
1310 /* Need to cast, because on Cygwin 1.5.x systems, the return type is
1312 _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
1314 _GL_CXXALIASWARN (strsignal);
1315 #elif defined GNULIB_POSIXCHECK
1317 # if HAVE_RAW_DECL_STRSIGNAL
1318 _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
1319 "use gnulib module strsignal for portability");
1325 _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
1327 _GL_ARG_NONNULL ((1, 2)));
1329 _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
1330 _GL_CXXALIASWARN (strverscmp);
1331 #elif defined GNULIB_POSIXCHECK
1333 # if HAVE_RAW_DECL_STRVERSCMP
1334 _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1335 "use gnulib module strverscmp for portability");
1340 #endif /* _GL_STRING_H */
1341 #endif /* _GL_STRING_H */