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