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