comparison lib/string.in.h @ 398:7987ee447833 3.0-beta1

Added generated files for release
author lost@l-w.ca
date Fri, 23 Jul 2010 17:18:52 -0600
parents
children
comparison
equal deleted inserted replaced
397:09fe7c40a082 398:7987ee447833
1 /* A GNU-like <string.h>.
2
3 Copyright (C) 1995-1996, 2001-2010 Free Software Foundation, Inc.
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
7 the Free Software Foundation; either version 3, or (at your option)
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
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19 #ifndef _GL_STRING_H
20
21 #if __GNUC__ >= 3
22 @PRAGMA_SYSTEM_HEADER@
23 #endif
24
25 /* The include_next requires a split double-inclusion guard. */
26 #@INCLUDE_NEXT@ @NEXT_STRING_H@
27
28 #ifndef _GL_STRING_H
29 #define _GL_STRING_H
30
31 /* NetBSD 5.0 mis-defines NULL. */
32 #include <stddef.h>
33
34 /* MirBSD defines mbslen as a macro. */
35 #if @GNULIB_MBSLEN@ && defined __MirBSD__
36 # include <wchar.h>
37 #endif
38
39 #ifndef __attribute__
40 /* This feature is available in gcc versions 2.5 and later. */
41 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
42 # define __attribute__(Spec) /* empty */
43 # endif
44 /* The attribute __pure__ was added in gcc 2.96. */
45 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
46 # define __pure__ /* empty */
47 # endif
48 #endif
49
50
51 /* The definition of GL_LINK_WARNING is copied here. */
52
53 /* The definition of _GL_ARG_NONNULL is copied here. */
54
55
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59
60
61 /* Return the first instance of C within N bytes of S, or NULL. */
62 #if @GNULIB_MEMCHR@
63 # if @REPLACE_MEMCHR@
64 # define memchr rpl_memchr
65 extern void *memchr (void const *__s, int __c, size_t __n)
66 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
67 # endif
68 #elif defined GNULIB_POSIXCHECK
69 # undef memchr
70 # define memchr(s,c,n) \
71 (GL_LINK_WARNING ("memchr has platform-specific bugs - " \
72 "use gnulib module memchr for portability" ), \
73 memchr (s, c, n))
74 #endif
75
76 /* Return the first occurrence of NEEDLE in HAYSTACK. */
77 #if @GNULIB_MEMMEM@
78 # if @REPLACE_MEMMEM@
79 # define memmem rpl_memmem
80 # endif
81 # if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
82 extern void *memmem (void const *__haystack, size_t __haystack_len,
83 void const *__needle, size_t __needle_len)
84 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3));
85 # endif
86 #elif defined GNULIB_POSIXCHECK
87 # undef memmem
88 # define memmem(a,al,b,bl) \
89 (GL_LINK_WARNING ("memmem is unportable and often quadratic - " \
90 "use gnulib module memmem-simple for portability, " \
91 "and module memmem for speed" ), \
92 memmem (a, al, b, bl))
93 #endif
94
95 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
96 last written byte. */
97 #if @GNULIB_MEMPCPY@
98 # if ! @HAVE_MEMPCPY@
99 extern void *mempcpy (void *restrict __dest, void const *restrict __src,
100 size_t __n)
101 _GL_ARG_NONNULL ((1, 2));
102 # endif
103 #elif defined GNULIB_POSIXCHECK
104 # undef mempcpy
105 # define mempcpy(a,b,n) \
106 (GL_LINK_WARNING ("mempcpy is unportable - " \
107 "use gnulib module mempcpy for portability"), \
108 mempcpy (a, b, n))
109 #endif
110
111 /* Search backwards through a block for a byte (specified as an int). */
112 #if @GNULIB_MEMRCHR@
113 # if ! @HAVE_DECL_MEMRCHR@
114 extern void *memrchr (void const *, int, size_t)
115 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
116 # endif
117 #elif defined GNULIB_POSIXCHECK
118 # undef memrchr
119 # define memrchr(a,b,c) \
120 (GL_LINK_WARNING ("memrchr is unportable - " \
121 "use gnulib module memrchr for portability"), \
122 memrchr (a, b, c))
123 #endif
124
125 /* Find the first occurrence of C in S. More efficient than
126 memchr(S,C,N), at the expense of undefined behavior if C does not
127 occur within N bytes. */
128 #if @GNULIB_RAWMEMCHR@
129 # if ! @HAVE_RAWMEMCHR@
130 extern void *rawmemchr (void const *__s, int __c_in)
131 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
132 # endif
133 #elif defined GNULIB_POSIXCHECK
134 # undef rawmemchr
135 # define rawmemchr(a,b) \
136 (GL_LINK_WARNING ("rawmemchr is unportable - " \
137 "use gnulib module rawmemchr for portability"), \
138 rawmemchr (a, b))
139 #endif
140
141 /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
142 #if @GNULIB_STPCPY@
143 # if ! @HAVE_STPCPY@
144 extern char *stpcpy (char *restrict __dst, char const *restrict __src)
145 _GL_ARG_NONNULL ((1, 2));
146 # endif
147 #elif defined GNULIB_POSIXCHECK
148 # undef stpcpy
149 # define stpcpy(a,b) \
150 (GL_LINK_WARNING ("stpcpy is unportable - " \
151 "use gnulib module stpcpy for portability"), \
152 stpcpy (a, b))
153 #endif
154
155 /* Copy no more than N bytes of SRC to DST, returning a pointer past the
156 last non-NUL byte written into DST. */
157 #if @GNULIB_STPNCPY@
158 # if ! @HAVE_STPNCPY@
159 # define stpncpy gnu_stpncpy
160 extern char *stpncpy (char *restrict __dst, char const *restrict __src,
161 size_t __n)
162 _GL_ARG_NONNULL ((1, 2));
163 # endif
164 #elif defined GNULIB_POSIXCHECK
165 # undef stpncpy
166 # define stpncpy(a,b,n) \
167 (GL_LINK_WARNING ("stpncpy is unportable - " \
168 "use gnulib module stpncpy for portability"), \
169 stpncpy (a, b, n))
170 #endif
171
172 #if defined GNULIB_POSIXCHECK
173 /* strchr() does not work with multibyte strings if the locale encoding is
174 GB18030 and the character to be searched is a digit. */
175 # undef strchr
176 # define strchr(s,c) \
177 (GL_LINK_WARNING ("strchr cannot work correctly on character strings " \
178 "in some multibyte locales - " \
179 "use mbschr if you care about internationalization"), \
180 strchr (s, c))
181 #endif
182
183 /* Find the first occurrence of C in S or the final NUL byte. */
184 #if @GNULIB_STRCHRNUL@
185 # if ! @HAVE_STRCHRNUL@
186 extern char *strchrnul (char const *__s, int __c_in)
187 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
188 # endif
189 #elif defined GNULIB_POSIXCHECK
190 # undef strchrnul
191 # define strchrnul(a,b) \
192 (GL_LINK_WARNING ("strchrnul is unportable - " \
193 "use gnulib module strchrnul for portability"), \
194 strchrnul (a, b))
195 #endif
196
197 /* Duplicate S, returning an identical malloc'd string. */
198 #if @GNULIB_STRDUP@
199 # if @REPLACE_STRDUP@
200 # undef strdup
201 # define strdup rpl_strdup
202 # endif
203 # if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
204 extern char *strdup (char const *__s) _GL_ARG_NONNULL ((1));
205 # endif
206 #elif defined GNULIB_POSIXCHECK
207 # undef strdup
208 # define strdup(a) \
209 (GL_LINK_WARNING ("strdup is unportable - " \
210 "use gnulib module strdup for portability"), \
211 strdup (a))
212 #endif
213
214 /* Return a newly allocated copy of at most N bytes of STRING. */
215 #if @GNULIB_STRNDUP@
216 # if @REPLACE_STRNDUP@
217 # undef strndup
218 # define strndup rpl_strndup
219 # endif
220 # if @REPLACE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
221 extern char *strndup (char const *__string, size_t __n) _GL_ARG_NONNULL ((1));
222 # endif
223 #elif defined GNULIB_POSIXCHECK
224 # undef strndup
225 # define strndup(a,n) \
226 (GL_LINK_WARNING ("strndup is unportable - " \
227 "use gnulib module strndup for portability"), \
228 strndup (a, n))
229 #endif
230
231 /* Find the length (number of bytes) of STRING, but scan at most
232 MAXLEN bytes. If no '\0' terminator is found in that many bytes,
233 return MAXLEN. */
234 #if @GNULIB_STRNLEN@
235 # if ! @HAVE_DECL_STRNLEN@
236 extern size_t strnlen (char const *__string, size_t __maxlen)
237 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
238 # endif
239 #elif defined GNULIB_POSIXCHECK
240 # undef strnlen
241 # define strnlen(a,n) \
242 (GL_LINK_WARNING ("strnlen is unportable - " \
243 "use gnulib module strnlen for portability"), \
244 strnlen (a, n))
245 #endif
246
247 #if defined GNULIB_POSIXCHECK
248 /* strcspn() assumes the second argument is a list of single-byte characters.
249 Even in this simple case, it does not work with multibyte strings if the
250 locale encoding is GB18030 and one of the characters to be searched is a
251 digit. */
252 # undef strcspn
253 # define strcspn(s,a) \
254 (GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \
255 "in multibyte locales - " \
256 "use mbscspn if you care about internationalization"), \
257 strcspn (s, a))
258 #endif
259
260 /* Find the first occurrence in S of any character in ACCEPT. */
261 #if @GNULIB_STRPBRK@
262 # if ! @HAVE_STRPBRK@
263 extern char *strpbrk (char const *__s, char const *__accept)
264 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
265 # endif
266 # if defined GNULIB_POSIXCHECK
267 /* strpbrk() assumes the second argument is a list of single-byte characters.
268 Even in this simple case, it does not work with multibyte strings if the
269 locale encoding is GB18030 and one of the characters to be searched is a
270 digit. */
271 # undef strpbrk
272 # define strpbrk(s,a) \
273 (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \
274 "in multibyte locales - " \
275 "use mbspbrk if you care about internationalization"), \
276 strpbrk (s, a))
277 # endif
278 #elif defined GNULIB_POSIXCHECK
279 # undef strpbrk
280 # define strpbrk(s,a) \
281 (GL_LINK_WARNING ("strpbrk is unportable - " \
282 "use gnulib module strpbrk for portability"), \
283 strpbrk (s, a))
284 #endif
285
286 #if defined GNULIB_POSIXCHECK
287 /* strspn() assumes the second argument is a list of single-byte characters.
288 Even in this simple case, it cannot work with multibyte strings. */
289 # undef strspn
290 # define strspn(s,a) \
291 (GL_LINK_WARNING ("strspn cannot work correctly on character strings " \
292 "in multibyte locales - " \
293 "use mbsspn if you care about internationalization"), \
294 strspn (s, a))
295 #endif
296
297 #if defined GNULIB_POSIXCHECK
298 /* strrchr() does not work with multibyte strings if the locale encoding is
299 GB18030 and the character to be searched is a digit. */
300 # undef strrchr
301 # define strrchr(s,c) \
302 (GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \
303 "in some multibyte locales - " \
304 "use mbsrchr if you care about internationalization"), \
305 strrchr (s, c))
306 #endif
307
308 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
309 If one is found, overwrite it with a NUL, and advance *STRINGP
310 to point to the next char after it. Otherwise, set *STRINGP to NULL.
311 If *STRINGP was already NULL, nothing happens.
312 Return the old value of *STRINGP.
313
314 This is a variant of strtok() that is multithread-safe and supports
315 empty fields.
316
317 Caveat: It modifies the original string.
318 Caveat: These functions cannot be used on constant strings.
319 Caveat: The identity of the delimiting character is lost.
320 Caveat: It doesn't work with multibyte strings unless all of the delimiter
321 characters are ASCII characters < 0x30.
322
323 See also strtok_r(). */
324 #if @GNULIB_STRSEP@
325 # if ! @HAVE_STRSEP@
326 extern char *strsep (char **restrict __stringp, char const *restrict __delim)
327 _GL_ARG_NONNULL ((1, 2));
328 # endif
329 # if defined GNULIB_POSIXCHECK
330 # undef strsep
331 # define strsep(s,d) \
332 (GL_LINK_WARNING ("strsep cannot work correctly on character strings " \
333 "in multibyte locales - " \
334 "use mbssep if you care about internationalization"), \
335 strsep (s, d))
336 # endif
337 #elif defined GNULIB_POSIXCHECK
338 # undef strsep
339 # define strsep(s,d) \
340 (GL_LINK_WARNING ("strsep is unportable - " \
341 "use gnulib module strsep for portability"), \
342 strsep (s, d))
343 #endif
344
345 #if @GNULIB_STRSTR@
346 # if @REPLACE_STRSTR@
347 # define strstr rpl_strstr
348 extern char *strstr (const char *haystack, const char *needle)
349 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
350 # endif
351 #elif defined GNULIB_POSIXCHECK
352 /* strstr() does not work with multibyte strings if the locale encoding is
353 different from UTF-8:
354 POSIX says that it operates on "strings", and "string" in POSIX is defined
355 as a sequence of bytes, not of characters. */
356 # undef strstr
357 # define strstr(a,b) \
358 (GL_LINK_WARNING ("strstr is quadratic on many systems, and cannot " \
359 "work correctly on character strings in most " \
360 "multibyte locales - " \
361 "use mbsstr if you care about internationalization, " \
362 "or use strstr if you care about speed"), \
363 strstr (a, b))
364 #endif
365
366 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
367 comparison. */
368 #if @GNULIB_STRCASESTR@
369 # if @REPLACE_STRCASESTR@
370 # define strcasestr rpl_strcasestr
371 # endif
372 # if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
373 extern char *strcasestr (const char *haystack, const char *needle)
374 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
375 # endif
376 #elif defined GNULIB_POSIXCHECK
377 /* strcasestr() does not work with multibyte strings:
378 It is a glibc extension, and glibc implements it only for unibyte
379 locales. */
380 # undef strcasestr
381 # define strcasestr(a,b) \
382 (GL_LINK_WARNING ("strcasestr does work correctly on character strings " \
383 "in multibyte locales - " \
384 "use mbscasestr if you care about " \
385 "internationalization, or use c-strcasestr if you want " \
386 "a locale independent function"), \
387 strcasestr (a, b))
388 #endif
389
390 /* Parse S into tokens separated by characters in DELIM.
391 If S is NULL, the saved pointer in SAVE_PTR is used as
392 the next starting point. For example:
393 char s[] = "-abc-=-def";
394 char *sp;
395 x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
396 x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
397 x = strtok_r(NULL, "=", &sp); // x = NULL
398 // s = "abc\0-def\0"
399
400 This is a variant of strtok() that is multithread-safe.
401
402 For the POSIX documentation for this function, see:
403 http://www.opengroup.org/susv3xsh/strtok.html
404
405 Caveat: It modifies the original string.
406 Caveat: These functions cannot be used on constant strings.
407 Caveat: The identity of the delimiting character is lost.
408 Caveat: It doesn't work with multibyte strings unless all of the delimiter
409 characters are ASCII characters < 0x30.
410
411 See also strsep(). */
412 #if @GNULIB_STRTOK_R@
413 # if @REPLACE_STRTOK_R@
414 # undef strtok_r
415 # define strtok_r rpl_strtok_r
416 # elif @UNDEFINE_STRTOK_R@
417 # undef strtok_r
418 # endif
419 # if ! @HAVE_DECL_STRTOK_R@ || @REPLACE_STRTOK_R@
420 extern char *strtok_r (char *restrict s, char const *restrict delim,
421 char **restrict save_ptr)
422 _GL_ARG_NONNULL ((2, 3));
423 # endif
424 # if defined GNULIB_POSIXCHECK
425 # undef strtok_r
426 # define strtok_r(s,d,p) \
427 (GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \
428 "in multibyte locales - " \
429 "use mbstok_r if you care about internationalization"), \
430 strtok_r (s, d, p))
431 # endif
432 #elif defined GNULIB_POSIXCHECK
433 # undef strtok_r
434 # define strtok_r(s,d,p) \
435 (GL_LINK_WARNING ("strtok_r is unportable - " \
436 "use gnulib module strtok_r for portability"), \
437 strtok_r (s, d, p))
438 #endif
439
440
441 /* The following functions are not specified by POSIX. They are gnulib
442 extensions. */
443
444 #if @GNULIB_MBSLEN@
445 /* Return the number of multibyte characters in the character string STRING.
446 This considers multibyte characters, unlike strlen, which counts bytes. */
447 # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
448 # undef mbslen
449 # endif
450 # if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */
451 # define mbslen rpl_mbslen
452 # endif
453 extern size_t mbslen (const char *string) _GL_ARG_NONNULL ((1));
454 #endif
455
456 #if @GNULIB_MBSNLEN@
457 /* Return the number of multibyte characters in the character string starting
458 at STRING and ending at STRING + LEN. */
459 extern size_t mbsnlen (const char *string, size_t len) _GL_ARG_NONNULL ((1));
460 #endif
461
462 #if @GNULIB_MBSCHR@
463 /* Locate the first single-byte character C in the character string STRING,
464 and return a pointer to it. Return NULL if C is not found in STRING.
465 Unlike strchr(), this function works correctly in multibyte locales with
466 encodings such as GB18030. */
467 # define mbschr rpl_mbschr /* avoid collision with HP-UX function */
468 extern char * mbschr (const char *string, int c) _GL_ARG_NONNULL ((1));
469 #endif
470
471 #if @GNULIB_MBSRCHR@
472 /* Locate the last single-byte character C in the character string STRING,
473 and return a pointer to it. Return NULL if C is not found in STRING.
474 Unlike strrchr(), this function works correctly in multibyte locales with
475 encodings such as GB18030. */
476 # define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
477 extern char * mbsrchr (const char *string, int c) _GL_ARG_NONNULL ((1));
478 #endif
479
480 #if @GNULIB_MBSSTR@
481 /* Find the first occurrence of the character string NEEDLE in the character
482 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
483 Unlike strstr(), this function works correctly in multibyte locales with
484 encodings different from UTF-8. */
485 extern char * mbsstr (const char *haystack, const char *needle)
486 _GL_ARG_NONNULL ((1, 2));
487 #endif
488
489 #if @GNULIB_MBSCASECMP@
490 /* Compare the character strings S1 and S2, ignoring case, returning less than,
491 equal to or greater than zero if S1 is lexicographically less than, equal to
492 or greater than S2.
493 Note: This function may, in multibyte locales, return 0 for strings of
494 different lengths!
495 Unlike strcasecmp(), this function works correctly in multibyte locales. */
496 extern int mbscasecmp (const char *s1, const char *s2)
497 _GL_ARG_NONNULL ((1, 2));
498 #endif
499
500 #if @GNULIB_MBSNCASECMP@
501 /* Compare the initial segment of the character string S1 consisting of at most
502 N characters with the initial segment of the character string S2 consisting
503 of at most N characters, ignoring case, returning less than, equal to or
504 greater than zero if the initial segment of S1 is lexicographically less
505 than, equal to or greater than the initial segment of S2.
506 Note: This function may, in multibyte locales, return 0 for initial segments
507 of different lengths!
508 Unlike strncasecmp(), this function works correctly in multibyte locales.
509 But beware that N is not a byte count but a character count! */
510 extern int mbsncasecmp (const char *s1, const char *s2, size_t n)
511 _GL_ARG_NONNULL ((1, 2));
512 #endif
513
514 #if @GNULIB_MBSPCASECMP@
515 /* Compare the initial segment of the character string STRING consisting of
516 at most mbslen (PREFIX) characters with the character string PREFIX,
517 ignoring case, returning less than, equal to or greater than zero if this
518 initial segment is lexicographically less than, equal to or greater than
519 PREFIX.
520 Note: This function may, in multibyte locales, return 0 if STRING is of
521 smaller length than PREFIX!
522 Unlike strncasecmp(), this function works correctly in multibyte
523 locales. */
524 extern char * mbspcasecmp (const char *string, const char *prefix)
525 _GL_ARG_NONNULL ((1, 2));
526 #endif
527
528 #if @GNULIB_MBSCASESTR@
529 /* Find the first occurrence of the character string NEEDLE in the character
530 string HAYSTACK, using case-insensitive comparison.
531 Note: This function may, in multibyte locales, return success even if
532 strlen (haystack) < strlen (needle) !
533 Unlike strcasestr(), this function works correctly in multibyte locales. */
534 extern char * mbscasestr (const char *haystack, const char *needle)
535 _GL_ARG_NONNULL ((1, 2));
536 #endif
537
538 #if @GNULIB_MBSCSPN@
539 /* Find the first occurrence in the character string STRING of any character
540 in the character string ACCEPT. Return the number of bytes from the
541 beginning of the string to this occurrence, or to the end of the string
542 if none exists.
543 Unlike strcspn(), this function works correctly in multibyte locales. */
544 extern size_t mbscspn (const char *string, const char *accept)
545 _GL_ARG_NONNULL ((1, 2));
546 #endif
547
548 #if @GNULIB_MBSPBRK@
549 /* Find the first occurrence in the character string STRING of any character
550 in the character string ACCEPT. Return the pointer to it, or NULL if none
551 exists.
552 Unlike strpbrk(), this function works correctly in multibyte locales. */
553 # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
554 extern char * mbspbrk (const char *string, const char *accept)
555 _GL_ARG_NONNULL ((1, 2));
556 #endif
557
558 #if @GNULIB_MBSSPN@
559 /* Find the first occurrence in the character string STRING of any character
560 not in the character string REJECT. Return the number of bytes from the
561 beginning of the string to this occurrence, or to the end of the string
562 if none exists.
563 Unlike strspn(), this function works correctly in multibyte locales. */
564 extern size_t mbsspn (const char *string, const char *reject)
565 _GL_ARG_NONNULL ((1, 2));
566 #endif
567
568 #if @GNULIB_MBSSEP@
569 /* Search the next delimiter (multibyte character listed in the character
570 string DELIM) starting at the character string *STRINGP.
571 If one is found, overwrite it with a NUL, and advance *STRINGP to point
572 to the next multibyte character after it. Otherwise, set *STRINGP to NULL.
573 If *STRINGP was already NULL, nothing happens.
574 Return the old value of *STRINGP.
575
576 This is a variant of mbstok_r() that supports empty fields.
577
578 Caveat: It modifies the original string.
579 Caveat: These functions cannot be used on constant strings.
580 Caveat: The identity of the delimiting character is lost.
581
582 See also mbstok_r(). */
583 extern char * mbssep (char **stringp, const char *delim)
584 _GL_ARG_NONNULL ((1, 2));
585 #endif
586
587 #if @GNULIB_MBSTOK_R@
588 /* Parse the character string STRING into tokens separated by characters in
589 the character string DELIM.
590 If STRING is NULL, the saved pointer in SAVE_PTR is used as
591 the next starting point. For example:
592 char s[] = "-abc-=-def";
593 char *sp;
594 x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
595 x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
596 x = mbstok_r(NULL, "=", &sp); // x = NULL
597 // s = "abc\0-def\0"
598
599 Caveat: It modifies the original string.
600 Caveat: These functions cannot be used on constant strings.
601 Caveat: The identity of the delimiting character is lost.
602
603 See also mbssep(). */
604 extern char * mbstok_r (char *string, const char *delim, char **save_ptr)
605 _GL_ARG_NONNULL ((2, 3));
606 #endif
607
608 /* Map any int, typically from errno, into an error message. */
609 #if @GNULIB_STRERROR@
610 # if @REPLACE_STRERROR@
611 # undef strerror
612 # define strerror rpl_strerror
613 extern char *strerror (int);
614 # endif
615 #elif defined GNULIB_POSIXCHECK
616 # undef strerror
617 # define strerror(e) \
618 (GL_LINK_WARNING ("strerror is unportable - " \
619 "use gnulib module strerror to guarantee non-NULL result"), \
620 strerror (e))
621 #endif
622
623 #if @GNULIB_STRSIGNAL@
624 # if @REPLACE_STRSIGNAL@
625 # define strsignal rpl_strsignal
626 # endif
627 # if ! @HAVE_DECL_STRSIGNAL@ || @REPLACE_STRSIGNAL@
628 extern char *strsignal (int __sig);
629 # endif
630 #elif defined GNULIB_POSIXCHECK
631 # undef strsignal
632 # define strsignal(a) \
633 (GL_LINK_WARNING ("strsignal is unportable - " \
634 "use gnulib module strsignal for portability"), \
635 strsignal (a))
636 #endif
637
638 #if @GNULIB_STRVERSCMP@
639 # if !@HAVE_STRVERSCMP@
640 extern int strverscmp (const char *, const char *) _GL_ARG_NONNULL ((1, 2));
641 # endif
642 #elif defined GNULIB_POSIXCHECK
643 # undef strverscmp
644 # define strverscmp(a, b) \
645 (GL_LINK_WARNING ("strverscmp is unportable - " \
646 "use gnulib module strverscmp for portability"), \
647 strverscmp (a, b))
648 #endif
649
650
651 #ifdef __cplusplus
652 }
653 #endif
654
655 #endif /* _GL_STRING_H */
656 #endif /* _GL_STRING_H */