28
28
#ifndef _GL_STRING_H
29
29
#define _GL_STRING_H
31
/* NetBSD 5.0 mis-defines NULL. */
34
/* MirBSD defines mbslen as a macro. */
35
#if @GNULIB_MBSLEN@ && defined __MirBSD__
32
39
#ifndef __attribute__
33
40
/* This feature is available in gcc versions 2.5 and later. */
34
41
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
35
42
# define __attribute__(Spec) /* empty */
37
45
/* The attribute __pure__ was added in gcc 2.96. */
38
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
39
# define __pure__ /* empty */
44
/* The definition of GL_LINK_WARNING is copied here. */
46
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
47
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
49
# define _GL_ATTRIBUTE_PURE /* empty */
53
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
55
/* The definition of _GL_ARG_NONNULL is copied here. */
57
/* The definition of _GL_WARN_ON_USE is copied here. */
52
60
/* Return the first instance of C within N bytes of S, or NULL. */
53
61
#if @GNULIB_MEMCHR@
54
62
# if @REPLACE_MEMCHR@
55
# define memchr rpl_memchr
63
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
64
# define memchr rpl_memchr
66
_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
68
_GL_ARG_NONNULL ((1)));
69
_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
72
_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
74
_GL_ARG_NONNULL ((1)));
76
/* On some systems, this function is defined as an overloaded function:
77
extern "C" { const void * std::memchr (const void *, int, size_t); }
78
extern "C++" { void * std::memchr (void *, int, size_t); } */
79
_GL_CXXALIAS_SYS_CAST2 (memchr,
80
void *, (void const *__s, int __c, size_t __n),
81
void const *, (void const *__s, int __c, size_t __n));
58
extern void *memchr (void const *__s, int __c, size_t __n)
59
__attribute__ ((__pure__));
83
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
84
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
85
_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
86
_GL_CXXALIASWARN1 (memchr, void const *,
87
(void const *__s, int __c, size_t __n));
89
_GL_CXXALIASWARN (memchr);
61
91
#elif defined GNULIB_POSIXCHECK
63
# define memchr(s,c,n) \
64
(GL_LINK_WARNING ("memchr has platform-specific bugs - " \
65
"use gnulib module memchr for portability" ), \
93
/* Assume memchr is always declared. */
94
_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
95
"use gnulib module memchr for portability" );
69
98
/* Return the first occurrence of NEEDLE in HAYSTACK. */
70
99
#if @GNULIB_MEMMEM@
71
100
# if @REPLACE_MEMMEM@
72
# define memmem rpl_memmem
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__));
101
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
102
# define memmem rpl_memmem
104
_GL_FUNCDECL_RPL (memmem, void *,
105
(void const *__haystack, size_t __haystack_len,
106
void const *__needle, size_t __needle_len)
108
_GL_ARG_NONNULL ((1, 3)));
109
_GL_CXXALIAS_RPL (memmem, void *,
110
(void const *__haystack, size_t __haystack_len,
111
void const *__needle, size_t __needle_len));
113
# if ! @HAVE_DECL_MEMMEM@
114
_GL_FUNCDECL_SYS (memmem, void *,
115
(void const *__haystack, size_t __haystack_len,
116
void const *__needle, size_t __needle_len)
118
_GL_ARG_NONNULL ((1, 3)));
120
_GL_CXXALIAS_SYS (memmem, void *,
121
(void const *__haystack, size_t __haystack_len,
122
void const *__needle, size_t __needle_len));
124
_GL_CXXALIASWARN (memmem);
79
125
#elif defined GNULIB_POSIXCHECK
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))
127
# if HAVE_RAW_DECL_MEMMEM
128
_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
129
"use gnulib module memmem-simple for portability, "
130
"and module memmem for speed" );
88
134
/* Copy N bytes of SRC to DEST, return pointer to bytes after the
89
135
last written byte. */
90
136
#if @GNULIB_MEMPCPY@
91
137
# if ! @HAVE_MEMPCPY@
92
extern void *mempcpy (void *restrict __dest, void const *restrict __src,
138
_GL_FUNCDECL_SYS (mempcpy, void *,
139
(void *restrict __dest, void const *restrict __src,
141
_GL_ARG_NONNULL ((1, 2)));
143
_GL_CXXALIAS_SYS (mempcpy, void *,
144
(void *restrict __dest, void const *restrict __src,
146
_GL_CXXALIASWARN (mempcpy);
95
147
#elif defined GNULIB_POSIXCHECK
97
# define mempcpy(a,b,n) \
98
(GL_LINK_WARNING ("mempcpy is unportable - " \
99
"use gnulib module mempcpy for portability"), \
149
# if HAVE_RAW_DECL_MEMPCPY
150
_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
151
"use gnulib module mempcpy for portability");
103
155
/* Search backwards through a block for a byte (specified as an int). */
104
156
#if @GNULIB_MEMRCHR@
105
157
# if ! @HAVE_DECL_MEMRCHR@
106
extern void *memrchr (void const *, int, size_t)
107
__attribute__ ((__pure__));
158
_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
160
_GL_ARG_NONNULL ((1)));
162
/* On some systems, this function is defined as an overloaded function:
163
extern "C++" { const void * std::memrchr (const void *, int, size_t); }
164
extern "C++" { void * std::memrchr (void *, int, size_t); } */
165
_GL_CXXALIAS_SYS_CAST2 (memrchr,
166
void *, (void const *, int, size_t),
167
void const *, (void const *, int, size_t));
168
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
169
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
170
_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
171
_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
173
_GL_CXXALIASWARN (memrchr);
109
175
#elif defined GNULIB_POSIXCHECK
111
# define memrchr(a,b,c) \
112
(GL_LINK_WARNING ("memrchr is unportable - " \
113
"use gnulib module memrchr for portability"), \
177
# if HAVE_RAW_DECL_MEMRCHR
178
_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
179
"use gnulib module memrchr for portability");
117
183
/* Find the first occurrence of C in S. More efficient than
119
185
occur within N bytes. */
120
186
#if @GNULIB_RAWMEMCHR@
121
187
# if ! @HAVE_RAWMEMCHR@
122
extern void *rawmemchr (void const *__s, int __c_in)
123
__attribute__ ((__pure__));
188
_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
190
_GL_ARG_NONNULL ((1)));
192
/* On some systems, this function is defined as an overloaded function:
193
extern "C++" { const void * std::rawmemchr (const void *, int); }
194
extern "C++" { void * std::rawmemchr (void *, int); } */
195
_GL_CXXALIAS_SYS_CAST2 (rawmemchr,
196
void *, (void const *__s, int __c_in),
197
void const *, (void const *__s, int __c_in));
198
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
199
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
200
_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
201
_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
203
_GL_CXXALIASWARN (rawmemchr);
125
205
#elif defined GNULIB_POSIXCHECK
126
206
# undef rawmemchr
127
# define rawmemchr(a,b) \
128
(GL_LINK_WARNING ("rawmemchr is unportable - " \
129
"use gnulib module rawmemchr for portability"), \
207
# if HAVE_RAW_DECL_RAWMEMCHR
208
_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
209
"use gnulib module rawmemchr for portability");
133
213
/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
134
214
#if @GNULIB_STPCPY@
135
215
# if ! @HAVE_STPCPY@
136
extern char *stpcpy (char *restrict __dst, char const *restrict __src);
216
_GL_FUNCDECL_SYS (stpcpy, char *,
217
(char *restrict __dst, char const *restrict __src)
218
_GL_ARG_NONNULL ((1, 2)));
220
_GL_CXXALIAS_SYS (stpcpy, char *,
221
(char *restrict __dst, char const *restrict __src));
222
_GL_CXXALIASWARN (stpcpy);
138
223
#elif defined GNULIB_POSIXCHECK
140
# define stpcpy(a,b) \
141
(GL_LINK_WARNING ("stpcpy is unportable - " \
142
"use gnulib module stpcpy for portability"), \
225
# if HAVE_RAW_DECL_STPCPY
226
_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
227
"use gnulib module stpcpy for portability");
146
231
/* Copy no more than N bytes of SRC to DST, returning a pointer past the
147
232
last non-NUL byte written into DST. */
148
233
#if @GNULIB_STPNCPY@
149
# if ! @HAVE_STPNCPY@
150
# define stpncpy gnu_stpncpy
151
extern char *stpncpy (char *restrict __dst, char const *restrict __src,
234
# if @REPLACE_STPNCPY@
235
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
237
# define stpncpy rpl_stpncpy
239
_GL_FUNCDECL_RPL (stpncpy, char *,
240
(char *restrict __dst, char const *restrict __src,
242
_GL_ARG_NONNULL ((1, 2)));
243
_GL_CXXALIAS_RPL (stpncpy, char *,
244
(char *restrict __dst, char const *restrict __src,
247
# if ! @HAVE_STPNCPY@
248
_GL_FUNCDECL_SYS (stpncpy, char *,
249
(char *restrict __dst, char const *restrict __src,
251
_GL_ARG_NONNULL ((1, 2)));
253
_GL_CXXALIAS_SYS (stpncpy, char *,
254
(char *restrict __dst, char const *restrict __src,
257
_GL_CXXALIASWARN (stpncpy);
154
258
#elif defined GNULIB_POSIXCHECK
156
# define stpncpy(a,b,n) \
157
(GL_LINK_WARNING ("stpncpy is unportable - " \
158
"use gnulib module stpncpy for portability"), \
260
# if HAVE_RAW_DECL_STPNCPY
261
_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
262
"use gnulib module stpncpy for portability");
162
266
#if defined GNULIB_POSIXCHECK
163
267
/* strchr() does not work with multibyte strings if the locale encoding is
164
268
GB18030 and the character to be searched is a digit. */
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"), \
270
/* Assume strchr is always declared. */
271
_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
272
"in some multibyte locales - "
273
"use mbschr if you care about internationalization");
173
276
/* Find the first occurrence of C in S or the final NUL byte. */
174
277
#if @GNULIB_STRCHRNUL@
175
278
# if ! @HAVE_STRCHRNUL@
176
extern char *strchrnul (char const *__s, int __c_in)
177
__attribute__ ((__pure__));
279
_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
281
_GL_ARG_NONNULL ((1)));
283
/* On some systems, this function is defined as an overloaded function:
284
extern "C++" { const char * std::strchrnul (const char *, int); }
285
extern "C++" { char * std::strchrnul (char *, int); } */
286
_GL_CXXALIAS_SYS_CAST2 (strchrnul,
287
char *, (char const *__s, int __c_in),
288
char const *, (char const *__s, int __c_in));
289
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
290
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
291
_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
292
_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
294
_GL_CXXALIASWARN (strchrnul);
179
296
#elif defined GNULIB_POSIXCHECK
180
297
# undef strchrnul
181
# define strchrnul(a,b) \
182
(GL_LINK_WARNING ("strchrnul is unportable - " \
183
"use gnulib module strchrnul for portability"), \
298
# if HAVE_RAW_DECL_STRCHRNUL
299
_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
300
"use gnulib module strchrnul for portability");
187
304
/* Duplicate S, returning an identical malloc'd string. */
188
305
#if @GNULIB_STRDUP@
189
306
# if @REPLACE_STRDUP@
191
# define strdup rpl_strdup
193
# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
194
extern char *strdup (char const *__s);
307
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
309
# define strdup rpl_strdup
311
_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
312
_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
314
# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
315
/* strdup exists as a function and as a macro. Get rid of the macro. */
318
# if !(@HAVE_DECL_STRDUP@ || defined strdup)
319
_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
321
_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
323
_GL_CXXALIASWARN (strdup);
196
324
#elif defined GNULIB_POSIXCHECK
199
(GL_LINK_WARNING ("strdup is unportable - " \
200
"use gnulib module strdup for portability"), \
326
# if HAVE_RAW_DECL_STRDUP
327
_GL_WARN_ON_USE (strdup, "strdup is unportable - "
328
"use gnulib module strdup for portability");
332
/* Append no more than N characters from SRC onto DEST. */
334
# if @REPLACE_STRNCAT@
335
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
337
# define strncat rpl_strncat
339
_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
340
_GL_ARG_NONNULL ((1, 2)));
341
_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
343
_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
345
_GL_CXXALIASWARN (strncat);
346
#elif defined GNULIB_POSIXCHECK
348
# if HAVE_RAW_DECL_STRNCAT
349
_GL_WARN_ON_USE (strncat, "strncat is unportable - "
350
"use gnulib module strncat for portability");
204
354
/* Return a newly allocated copy of at most N bytes of STRING. */
205
355
#if @GNULIB_STRNDUP@
206
# if ! @HAVE_STRNDUP@
208
# define strndup rpl_strndup
210
# if ! @HAVE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
211
extern char *strndup (char const *__string, size_t __n);
356
# if @REPLACE_STRNDUP@
357
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
359
# define strndup rpl_strndup
361
_GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n)
362
_GL_ARG_NONNULL ((1)));
363
_GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n));
365
# if ! @HAVE_DECL_STRNDUP@
366
_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
367
_GL_ARG_NONNULL ((1)));
369
_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
371
_GL_CXXALIASWARN (strndup);
213
372
#elif defined GNULIB_POSIXCHECK
215
# define strndup(a,n) \
216
(GL_LINK_WARNING ("strndup is unportable - " \
217
"use gnulib module strndup for portability"), \
374
# if HAVE_RAW_DECL_STRNDUP
375
_GL_WARN_ON_USE (strndup, "strndup is unportable - "
376
"use gnulib module strndup for portability");
221
380
/* Find the length (number of bytes) of STRING, but scan at most
222
381
MAXLEN bytes. If no '\0' terminator is found in that many bytes,
223
382
return MAXLEN. */
224
383
#if @GNULIB_STRNLEN@
225
# if ! @HAVE_DECL_STRNLEN@
226
extern size_t strnlen (char const *__string, size_t __maxlen)
227
__attribute__ ((__pure__));
384
# if @REPLACE_STRNLEN@
385
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
387
# define strnlen rpl_strnlen
389
_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
391
_GL_ARG_NONNULL ((1)));
392
_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
394
# if ! @HAVE_DECL_STRNLEN@
395
_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
397
_GL_ARG_NONNULL ((1)));
399
_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
401
_GL_CXXALIASWARN (strnlen);
229
402
#elif defined GNULIB_POSIXCHECK
231
# define strnlen(a,n) \
232
(GL_LINK_WARNING ("strnlen is unportable - " \
233
"use gnulib module strnlen for portability"), \
404
# if HAVE_RAW_DECL_STRNLEN
405
_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
406
"use gnulib module strnlen for portability");
237
410
#if defined GNULIB_POSIXCHECK
313
496
See also strtok_r(). */
314
497
#if @GNULIB_STRSEP@
315
498
# if ! @HAVE_STRSEP@
316
extern char *strsep (char **restrict __stringp, char const *restrict __delim);
499
_GL_FUNCDECL_SYS (strsep, char *,
500
(char **restrict __stringp, char const *restrict __delim)
501
_GL_ARG_NONNULL ((1, 2)));
503
_GL_CXXALIAS_SYS (strsep, char *,
504
(char **restrict __stringp, char const *restrict __delim));
505
_GL_CXXALIASWARN (strsep);
318
506
# if defined GNULIB_POSIXCHECK
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"), \
508
_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
509
"in multibyte locales - "
510
"use mbssep if you care about internationalization");
326
512
#elif defined GNULIB_POSIXCHECK
328
# define strsep(s,d) \
329
(GL_LINK_WARNING ("strsep is unportable - " \
330
"use gnulib module strsep for portability"), \
514
# if HAVE_RAW_DECL_STRSEP
515
_GL_WARN_ON_USE (strsep, "strsep is unportable - "
516
"use gnulib module strsep for portability");
334
520
#if @GNULIB_STRSTR@
335
521
# if @REPLACE_STRSTR@
336
# define strstr rpl_strstr
337
char *strstr (const char *haystack, const char *needle)
338
__attribute__ ((__pure__));
522
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
523
# define strstr rpl_strstr
525
_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
527
_GL_ARG_NONNULL ((1, 2)));
528
_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
530
/* On some systems, this function is defined as an overloaded function:
531
extern "C++" { const char * strstr (const char *, const char *); }
532
extern "C++" { char * strstr (char *, const char *); } */
533
_GL_CXXALIAS_SYS_CAST2 (strstr,
534
char *, (const char *haystack, const char *needle),
535
const char *, (const char *haystack, const char *needle));
537
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
538
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
539
_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
540
_GL_CXXALIASWARN1 (strstr, const char *,
541
(const char *haystack, const char *needle));
543
_GL_CXXALIASWARN (strstr);
340
545
#elif defined GNULIB_POSIXCHECK
341
546
/* strstr() does not work with multibyte strings if the locale encoding is
343
548
POSIX says that it operates on "strings", and "string" in POSIX is defined
344
549
as a sequence of bytes, not of characters. */
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"), \
551
/* Assume strstr is always declared. */
552
_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
553
"work correctly on character strings in most "
554
"multibyte locales - "
555
"use mbsstr if you care about internationalization, "
556
"or use strstr if you care about speed");
355
559
/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
357
561
#if @GNULIB_STRCASESTR@
358
562
# if @REPLACE_STRCASESTR@
359
# define strcasestr rpl_strcasestr
563
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
564
# define strcasestr rpl_strcasestr
566
_GL_FUNCDECL_RPL (strcasestr, char *,
567
(const char *haystack, const char *needle)
569
_GL_ARG_NONNULL ((1, 2)));
570
_GL_CXXALIAS_RPL (strcasestr, char *,
571
(const char *haystack, const char *needle));
573
# if ! @HAVE_STRCASESTR@
574
_GL_FUNCDECL_SYS (strcasestr, char *,
575
(const char *haystack, const char *needle)
577
_GL_ARG_NONNULL ((1, 2)));
579
/* On some systems, this function is defined as an overloaded function:
580
extern "C++" { const char * strcasestr (const char *, const char *); }
581
extern "C++" { char * strcasestr (char *, const char *); } */
582
_GL_CXXALIAS_SYS_CAST2 (strcasestr,
583
char *, (const char *haystack, const char *needle),
584
const char *, (const char *haystack, const char *needle));
361
# if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
362
extern char *strcasestr (const char *haystack, const char *needle)
363
__attribute__ ((__pure__));
586
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
587
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
588
_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
589
_GL_CXXALIASWARN1 (strcasestr, const char *,
590
(const char *haystack, const char *needle));
592
_GL_CXXALIASWARN (strcasestr);
365
594
#elif defined GNULIB_POSIXCHECK
366
595
/* strcasestr() does not work with multibyte strings:
367
596
It is a glibc extension, and glibc implements it only for unibyte
369
598
# 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"), \
599
# if HAVE_RAW_DECL_STRCASESTR
600
_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
601
"strings in multibyte locales - "
602
"use mbscasestr if you care about "
603
"internationalization, or use c-strcasestr if you want "
604
"a locale independent function");
379
608
/* Parse S into tokens separated by characters in DELIM.
380
609
If S is NULL, the saved pointer in SAVE_PTR is used as
381
610
the next starting point. For example:
382
char s[] = "-abc-=-def";
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
611
char s[] = "-abc-=-def";
613
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
614
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
615
x = strtok_r(NULL, "=", &sp); // x = NULL
389
618
This is a variant of strtok() that is multithread-safe.
400
629
See also strsep(). */
401
630
#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);
631
# if @REPLACE_STRTOK_R@
632
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
634
# define strtok_r rpl_strtok_r
636
_GL_FUNCDECL_RPL (strtok_r, char *,
637
(char *restrict s, char const *restrict delim,
638
char **restrict save_ptr)
639
_GL_ARG_NONNULL ((2, 3)));
640
_GL_CXXALIAS_RPL (strtok_r, char *,
641
(char *restrict s, char const *restrict delim,
642
char **restrict save_ptr));
644
# if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
647
# if ! @HAVE_DECL_STRTOK_R@
648
_GL_FUNCDECL_SYS (strtok_r, char *,
649
(char *restrict s, char const *restrict delim,
650
char **restrict save_ptr)
651
_GL_ARG_NONNULL ((2, 3)));
653
_GL_CXXALIAS_SYS (strtok_r, char *,
654
(char *restrict s, char const *restrict delim,
655
char **restrict save_ptr));
657
_GL_CXXALIASWARN (strtok_r);
406
658
# if defined GNULIB_POSIXCHECK
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"), \
659
_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
660
"strings in multibyte locales - "
661
"use mbstok_r if you care about internationalization");
414
663
#elif defined GNULIB_POSIXCHECK
416
# define strtok_r(s,d,p) \
417
(GL_LINK_WARNING ("strtok_r is unportable - " \
418
"use gnulib module strtok_r for portability"), \
665
# if HAVE_RAW_DECL_STRTOK_R
666
_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
667
"use gnulib module strtok_r for portability");
556
859
the character string DELIM.
557
860
If STRING is NULL, the saved pointer in SAVE_PTR is used as
558
861
the next starting point. For example:
559
char s[] = "-abc-=-def";
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
862
char s[] = "-abc-=-def";
864
x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
865
x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
866
x = mbstok_r(NULL, "=", &sp); // x = NULL
566
869
Caveat: It modifies the original string.
567
870
Caveat: These functions cannot be used on constant strings.
568
871
Caveat: The identity of the delimiting character is lost.
570
873
See also mbssep(). */
571
extern char * mbstok_r (char *string, const char *delim, char **save_ptr);
874
_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
875
_GL_ARG_NONNULL ((2, 3));
574
878
/* Map any int, typically from errno, into an error message. */
575
879
#if @GNULIB_STRERROR@
576
880
# if @REPLACE_STRERROR@
578
# define strerror rpl_strerror
579
extern char *strerror (int);
881
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
883
# define strerror rpl_strerror
885
_GL_FUNCDECL_RPL (strerror, char *, (int));
886
_GL_CXXALIAS_RPL (strerror, char *, (int));
888
_GL_CXXALIAS_SYS (strerror, char *, (int));
890
_GL_CXXALIASWARN (strerror);
581
891
#elif defined GNULIB_POSIXCHECK
583
# define strerror(e) \
584
(GL_LINK_WARNING ("strerror is unportable - " \
585
"use gnulib module strerror to guarantee non-NULL result"), \
893
/* Assume strerror is always declared. */
894
_GL_WARN_ON_USE (strerror, "strerror is unportable - "
895
"use gnulib module strerror to guarantee non-NULL result");
589
898
#if @GNULIB_STRSIGNAL@
590
899
# if @REPLACE_STRSIGNAL@
591
# define strsignal rpl_strsignal
593
# if ! @HAVE_DECL_STRSIGNAL@ || @REPLACE_STRSIGNAL@
594
extern char *strsignal (int __sig);
900
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
901
# define strsignal rpl_strsignal
903
_GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
904
_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
906
# if ! @HAVE_DECL_STRSIGNAL@
907
_GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
909
/* Need to cast, because on Cygwin 1.5.x systems, the return type is
911
_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
913
_GL_CXXALIASWARN (strsignal);
596
914
#elif defined GNULIB_POSIXCHECK
597
915
# undef strsignal
598
# define strsignal(a) \
599
(GL_LINK_WARNING ("strsignal is unportable - " \
600
"use gnulib module strsignal for portability"), \
916
# if HAVE_RAW_DECL_STRSIGNAL
917
_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
918
"use gnulib module strsignal for portability");
604
922
#if @GNULIB_STRVERSCMP@
605
923
# if !@HAVE_STRVERSCMP@
606
extern int strverscmp (const char *, const char *);
924
_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
925
_GL_ARG_NONNULL ((1, 2)));
927
_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
928
_GL_CXXALIASWARN (strverscmp);
608
929
#elif defined GNULIB_POSIXCHECK
609
930
# undef strverscmp
610
# define strverscmp(a, b) \
611
(GL_LINK_WARNING ("strverscmp is unportable - " \
612
"use gnulib module strverscmp for portability"), \
931
# if HAVE_RAW_DECL_STRVERSCMP
932
_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
933
"use gnulib module strverscmp for portability");
621
938
#endif /* _GL_STRING_H */
622
939
#endif /* _GL_STRING_H */