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