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