19
19
#ifndef _GL_STRING_H
22
@PRAGMA_SYSTEM_HEADER@
21
25
/* The include_next requires a split double-inclusion guard. */
22
26
#@INCLUDE_NEXT@ @NEXT_STRING_H@
24
28
#ifndef _GL_STRING_H
25
29
#define _GL_STRING_H
28
/* The definition of GL_LINK_WARNING is copied here. */
31
/* NetBSD 5.0 mis-defines NULL. */
34
/* MirBSD defines mbslen as a macro. */
35
#if @GNULIB_MBSLEN@ && defined __MirBSD__
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 */
44
/* The attribute __pure__ was added in gcc 2.96. */
45
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
46
# define __pure__ /* empty */
51
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
53
/* The definition of _GL_ARG_NONNULL is copied here. */
55
/* The definition of _GL_WARN_ON_USE is copied here. */
58
/* Return the first instance of C within N bytes of S, or NULL. */
61
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
62
# define memchr rpl_memchr
64
_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
65
__attribute__ ((__pure__))
66
_GL_ARG_NONNULL ((1)));
67
_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
70
_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
71
__attribute__ ((__pure__))
72
_GL_ARG_NONNULL ((1)));
74
/* On some systems, this function is defined as an overloaded function:
75
extern "C" { const void * std::memchr (const void *, int, size_t); }
76
extern "C++" { void * std::memchr (void *, int, size_t); } */
77
_GL_CXXALIAS_SYS_CAST2 (memchr,
78
void *, (void const *__s, int __c, size_t __n),
79
void const *, (void const *__s, int __c, size_t __n));
81
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
82
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
83
_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
84
_GL_CXXALIASWARN1 (memchr, void const *,
85
(void const *__s, int __c, size_t __n));
87
_GL_CXXALIASWARN (memchr);
89
#elif defined GNULIB_POSIXCHECK
91
/* Assume memchr is always declared. */
92
_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
93
"use gnulib module memchr for portability" );
35
96
/* Return the first occurrence of NEEDLE in HAYSTACK. */
36
97
#if @GNULIB_MEMMEM@
37
# if ! @HAVE_DECL_MEMMEM@
38
extern void *memmem (void const *__haystack, size_t __haystack_len,
39
void const *__needle, size_t __needle_len);
99
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
100
# define memmem rpl_memmem
102
_GL_FUNCDECL_RPL (memmem, void *,
103
(void const *__haystack, size_t __haystack_len,
104
void const *__needle, size_t __needle_len)
105
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3)));
106
_GL_CXXALIAS_RPL (memmem, void *,
107
(void const *__haystack, size_t __haystack_len,
108
void const *__needle, size_t __needle_len));
110
# if ! @HAVE_DECL_MEMMEM@
111
_GL_FUNCDECL_SYS (memmem, void *,
112
(void const *__haystack, size_t __haystack_len,
113
void const *__needle, size_t __needle_len)
114
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3)));
116
_GL_CXXALIAS_SYS (memmem, void *,
117
(void const *__haystack, size_t __haystack_len,
118
void const *__needle, size_t __needle_len));
120
_GL_CXXALIASWARN (memmem);
41
121
#elif defined GNULIB_POSIXCHECK
43
# define memmem(a,al,b,bl) \
44
(GL_LINK_WARNING ("memmem is unportable - " \
45
"use gnulib module memmem for portability"), \
46
memmem (a, al, b, bl))
123
# if HAVE_RAW_DECL_MEMMEM
124
_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
125
"use gnulib module memmem-simple for portability, "
126
"and module memmem for speed" );
49
130
/* Copy N bytes of SRC to DEST, return pointer to bytes after the
50
131
last written byte. */
51
132
#if @GNULIB_MEMPCPY@
52
133
# if ! @HAVE_MEMPCPY@
53
extern void *mempcpy (void *restrict __dest, void const *restrict __src,
134
_GL_FUNCDECL_SYS (mempcpy, void *,
135
(void *restrict __dest, void const *restrict __src,
137
_GL_ARG_NONNULL ((1, 2)));
139
_GL_CXXALIAS_SYS (mempcpy, void *,
140
(void *restrict __dest, void const *restrict __src,
142
_GL_CXXALIASWARN (mempcpy);
56
143
#elif defined GNULIB_POSIXCHECK
58
# define mempcpy(a,b,n) \
59
(GL_LINK_WARNING ("mempcpy is unportable - " \
60
"use gnulib module mempcpy for portability"), \
145
# if HAVE_RAW_DECL_MEMPCPY
146
_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
147
"use gnulib module mempcpy for portability");
64
151
/* Search backwards through a block for a byte (specified as an int). */
65
152
#if @GNULIB_MEMRCHR@
66
153
# if ! @HAVE_DECL_MEMRCHR@
67
extern void *memrchr (void const *, int, size_t);
154
_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
155
__attribute__ ((__pure__))
156
_GL_ARG_NONNULL ((1)));
158
/* On some systems, this function is defined as an overloaded function:
159
extern "C++" { const void * std::memrchr (const void *, int, size_t); }
160
extern "C++" { void * std::memrchr (void *, int, size_t); } */
161
_GL_CXXALIAS_SYS_CAST2 (memrchr,
162
void *, (void const *, int, size_t),
163
void const *, (void const *, int, size_t));
164
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
165
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
166
_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
167
_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
169
_GL_CXXALIASWARN (memrchr);
69
171
#elif defined GNULIB_POSIXCHECK
71
# define memrchr(a,b,c) \
72
(GL_LINK_WARNING ("memrchr is unportable - " \
73
"use gnulib module memrchr for portability"), \
173
# if HAVE_RAW_DECL_MEMRCHR
174
_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
175
"use gnulib module memrchr for portability");
179
/* Find the first occurrence of C in S. More efficient than
180
memchr(S,C,N), at the expense of undefined behavior if C does not
181
occur within N bytes. */
182
#if @GNULIB_RAWMEMCHR@
183
# if ! @HAVE_RAWMEMCHR@
184
_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
185
__attribute__ ((__pure__))
186
_GL_ARG_NONNULL ((1)));
188
/* On some systems, this function is defined as an overloaded function:
189
extern "C++" { const void * std::rawmemchr (const void *, int); }
190
extern "C++" { void * std::rawmemchr (void *, int); } */
191
_GL_CXXALIAS_SYS_CAST2 (rawmemchr,
192
void *, (void const *__s, int __c_in),
193
void const *, (void const *__s, int __c_in));
194
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
195
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
196
_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
197
_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
199
_GL_CXXALIASWARN (rawmemchr);
201
#elif defined GNULIB_POSIXCHECK
203
# if HAVE_RAW_DECL_RAWMEMCHR
204
_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
205
"use gnulib module rawmemchr for portability");
77
209
/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
78
210
#if @GNULIB_STPCPY@
79
211
# if ! @HAVE_STPCPY@
80
extern char *stpcpy (char *restrict __dst, char const *restrict __src);
212
_GL_FUNCDECL_SYS (stpcpy, char *,
213
(char *restrict __dst, char const *restrict __src)
214
_GL_ARG_NONNULL ((1, 2)));
216
_GL_CXXALIAS_SYS (stpcpy, char *,
217
(char *restrict __dst, char const *restrict __src));
218
_GL_CXXALIASWARN (stpcpy);
82
219
#elif defined GNULIB_POSIXCHECK
84
# define stpcpy(a,b) \
85
(GL_LINK_WARNING ("stpcpy is unportable - " \
86
"use gnulib module stpcpy for portability"), \
221
# if HAVE_RAW_DECL_STPCPY
222
_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
223
"use gnulib module stpcpy for portability");
90
227
/* Copy no more than N bytes of SRC to DST, returning a pointer past the
91
228
last non-NUL byte written into DST. */
92
229
#if @GNULIB_STPNCPY@
94
# define stpncpy gnu_stpncpy
95
extern char *stpncpy (char *restrict __dst, char const *restrict __src,
230
# if @REPLACE_STPNCPY@
231
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
232
# define stpncpy rpl_stpncpy
234
_GL_FUNCDECL_RPL (stpncpy, char *,
235
(char *restrict __dst, char const *restrict __src,
237
_GL_ARG_NONNULL ((1, 2)));
238
_GL_CXXALIAS_RPL (stpncpy, char *,
239
(char *restrict __dst, char const *restrict __src,
242
# if ! @HAVE_STPNCPY@
243
_GL_FUNCDECL_SYS (stpncpy, char *,
244
(char *restrict __dst, char const *restrict __src,
246
_GL_ARG_NONNULL ((1, 2)));
248
_GL_CXXALIAS_SYS (stpncpy, char *,
249
(char *restrict __dst, char const *restrict __src,
252
_GL_CXXALIASWARN (stpncpy);
98
253
#elif defined GNULIB_POSIXCHECK
100
# define stpncpy(a,b,n) \
101
(GL_LINK_WARNING ("stpncpy is unportable - " \
102
"use gnulib module stpncpy for portability"), \
106
/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
107
greater than zero if S1 is lexicographically less than, equal to or greater
109
Note: This function does not work in multibyte locales. */
110
#if ! @HAVE_STRCASECMP@
111
extern int strcasecmp (char const *s1, char const *s2);
113
#if defined GNULIB_POSIXCHECK
114
/* strcasecmp() does not work with multibyte strings:
115
POSIX says that it operates on "strings", and "string" in POSIX is defined
116
as a sequence of bytes, not of characters. */
118
# define strcasecmp(a,b) \
119
(GL_LINK_WARNING ("strcasecmp cannot work correctly on character strings " \
120
"in multibyte locales - " \
121
"use mbscasecmp if you care about " \
122
"internationalization, or use c_strcasecmp (from " \
123
"gnulib module c-strcase) if you want a locale " \
124
"independent function"), \
128
/* Compare no more than N bytes of strings S1 and S2, ignoring case,
129
returning less than, equal to or greater than zero if S1 is
130
lexicographically less than, equal to or greater than S2.
131
Note: This function cannot work correctly in multibyte locales. */
132
#if ! @HAVE_DECL_STRNCASECMP@
133
extern int strncasecmp (char const *s1, char const *s2, size_t n);
135
#if defined GNULIB_POSIXCHECK
136
/* strncasecmp() does not work with multibyte strings:
137
POSIX says that it operates on "strings", and "string" in POSIX is defined
138
as a sequence of bytes, not of characters. */
140
# define strncasecmp(a,b,n) \
141
(GL_LINK_WARNING ("strncasecmp cannot work correctly on character " \
142
"strings in multibyte locales - " \
143
"use mbsncasecmp or mbspcasecmp if you care about " \
144
"internationalization, or use c_strncasecmp (from " \
145
"gnulib module c-strcase) if you want a locale " \
146
"independent function"), \
147
strncasecmp (a, b, n))
255
# if HAVE_RAW_DECL_STPNCPY
256
_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
257
"use gnulib module stpncpy for portability");
150
261
#if defined GNULIB_POSIXCHECK
151
262
/* strchr() does not work with multibyte strings if the locale encoding is
152
263
GB18030 and the character to be searched is a digit. */
154
# define strchr(s,c) \
155
(GL_LINK_WARNING ("strchr cannot work correctly on character strings " \
156
"in some multibyte locales - " \
157
"use mbschr if you care about internationalization"), \
265
/* Assume strchr is always declared. */
266
_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
267
"in some multibyte locales - "
268
"use mbschr if you care about internationalization");
161
271
/* Find the first occurrence of C in S or the final NUL byte. */
162
272
#if @GNULIB_STRCHRNUL@
163
273
# if ! @HAVE_STRCHRNUL@
164
extern char *strchrnul (char const *__s, int __c_in);
274
_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
275
__attribute__ ((__pure__))
276
_GL_ARG_NONNULL ((1)));
278
/* On some systems, this function is defined as an overloaded function:
279
extern "C++" { const char * std::strchrnul (const char *, int); }
280
extern "C++" { char * std::strchrnul (char *, int); } */
281
_GL_CXXALIAS_SYS_CAST2 (strchrnul,
282
char *, (char const *__s, int __c_in),
283
char const *, (char const *__s, int __c_in));
284
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
285
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
286
_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
287
_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
289
_GL_CXXALIASWARN (strchrnul);
166
291
#elif defined GNULIB_POSIXCHECK
167
292
# undef strchrnul
168
# define strchrnul(a,b) \
169
(GL_LINK_WARNING ("strchrnul is unportable - " \
170
"use gnulib module strchrnul for portability"), \
293
# if HAVE_RAW_DECL_STRCHRNUL
294
_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
295
"use gnulib module strchrnul for portability");
174
299
/* Duplicate S, returning an identical malloc'd string. */
175
300
#if @GNULIB_STRDUP@
176
# if ! @HAVE_DECL_STRDUP@ && ! defined strdup
177
extern char *strdup (char const *__s);
301
# if @REPLACE_STRDUP@
302
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
304
# define strdup rpl_strdup
306
_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
307
_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
309
# if !(@HAVE_DECL_STRDUP@ || defined strdup)
310
_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
312
_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
314
_GL_CXXALIASWARN (strdup);
179
315
#elif defined GNULIB_POSIXCHECK
182
(GL_LINK_WARNING ("strdup is unportable - " \
183
"use gnulib module strdup for portability"), \
317
# if HAVE_RAW_DECL_STRDUP
318
_GL_WARN_ON_USE (strdup, "strdup is unportable - "
319
"use gnulib module strdup for portability");
323
/* Append no more than N characters from SRC onto DEST. */
325
# if @REPLACE_STRNCAT@
326
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
328
# define strncat rpl_strncat
330
_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
331
_GL_ARG_NONNULL ((1, 2)));
332
_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
334
_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
336
_GL_CXXALIASWARN (strncat);
337
#elif defined GNULIB_POSIXCHECK
339
# if HAVE_RAW_DECL_STRNCAT
340
_GL_WARN_ON_USE (strncat, "strncat is unportable - "
341
"use gnulib module strncat for portability");
187
345
/* Return a newly allocated copy of at most N bytes of STRING. */
188
346
#if @GNULIB_STRNDUP@
189
# if ! @HAVE_STRNDUP@
191
# define strndup rpl_strndup
193
# if ! @HAVE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
194
extern char *strndup (char const *__string, size_t __n);
347
# if @REPLACE_STRNDUP@
348
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
350
# define strndup rpl_strndup
352
_GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n)
353
_GL_ARG_NONNULL ((1)));
354
_GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n));
356
# if ! @HAVE_DECL_STRNDUP@
357
_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
358
_GL_ARG_NONNULL ((1)));
360
_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
362
_GL_CXXALIASWARN (strndup);
196
363
#elif defined GNULIB_POSIXCHECK
198
# define strndup(a,n) \
199
(GL_LINK_WARNING ("strndup is unportable - " \
200
"use gnulib module strndup for portability"), \
365
# if HAVE_RAW_DECL_STRNDUP
366
_GL_WARN_ON_USE (strndup, "strndup is unportable - "
367
"use gnulib module strndup for portability");
204
371
/* Find the length (number of bytes) of STRING, but scan at most
205
372
MAXLEN bytes. If no '\0' terminator is found in that many bytes,
206
373
return MAXLEN. */
207
374
#if @GNULIB_STRNLEN@
208
# if ! @HAVE_DECL_STRNLEN@
209
extern size_t strnlen (char const *__string, size_t __maxlen);
375
# if @REPLACE_STRNLEN@
376
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
378
# define strnlen rpl_strnlen
380
_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
381
__attribute__ ((__pure__))
382
_GL_ARG_NONNULL ((1)));
383
_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
385
# if ! @HAVE_DECL_STRNLEN@
386
_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
387
__attribute__ ((__pure__))
388
_GL_ARG_NONNULL ((1)));
390
_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
392
_GL_CXXALIASWARN (strnlen);
211
393
#elif defined GNULIB_POSIXCHECK
213
# define strnlen(a,n) \
214
(GL_LINK_WARNING ("strnlen is unportable - " \
215
"use gnulib module strnlen for portability"), \
395
# if HAVE_RAW_DECL_STRNLEN
396
_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
397
"use gnulib module strnlen for portability");
219
401
#if defined GNULIB_POSIXCHECK
294
487
See also strtok_r(). */
295
488
#if @GNULIB_STRSEP@
296
489
# if ! @HAVE_STRSEP@
297
extern char *strsep (char **restrict __stringp, char const *restrict __delim);
490
_GL_FUNCDECL_SYS (strsep, char *,
491
(char **restrict __stringp, char const *restrict __delim)
492
_GL_ARG_NONNULL ((1, 2)));
494
_GL_CXXALIAS_SYS (strsep, char *,
495
(char **restrict __stringp, char const *restrict __delim));
496
_GL_CXXALIASWARN (strsep);
299
497
# if defined GNULIB_POSIXCHECK
301
# define strsep(s,d) \
302
(GL_LINK_WARNING ("strsep cannot work correctly on character strings " \
303
"in multibyte locales - " \
304
"use mbssep if you care about internationalization"), \
499
_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
500
"in multibyte locales - "
501
"use mbssep if you care about internationalization");
307
503
#elif defined GNULIB_POSIXCHECK
309
# define strsep(s,d) \
310
(GL_LINK_WARNING ("strsep is unportable - " \
311
"use gnulib module strsep for portability"), \
505
# if HAVE_RAW_DECL_STRSEP
506
_GL_WARN_ON_USE (strsep, "strsep is unportable - "
507
"use gnulib module strsep for portability");
315
#if defined GNULIB_POSIXCHECK
512
# if @REPLACE_STRSTR@
513
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
514
# define strstr rpl_strstr
516
_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
517
__attribute__ ((__pure__))
518
_GL_ARG_NONNULL ((1, 2)));
519
_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
521
/* On some systems, this function is defined as an overloaded function:
522
extern "C++" { const char * strstr (const char *, const char *); }
523
extern "C++" { char * strstr (char *, const char *); } */
524
_GL_CXXALIAS_SYS_CAST2 (strstr,
525
char *, (const char *haystack, const char *needle),
526
const char *, (const char *haystack, const char *needle));
528
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
529
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
530
_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
531
_GL_CXXALIASWARN1 (strstr, const char *,
532
(const char *haystack, const char *needle));
534
_GL_CXXALIASWARN (strstr);
536
#elif defined GNULIB_POSIXCHECK
316
537
/* strstr() does not work with multibyte strings if the locale encoding is
317
538
different from UTF-8:
318
539
POSIX says that it operates on "strings", and "string" in POSIX is defined
319
540
as a sequence of bytes, not of characters. */
321
# define strstr(a,b) \
322
(GL_LINK_WARNING ("strstr cannot work correctly on character strings " \
323
"in most multibyte locales - " \
324
"use mbsstr if you care about internationalization"), \
542
/* Assume strstr is always declared. */
543
_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
544
"work correctly on character strings in most "
545
"multibyte locales - "
546
"use mbsstr if you care about internationalization, "
547
"or use strstr if you care about speed");
328
550
/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
330
#if ! @HAVE_STRCASESTR@
331
extern char *strcasestr (const char *haystack, const char *needle);
333
#if defined GNULIB_POSIXCHECK
552
#if @GNULIB_STRCASESTR@
553
# if @REPLACE_STRCASESTR@
554
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
555
# define strcasestr rpl_strcasestr
557
_GL_FUNCDECL_RPL (strcasestr, char *,
558
(const char *haystack, const char *needle)
559
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)));
560
_GL_CXXALIAS_RPL (strcasestr, char *,
561
(const char *haystack, const char *needle));
563
# if ! @HAVE_STRCASESTR@
564
_GL_FUNCDECL_SYS (strcasestr, char *,
565
(const char *haystack, const char *needle)
566
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)));
568
/* On some systems, this function is defined as an overloaded function:
569
extern "C++" { const char * strcasestr (const char *, const char *); }
570
extern "C++" { char * strcasestr (char *, const char *); } */
571
_GL_CXXALIAS_SYS_CAST2 (strcasestr,
572
char *, (const char *haystack, const char *needle),
573
const char *, (const char *haystack, const char *needle));
575
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
576
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
577
_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
578
_GL_CXXALIASWARN1 (strcasestr, const char *,
579
(const char *haystack, const char *needle));
581
_GL_CXXALIASWARN (strcasestr);
583
#elif defined GNULIB_POSIXCHECK
334
584
/* strcasestr() does not work with multibyte strings:
335
585
It is a glibc extension, and glibc implements it only for unibyte
337
587
# undef strcasestr
338
# define strcasestr(a,b) \
339
(GL_LINK_WARNING ("strcasestr does work correctly on character strings " \
340
"in multibyte locales - " \
341
"use mbscasestr if you care about " \
342
"internationalization, or use c-strcasestr if you want " \
343
"a locale independent function"), \
588
# if HAVE_RAW_DECL_STRCASESTR
589
_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
590
"strings in multibyte locales - "
591
"use mbscasestr if you care about "
592
"internationalization, or use c-strcasestr if you want "
593
"a locale independent function");
347
597
/* Parse S into tokens separated by characters in DELIM.
348
598
If S is NULL, the saved pointer in SAVE_PTR is used as
349
599
the next starting point. For example:
350
char s[] = "-abc-=-def";
352
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
353
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
354
x = strtok_r(NULL, "=", &sp); // x = NULL
600
char s[] = "-abc-=-def";
602
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
603
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
604
x = strtok_r(NULL, "=", &sp); // x = NULL
357
607
This is a variant of strtok() that is multithread-safe.