1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* -*- buffer-read-only: t -*- vi: set ro: */
3 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
4 /* A GNU-like <string.h>.
6 Copyright (C) 1995-1996, 2001-2011 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software Foundation,
20 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
25 #pragma GCC system_header
29 /* The include_next requires a split double-inclusion guard. */
30 #include_next <string.h>
35 /* NetBSD 5.0 mis-defines NULL. */
38 /* MirBSD defines mbslen as a macro. */
39 #if 1 && defined __MirBSD__
43 /* The __attribute__ feature is available in gcc versions 2.5 and later.
44 The attribute __pure__ was added in gcc 2.96. */
45 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
46 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
48 # define _GL_ATTRIBUTE_PURE /* empty */
51 /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */
52 /* But in any case avoid namespace pollution on glibc systems. */
53 #if (0 || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
54 && ! defined __GLIBC__
58 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
62 /* The three most frequent use cases of these macros are:
64 * For providing a substitute for a function that is missing on some
65 platforms, but is declared and works fine on the platforms on which
70 _GL_FUNCDECL_SYS (foo, ...);
72 _GL_CXXALIAS_SYS (foo, ...);
73 _GL_CXXALIASWARN (foo);
74 #elif defined GNULIB_POSIXCHECK
78 * For providing a replacement for a function that exists on all platforms,
79 but is broken/insufficient and needs to be replaced on some platforms:
83 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
87 _GL_FUNCDECL_RPL (foo, ...);
88 _GL_CXXALIAS_RPL (foo, ...);
90 _GL_CXXALIAS_SYS (foo, ...);
92 _GL_CXXALIASWARN (foo);
93 #elif defined GNULIB_POSIXCHECK
97 * For providing a replacement for a function that exists on some platforms
98 but is broken/insufficient and needs to be replaced on some of them and
99 is additionally either missing or undeclared on some other platforms:
103 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
107 _GL_FUNCDECL_RPL (foo, ...);
108 _GL_CXXALIAS_RPL (foo, ...);
110 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
111 _GL_FUNCDECL_SYS (foo, ...);
113 _GL_CXXALIAS_SYS (foo, ...);
115 _GL_CXXALIASWARN (foo);
116 #elif defined GNULIB_POSIXCHECK
121 /* _GL_EXTERN_C declaration;
122 performs the declaration with C linkage. */
123 #if defined __cplusplus
124 # define _GL_EXTERN_C extern "C"
126 # define _GL_EXTERN_C extern
129 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
130 declares a replacement function, named rpl_func, with the given prototype,
131 consisting of return type, parameters, and attributes.
133 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
134 _GL_ARG_NONNULL ((1)));
136 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
137 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
138 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
139 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
141 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
142 declares the system function, named func, with the given prototype,
143 consisting of return type, parameters, and attributes.
145 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
146 _GL_ARG_NONNULL ((1)));
148 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
149 _GL_EXTERN_C rettype func parameters_and_attributes
151 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
152 declares a C++ alias called GNULIB_NAMESPACE::func
153 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
155 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
157 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
158 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
159 #if defined __cplusplus && defined GNULIB_NAMESPACE
160 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
161 namespace GNULIB_NAMESPACE \
163 rettype (*const func) parameters = ::rpl_func; \
165 _GL_EXTERN_C int _gl_cxxalias_dummy
167 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
168 _GL_EXTERN_C int _gl_cxxalias_dummy
171 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
172 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
173 except that the C function rpl_func may have a slightly different
174 declaration. A cast is used to silence the "invalid conversion" error
175 that would otherwise occur. */
176 #if defined __cplusplus && defined GNULIB_NAMESPACE
177 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
178 namespace GNULIB_NAMESPACE \
180 rettype (*const func) parameters = \
181 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
183 _GL_EXTERN_C int _gl_cxxalias_dummy
185 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
186 _GL_EXTERN_C int _gl_cxxalias_dummy
189 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
190 declares a C++ alias called GNULIB_NAMESPACE::func
191 that redirects to the system provided function func, if GNULIB_NAMESPACE
194 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
196 #if defined __cplusplus && defined GNULIB_NAMESPACE
197 /* If we were to write
198 rettype (*const func) parameters = ::func;
199 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
200 better (remove an indirection through a 'static' pointer variable),
201 but then the _GL_CXXALIASWARN macro below would cause a warning not only
202 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
203 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
204 namespace GNULIB_NAMESPACE \
206 static rettype (*func) parameters = ::func; \
208 _GL_EXTERN_C int _gl_cxxalias_dummy
210 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
211 _GL_EXTERN_C int _gl_cxxalias_dummy
214 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
215 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
216 except that the C function func may have a slightly different declaration.
217 A cast is used to silence the "invalid conversion" error that would
219 #if defined __cplusplus && defined GNULIB_NAMESPACE
220 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
221 namespace GNULIB_NAMESPACE \
223 static rettype (*func) parameters = \
224 reinterpret_cast<rettype(*)parameters>(::func); \
226 _GL_EXTERN_C int _gl_cxxalias_dummy
228 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
229 _GL_EXTERN_C int _gl_cxxalias_dummy
232 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
233 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
234 except that the C function is picked among a set of overloaded functions,
235 namely the one with rettype2 and parameters2. Two consecutive casts
236 are used to silence the "cannot find a match" and "invalid conversion"
237 errors that would otherwise occur. */
238 #if defined __cplusplus && defined GNULIB_NAMESPACE
239 /* The outer cast must be a reinterpret_cast.
240 The inner cast: When the function is defined as a set of overloaded
241 functions, it works as a static_cast<>, choosing the designated variant.
242 When the function is defined as a single variant, it works as a
243 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
244 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
245 namespace GNULIB_NAMESPACE \
247 static rettype (*func) parameters = \
248 reinterpret_cast<rettype(*)parameters>( \
249 (rettype2(*)parameters2)(::func)); \
251 _GL_EXTERN_C int _gl_cxxalias_dummy
253 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
254 _GL_EXTERN_C int _gl_cxxalias_dummy
257 /* _GL_CXXALIASWARN (func);
258 causes a warning to be emitted when ::func is used but not when
259 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
261 #if defined __cplusplus && defined GNULIB_NAMESPACE
262 # define _GL_CXXALIASWARN(func) \
263 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
264 # define _GL_CXXALIASWARN_1(func,namespace) \
265 _GL_CXXALIASWARN_2 (func, namespace)
266 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
267 we enable the warning only when not optimizing. */
269 # define _GL_CXXALIASWARN_2(func,namespace) \
270 _GL_WARN_ON_USE (func, \
271 "The symbol ::" #func " refers to the system function. " \
272 "Use " #namespace "::" #func " instead.")
273 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
274 # define _GL_CXXALIASWARN_2(func,namespace) \
275 extern __typeof__ (func) func
277 # define _GL_CXXALIASWARN_2(func,namespace) \
278 _GL_EXTERN_C int _gl_cxxalias_dummy
281 # define _GL_CXXALIASWARN(func) \
282 _GL_EXTERN_C int _gl_cxxalias_dummy
285 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
286 causes a warning to be emitted when the given overloaded variant of ::func
287 is used but not when GNULIB_NAMESPACE::func is used. */
288 #if defined __cplusplus && defined GNULIB_NAMESPACE
289 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
290 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
292 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
293 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
294 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
295 we enable the warning only when not optimizing. */
297 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
298 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
299 "The symbol ::" #func " refers to the system function. " \
300 "Use " #namespace "::" #func " instead.")
301 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
302 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
303 extern __typeof__ (func) func
305 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
306 _GL_EXTERN_C int _gl_cxxalias_dummy
309 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
310 _GL_EXTERN_C int _gl_cxxalias_dummy
313 #endif /* _GL_CXXDEFS_H */
315 /* The definition of _GL_ARG_NONNULL is copied here. */
316 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
317 that the values passed as arguments n, ..., m must be non-NULL pointers.
318 n = 1 stands for the first argument, n = 2 for the second argument etc. */
319 #ifndef _GL_ARG_NONNULL
320 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
321 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
323 # define _GL_ARG_NONNULL(params)
327 /* The definition of _GL_WARN_ON_USE is copied here. */
328 #ifndef _GL_WARN_ON_USE
330 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
331 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
332 # define _GL_WARN_ON_USE(function, message) \
333 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
334 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
335 /* Verify the existence of the function. */
336 # define _GL_WARN_ON_USE(function, message) \
337 extern __typeof__ (function) function
338 # else /* Unsupported. */
339 # define _GL_WARN_ON_USE(function, message) \
340 _GL_WARN_EXTERN_C int _gl_warn_on_use
344 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
345 is like _GL_WARN_ON_USE (function, "string"), except that the function is
346 declared with the given prototype, consisting of return type, parameters,
348 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
349 not work in this case. */
350 #ifndef _GL_WARN_ON_USE_CXX
351 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
352 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
353 extern rettype function parameters_and_attributes \
354 __attribute__ ((__warning__ (msg)))
355 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
356 /* Verify the existence of the function. */
357 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
358 extern rettype function parameters_and_attributes
359 # else /* Unsupported. */
360 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
361 _GL_WARN_EXTERN_C int _gl_warn_on_use
365 /* _GL_WARN_EXTERN_C declaration;
366 performs the declaration with C linkage. */
367 #ifndef _GL_WARN_EXTERN_C
368 # if defined __cplusplus
369 # define _GL_WARN_EXTERN_C extern "C"
371 # define _GL_WARN_EXTERN_C extern
376 /* Find the index of the least-significant set bit. */
379 _GL_FUNCDECL_SYS (ffsl, int, (long int i));
381 _GL_CXXALIAS_SYS (ffsl, int, (long int i));
382 _GL_CXXALIASWARN (ffsl);
383 #elif defined GNULIB_POSIXCHECK
385 # if HAVE_RAW_DECL_FFSL
386 _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
391 /* Find the index of the least-significant set bit. */
394 _GL_FUNCDECL_SYS (ffsll, int, (long long int i));
396 _GL_CXXALIAS_SYS (ffsll, int, (long long int i));
397 _GL_CXXALIASWARN (ffsll);
398 #elif defined GNULIB_POSIXCHECK
400 # if HAVE_RAW_DECL_FFSLL
401 _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
406 /* Return the first instance of C within N bytes of S, or NULL. */
409 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
410 # define memchr rpl_memchr
412 _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
414 _GL_ARG_NONNULL ((1)));
415 _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
418 _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
420 _GL_ARG_NONNULL ((1)));
422 /* On some systems, this function is defined as an overloaded function:
423 extern "C" { const void * std::memchr (const void *, int, size_t); }
424 extern "C++" { void * std::memchr (void *, int, size_t); } */
425 _GL_CXXALIAS_SYS_CAST2 (memchr,
426 void *, (void const *__s, int __c, size_t __n),
427 void const *, (void const *__s, int __c, size_t __n));
429 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
430 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
431 _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
432 _GL_CXXALIASWARN1 (memchr, void const *,
433 (void const *__s, int __c, size_t __n));
435 _GL_CXXALIASWARN (memchr);
437 #elif defined GNULIB_POSIXCHECK
439 /* Assume memchr is always declared. */
440 _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
441 "use gnulib module memchr for portability" );
444 /* Return the first occurrence of NEEDLE in HAYSTACK. */
447 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
448 # define memmem rpl_memmem
450 _GL_FUNCDECL_RPL (memmem, void *,
451 (void const *__haystack, size_t __haystack_len,
452 void const *__needle, size_t __needle_len)
454 _GL_ARG_NONNULL ((1, 3)));
455 _GL_CXXALIAS_RPL (memmem, void *,
456 (void const *__haystack, size_t __haystack_len,
457 void const *__needle, size_t __needle_len));
460 _GL_FUNCDECL_SYS (memmem, void *,
461 (void const *__haystack, size_t __haystack_len,
462 void const *__needle, size_t __needle_len)
464 _GL_ARG_NONNULL ((1, 3)));
466 _GL_CXXALIAS_SYS (memmem, void *,
467 (void const *__haystack, size_t __haystack_len,
468 void const *__needle, size_t __needle_len));
470 _GL_CXXALIASWARN (memmem);
471 #elif defined GNULIB_POSIXCHECK
473 # if HAVE_RAW_DECL_MEMMEM
474 _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
475 "use gnulib module memmem-simple for portability, "
476 "and module memmem for speed" );
480 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
481 last written byte. */
484 _GL_FUNCDECL_SYS (mempcpy, void *,
485 (void *restrict __dest, void const *restrict __src,
487 _GL_ARG_NONNULL ((1, 2)));
489 _GL_CXXALIAS_SYS (mempcpy, void *,
490 (void *restrict __dest, void const *restrict __src,
492 _GL_CXXALIASWARN (mempcpy);
493 #elif defined GNULIB_POSIXCHECK
495 # if HAVE_RAW_DECL_MEMPCPY
496 _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
497 "use gnulib module mempcpy for portability");
501 /* Search backwards through a block for a byte (specified as an int). */
504 _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
506 _GL_ARG_NONNULL ((1)));
508 /* On some systems, this function is defined as an overloaded function:
509 extern "C++" { const void * std::memrchr (const void *, int, size_t); }
510 extern "C++" { void * std::memrchr (void *, int, size_t); } */
511 _GL_CXXALIAS_SYS_CAST2 (memrchr,
512 void *, (void const *, int, size_t),
513 void const *, (void const *, int, size_t));
514 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
515 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
516 _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
517 _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
519 _GL_CXXALIASWARN (memrchr);
521 #elif defined GNULIB_POSIXCHECK
523 # if HAVE_RAW_DECL_MEMRCHR
524 _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
525 "use gnulib module memrchr for portability");
529 /* Find the first occurrence of C in S. More efficient than
530 memchr(S,C,N), at the expense of undefined behavior if C does not
531 occur within N bytes. */
534 _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
536 _GL_ARG_NONNULL ((1)));
538 /* On some systems, this function is defined as an overloaded function:
539 extern "C++" { const void * std::rawmemchr (const void *, int); }
540 extern "C++" { void * std::rawmemchr (void *, int); } */
541 _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
542 void *, (void const *__s, int __c_in),
543 void const *, (void const *__s, int __c_in));
544 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
545 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
546 _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
547 _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
549 _GL_CXXALIASWARN (rawmemchr);
551 #elif defined GNULIB_POSIXCHECK
553 # if HAVE_RAW_DECL_RAWMEMCHR
554 _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
555 "use gnulib module rawmemchr for portability");
559 /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
562 _GL_FUNCDECL_SYS (stpcpy, char *,
563 (char *restrict __dst, char const *restrict __src)
564 _GL_ARG_NONNULL ((1, 2)));
566 _GL_CXXALIAS_SYS (stpcpy, char *,
567 (char *restrict __dst, char const *restrict __src));
568 _GL_CXXALIASWARN (stpcpy);
569 #elif defined GNULIB_POSIXCHECK
571 # if HAVE_RAW_DECL_STPCPY
572 _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
573 "use gnulib module stpcpy for portability");
577 /* Copy no more than N bytes of SRC to DST, returning a pointer past the
578 last non-NUL byte written into DST. */
581 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
583 # define stpncpy rpl_stpncpy
585 _GL_FUNCDECL_RPL (stpncpy, char *,
586 (char *restrict __dst, char const *restrict __src,
588 _GL_ARG_NONNULL ((1, 2)));
589 _GL_CXXALIAS_RPL (stpncpy, char *,
590 (char *restrict __dst, char const *restrict __src,
594 _GL_FUNCDECL_SYS (stpncpy, char *,
595 (char *restrict __dst, char const *restrict __src,
597 _GL_ARG_NONNULL ((1, 2)));
599 _GL_CXXALIAS_SYS (stpncpy, char *,
600 (char *restrict __dst, char const *restrict __src,
603 _GL_CXXALIASWARN (stpncpy);
604 #elif defined GNULIB_POSIXCHECK
606 # if HAVE_RAW_DECL_STPNCPY
607 _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
608 "use gnulib module stpncpy for portability");
612 #if defined GNULIB_POSIXCHECK
613 /* strchr() does not work with multibyte strings if the locale encoding is
614 GB18030 and the character to be searched is a digit. */
616 /* Assume strchr is always declared. */
617 _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
618 "in some multibyte locales - "
619 "use mbschr if you care about internationalization");
622 /* Find the first occurrence of C in S or the final NUL byte. */
625 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
626 # define strchrnul rpl_strchrnul
628 _GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
630 _GL_ARG_NONNULL ((1)));
631 _GL_CXXALIAS_RPL (strchrnul, char *,
632 (const char *str, int ch));
635 _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
637 _GL_ARG_NONNULL ((1)));
639 /* On some systems, this function is defined as an overloaded function:
640 extern "C++" { const char * std::strchrnul (const char *, int); }
641 extern "C++" { char * std::strchrnul (char *, int); } */
642 _GL_CXXALIAS_SYS_CAST2 (strchrnul,
643 char *, (char const *__s, int __c_in),
644 char const *, (char const *__s, int __c_in));
646 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
647 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
648 _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
649 _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
651 _GL_CXXALIASWARN (strchrnul);
653 #elif defined GNULIB_POSIXCHECK
655 # if HAVE_RAW_DECL_STRCHRNUL
656 _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
657 "use gnulib module strchrnul for portability");
661 /* Duplicate S, returning an identical malloc'd string. */
664 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
666 # define strdup rpl_strdup
668 _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
669 _GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
671 # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
672 /* strdup exists as a function and as a macro. Get rid of the macro. */
675 # if !(1 || defined strdup)
676 _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
678 _GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
680 _GL_CXXALIASWARN (strdup);
681 #elif defined GNULIB_POSIXCHECK
683 # if HAVE_RAW_DECL_STRDUP
684 _GL_WARN_ON_USE (strdup, "strdup is unportable - "
685 "use gnulib module strdup for portability");
689 /* Append no more than N characters from SRC onto DEST. */
692 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
694 # define strncat rpl_strncat
696 _GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
697 _GL_ARG_NONNULL ((1, 2)));
698 _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
700 _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
702 _GL_CXXALIASWARN (strncat);
703 #elif defined GNULIB_POSIXCHECK
705 # if HAVE_RAW_DECL_STRNCAT
706 _GL_WARN_ON_USE (strncat, "strncat is unportable - "
707 "use gnulib module strncat for portability");
711 /* Return a newly allocated copy of at most N bytes of STRING. */
714 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
716 # define strndup rpl_strndup
718 _GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n)
719 _GL_ARG_NONNULL ((1)));
720 _GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n));
723 _GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
724 _GL_ARG_NONNULL ((1)));
726 _GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
728 _GL_CXXALIASWARN (strndup);
729 #elif defined GNULIB_POSIXCHECK
731 # if HAVE_RAW_DECL_STRNDUP
732 _GL_WARN_ON_USE (strndup, "strndup is unportable - "
733 "use gnulib module strndup for portability");
737 /* Find the length (number of bytes) of STRING, but scan at most
738 MAXLEN bytes. If no '\0' terminator is found in that many bytes,
742 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
744 # define strnlen rpl_strnlen
746 _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
748 _GL_ARG_NONNULL ((1)));
749 _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
752 _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
754 _GL_ARG_NONNULL ((1)));
756 _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
758 _GL_CXXALIASWARN (strnlen);
759 #elif defined GNULIB_POSIXCHECK
761 # if HAVE_RAW_DECL_STRNLEN
762 _GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
763 "use gnulib module strnlen for portability");
767 #if defined GNULIB_POSIXCHECK
768 /* strcspn() assumes the second argument is a list of single-byte characters.
769 Even in this simple case, it does not work with multibyte strings if the
770 locale encoding is GB18030 and one of the characters to be searched is a
773 /* Assume strcspn is always declared. */
774 _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
775 "in multibyte locales - "
776 "use mbscspn if you care about internationalization");
779 /* Find the first occurrence in S of any character in ACCEPT. */
782 _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
784 _GL_ARG_NONNULL ((1, 2)));
786 /* On some systems, this function is defined as an overloaded function:
787 extern "C" { const char * strpbrk (const char *, const char *); }
788 extern "C++" { char * strpbrk (char *, const char *); } */
789 _GL_CXXALIAS_SYS_CAST2 (strpbrk,
790 char *, (char const *__s, char const *__accept),
791 const char *, (char const *__s, char const *__accept));
792 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
793 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
794 _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
795 _GL_CXXALIASWARN1 (strpbrk, char const *,
796 (char const *__s, char const *__accept));
798 _GL_CXXALIASWARN (strpbrk);
800 # if defined GNULIB_POSIXCHECK
801 /* strpbrk() assumes the second argument is a list of single-byte characters.
802 Even in this simple case, it does not work with multibyte strings if the
803 locale encoding is GB18030 and one of the characters to be searched is a
806 _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
807 "in multibyte locales - "
808 "use mbspbrk if you care about internationalization");
810 #elif defined GNULIB_POSIXCHECK
812 # if HAVE_RAW_DECL_STRPBRK
813 _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
814 "use gnulib module strpbrk for portability");
818 #if defined GNULIB_POSIXCHECK
819 /* strspn() assumes the second argument is a list of single-byte characters.
820 Even in this simple case, it cannot work with multibyte strings. */
822 /* Assume strspn is always declared. */
823 _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
824 "in multibyte locales - "
825 "use mbsspn if you care about internationalization");
828 #if defined GNULIB_POSIXCHECK
829 /* strrchr() does not work with multibyte strings if the locale encoding is
830 GB18030 and the character to be searched is a digit. */
832 /* Assume strrchr is always declared. */
833 _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
834 "in some multibyte locales - "
835 "use mbsrchr if you care about internationalization");
838 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
839 If one is found, overwrite it with a NUL, and advance *STRINGP
840 to point to the next char after it. Otherwise, set *STRINGP to NULL.
841 If *STRINGP was already NULL, nothing happens.
842 Return the old value of *STRINGP.
844 This is a variant of strtok() that is multithread-safe and supports
847 Caveat: It modifies the original string.
848 Caveat: These functions cannot be used on constant strings.
849 Caveat: The identity of the delimiting character is lost.
850 Caveat: It doesn't work with multibyte strings unless all of the delimiter
851 characters are ASCII characters < 0x30.
853 See also strtok_r(). */
856 _GL_FUNCDECL_SYS (strsep, char *,
857 (char **restrict __stringp, char const *restrict __delim)
858 _GL_ARG_NONNULL ((1, 2)));
860 _GL_CXXALIAS_SYS (strsep, char *,
861 (char **restrict __stringp, char const *restrict __delim));
862 _GL_CXXALIASWARN (strsep);
863 # if defined GNULIB_POSIXCHECK
865 _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
866 "in multibyte locales - "
867 "use mbssep if you care about internationalization");
869 #elif defined GNULIB_POSIXCHECK
871 # if HAVE_RAW_DECL_STRSEP
872 _GL_WARN_ON_USE (strsep, "strsep is unportable - "
873 "use gnulib module strsep for portability");
879 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
880 # define strstr rpl_strstr
882 _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
884 _GL_ARG_NONNULL ((1, 2)));
885 _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
887 /* On some systems, this function is defined as an overloaded function:
888 extern "C++" { const char * strstr (const char *, const char *); }
889 extern "C++" { char * strstr (char *, const char *); } */
890 _GL_CXXALIAS_SYS_CAST2 (strstr,
891 char *, (const char *haystack, const char *needle),
892 const char *, (const char *haystack, const char *needle));
894 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
895 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
896 _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
897 _GL_CXXALIASWARN1 (strstr, const char *,
898 (const char *haystack, const char *needle));
900 _GL_CXXALIASWARN (strstr);
902 #elif defined GNULIB_POSIXCHECK
903 /* strstr() does not work with multibyte strings if the locale encoding is
904 different from UTF-8:
905 POSIX says that it operates on "strings", and "string" in POSIX is defined
906 as a sequence of bytes, not of characters. */
908 /* Assume strstr is always declared. */
909 _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
910 "work correctly on character strings in most "
911 "multibyte locales - "
912 "use mbsstr if you care about internationalization, "
913 "or use strstr if you care about speed");
916 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
920 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
921 # define strcasestr rpl_strcasestr
923 _GL_FUNCDECL_RPL (strcasestr, char *,
924 (const char *haystack, const char *needle)
926 _GL_ARG_NONNULL ((1, 2)));
927 _GL_CXXALIAS_RPL (strcasestr, char *,
928 (const char *haystack, const char *needle));
931 _GL_FUNCDECL_SYS (strcasestr, char *,
932 (const char *haystack, const char *needle)
934 _GL_ARG_NONNULL ((1, 2)));
936 /* On some systems, this function is defined as an overloaded function:
937 extern "C++" { const char * strcasestr (const char *, const char *); }
938 extern "C++" { char * strcasestr (char *, const char *); } */
939 _GL_CXXALIAS_SYS_CAST2 (strcasestr,
940 char *, (const char *haystack, const char *needle),
941 const char *, (const char *haystack, const char *needle));
943 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
944 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
945 _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
946 _GL_CXXALIASWARN1 (strcasestr, const char *,
947 (const char *haystack, const char *needle));
949 _GL_CXXALIASWARN (strcasestr);
951 #elif defined GNULIB_POSIXCHECK
952 /* strcasestr() does not work with multibyte strings:
953 It is a glibc extension, and glibc implements it only for unibyte
956 # if HAVE_RAW_DECL_STRCASESTR
957 _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
958 "strings in multibyte locales - "
959 "use mbscasestr if you care about "
960 "internationalization, or use c-strcasestr if you want "
961 "a locale independent function");
965 /* Parse S into tokens separated by characters in DELIM.
966 If S is NULL, the saved pointer in SAVE_PTR is used as
967 the next starting point. For example:
968 char s[] = "-abc-=-def";
970 x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
971 x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
972 x = strtok_r(NULL, "=", &sp); // x = NULL
975 This is a variant of strtok() that is multithread-safe.
977 For the POSIX documentation for this function, see:
978 http://www.opengroup.org/susv3xsh/strtok.html
980 Caveat: It modifies the original string.
981 Caveat: These functions cannot be used on constant strings.
982 Caveat: The identity of the delimiting character is lost.
983 Caveat: It doesn't work with multibyte strings unless all of the delimiter
984 characters are ASCII characters < 0x30.
986 See also strsep(). */
989 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
991 # define strtok_r rpl_strtok_r
993 _GL_FUNCDECL_RPL (strtok_r, char *,
994 (char *restrict s, char const *restrict delim,
995 char **restrict save_ptr)
996 _GL_ARG_NONNULL ((2, 3)));
997 _GL_CXXALIAS_RPL (strtok_r, char *,
998 (char *restrict s, char const *restrict delim,
999 char **restrict save_ptr));
1001 # if 0 || defined GNULIB_POSIXCHECK
1005 _GL_FUNCDECL_SYS (strtok_r, char *,
1006 (char *restrict s, char const *restrict delim,
1007 char **restrict save_ptr)
1008 _GL_ARG_NONNULL ((2, 3)));
1010 _GL_CXXALIAS_SYS (strtok_r, char *,
1011 (char *restrict s, char const *restrict delim,
1012 char **restrict save_ptr));
1014 _GL_CXXALIASWARN (strtok_r);
1015 # if defined GNULIB_POSIXCHECK
1016 _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
1017 "strings in multibyte locales - "
1018 "use mbstok_r if you care about internationalization");
1020 #elif defined GNULIB_POSIXCHECK
1022 # if HAVE_RAW_DECL_STRTOK_R
1023 _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
1024 "use gnulib module strtok_r for portability");
1029 /* The following functions are not specified by POSIX. They are gnulib
1033 /* Return the number of multibyte characters in the character string STRING.
1034 This considers multibyte characters, unlike strlen, which counts bytes. */
1035 # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
1038 # if 0 /* AIX, OSF/1, MirBSD define mbslen already in libc. */
1039 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1040 # define mbslen rpl_mbslen
1042 _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
1043 _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
1045 _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
1046 _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
1048 _GL_CXXALIASWARN (mbslen);
1052 /* Return the number of multibyte characters in the character string starting
1053 at STRING and ending at STRING + LEN. */
1054 _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
1055 _GL_ARG_NONNULL ((1));
1059 /* Locate the first single-byte character C in the character string STRING,
1060 and return a pointer to it. Return NULL if C is not found in STRING.
1061 Unlike strchr(), this function works correctly in multibyte locales with
1062 encodings such as GB18030. */
1064 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1065 # define mbschr rpl_mbschr /* avoid collision with HP-UX function */
1067 _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
1068 _GL_ARG_NONNULL ((1)));
1069 _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
1071 _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
1072 _GL_ARG_NONNULL ((1)));
1073 _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
1075 _GL_CXXALIASWARN (mbschr);
1079 /* Locate the last single-byte character C in the character string STRING,
1080 and return a pointer to it. Return NULL if C is not found in STRING.
1081 Unlike strrchr(), this function works correctly in multibyte locales with
1082 encodings such as GB18030. */
1083 # if defined __hpux || defined __INTERIX
1084 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1085 # define mbsrchr rpl_mbsrchr /* avoid collision with system function */
1087 _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
1088 _GL_ARG_NONNULL ((1)));
1089 _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
1091 _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
1092 _GL_ARG_NONNULL ((1)));
1093 _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
1095 _GL_CXXALIASWARN (mbsrchr);
1099 /* Find the first occurrence of the character string NEEDLE in the character
1100 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
1101 Unlike strstr(), this function works correctly in multibyte locales with
1102 encodings different from UTF-8. */
1103 _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
1104 _GL_ARG_NONNULL ((1, 2));
1108 /* Compare the character strings S1 and S2, ignoring case, returning less than,
1109 equal to or greater than zero if S1 is lexicographically less than, equal to
1111 Note: This function may, in multibyte locales, return 0 for strings of
1113 Unlike strcasecmp(), this function works correctly in multibyte locales. */
1114 _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
1115 _GL_ARG_NONNULL ((1, 2));
1119 /* Compare the initial segment of the character string S1 consisting of at most
1120 N characters with the initial segment of the character string S2 consisting
1121 of at most N characters, ignoring case, returning less than, equal to or
1122 greater than zero if the initial segment of S1 is lexicographically less
1123 than, equal to or greater than the initial segment of S2.
1124 Note: This function may, in multibyte locales, return 0 for initial segments
1125 of different lengths!
1126 Unlike strncasecmp(), this function works correctly in multibyte locales.
1127 But beware that N is not a byte count but a character count! */
1128 _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
1129 _GL_ARG_NONNULL ((1, 2));
1133 /* Compare the initial segment of the character string STRING consisting of
1134 at most mbslen (PREFIX) characters with the character string PREFIX,
1135 ignoring case. If the two match, return a pointer to the first byte
1136 after this prefix in STRING. Otherwise, return NULL.
1137 Note: This function may, in multibyte locales, return non-NULL if STRING
1138 is of smaller length than PREFIX!
1139 Unlike strncasecmp(), this function works correctly in multibyte
1141 _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1142 _GL_ARG_NONNULL ((1, 2));
1146 /* Find the first occurrence of the character string NEEDLE in the character
1147 string HAYSTACK, using case-insensitive comparison.
1148 Note: This function may, in multibyte locales, return success even if
1149 strlen (haystack) < strlen (needle) !
1150 Unlike strcasestr(), this function works correctly in multibyte locales. */
1151 _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
1152 _GL_ARG_NONNULL ((1, 2));
1156 /* Find the first occurrence in the character string STRING of any character
1157 in the character string ACCEPT. Return the number of bytes from the
1158 beginning of the string to this occurrence, or to the end of the string
1160 Unlike strcspn(), this function works correctly in multibyte locales. */
1161 _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
1162 _GL_ARG_NONNULL ((1, 2));
1166 /* Find the first occurrence in the character string STRING of any character
1167 in the character string ACCEPT. Return the pointer to it, or NULL if none
1169 Unlike strpbrk(), this function works correctly in multibyte locales. */
1171 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1172 # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
1174 _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
1175 _GL_ARG_NONNULL ((1, 2)));
1176 _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
1178 _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
1179 _GL_ARG_NONNULL ((1, 2)));
1180 _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
1182 _GL_CXXALIASWARN (mbspbrk);
1186 /* Find the first occurrence in the character string STRING of any character
1187 not in the character string REJECT. Return the number of bytes from the
1188 beginning of the string to this occurrence, or to the end of the string
1190 Unlike strspn(), this function works correctly in multibyte locales. */
1191 _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
1192 _GL_ARG_NONNULL ((1, 2));
1196 /* Search the next delimiter (multibyte character listed in the character
1197 string DELIM) starting at the character string *STRINGP.
1198 If one is found, overwrite it with a NUL, and advance *STRINGP to point
1199 to the next multibyte character after it. Otherwise, set *STRINGP to NULL.
1200 If *STRINGP was already NULL, nothing happens.
1201 Return the old value of *STRINGP.
1203 This is a variant of mbstok_r() that supports empty fields.
1205 Caveat: It modifies the original string.
1206 Caveat: These functions cannot be used on constant strings.
1207 Caveat: The identity of the delimiting character is lost.
1209 See also mbstok_r(). */
1210 _GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
1211 _GL_ARG_NONNULL ((1, 2));
1215 /* Parse the character string STRING into tokens separated by characters in
1216 the character string DELIM.
1217 If STRING is NULL, the saved pointer in SAVE_PTR is used as
1218 the next starting point. For example:
1219 char s[] = "-abc-=-def";
1221 x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
1222 x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
1223 x = mbstok_r(NULL, "=", &sp); // x = NULL
1224 // s = "abc\0-def\0"
1226 Caveat: It modifies the original string.
1227 Caveat: These functions cannot be used on constant strings.
1228 Caveat: The identity of the delimiting character is lost.
1230 See also mbssep(). */
1231 _GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
1232 _GL_ARG_NONNULL ((2, 3));
1235 /* Map any int, typically from errno, into an error message. */
1238 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1240 # define strerror rpl_strerror
1242 _GL_FUNCDECL_RPL (strerror, char *, (int));
1243 _GL_CXXALIAS_RPL (strerror, char *, (int));
1245 _GL_CXXALIAS_SYS (strerror, char *, (int));
1247 _GL_CXXALIASWARN (strerror);
1248 #elif defined GNULIB_POSIXCHECK
1250 /* Assume strerror is always declared. */
1251 _GL_WARN_ON_USE (strerror, "strerror is unportable - "
1252 "use gnulib module strerror to guarantee non-NULL result");
1255 /* Map any int, typically from errno, into an error message. Multithread-safe.
1256 Uses the POSIX declaration, not the glibc declaration. */
1259 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1261 # define strerror_r rpl_strerror_r
1263 _GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
1264 _GL_ARG_NONNULL ((2)));
1265 _GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
1268 _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
1269 _GL_ARG_NONNULL ((2)));
1271 _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
1274 _GL_CXXALIASWARN (strerror_r);
1276 #elif defined GNULIB_POSIXCHECK
1278 # if HAVE_RAW_DECL_STRERROR_R
1279 _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1280 "use gnulib module strerror_r-posix for portability");
1286 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1287 # define strsignal rpl_strsignal
1289 _GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
1290 _GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
1293 _GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
1295 /* Need to cast, because on Cygwin 1.5.x systems, the return type is
1297 _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
1299 _GL_CXXALIASWARN (strsignal);
1300 #elif defined GNULIB_POSIXCHECK
1302 # if HAVE_RAW_DECL_STRSIGNAL
1303 _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
1304 "use gnulib module strsignal for portability");
1310 _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
1311 _GL_ARG_NONNULL ((1, 2)));
1313 _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
1314 _GL_CXXALIASWARN (strverscmp);
1315 #elif defined GNULIB_POSIXCHECK
1317 # if HAVE_RAW_DECL_STRVERSCMP
1318 _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1319 "use gnulib module strverscmp for portability");
1324 #endif /* _GL_STRING_H */
1325 #endif /* _GL_STRING_H */