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