~ubuntu-branches/ubuntu/lucid/wget/lucid-security

« back to all changes in this revision

Viewing changes to lib/string.in.h

  • Committer: Bazaar Package Importer
  • Author(s): Marc Deslauriers
  • Date: 2009-12-12 08:15:59 UTC
  • mfrom: (2.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091212081559-mvccl4kzdqb138y3
Tags: 1.12-1.1ubuntu1
* Merge from debian testing, remaining changes:
  - Add wget-udeb to ship wget.gnu as alternative to busybox wget
    implementation.
* Keep build dependencies in main:
  - debian/control: remove info2man build-dep
  - debian/patches/00list: disable wget-infopod_generated_manpage.dpatch

Show diffs side-by-side

added added

removed removed

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