44
/* The definition of GL_LINK_WARNING is copied here. */
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" );
52
96
/* Return the first occurrence of NEEDLE in HAYSTACK. */
53
97
#if @GNULIB_MEMMEM@
54
98
# if @REPLACE_MEMMEM@
55
# define memmem rpl_memmem
57
# if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
58
extern void *memmem (void const *__haystack, size_t __haystack_len,
59
void const *__needle, size_t __needle_len)
60
__attribute__ ((__pure__));
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);
62
121
#elif defined GNULIB_POSIXCHECK
64
# define memmem(a,al,b,bl) \
65
(GL_LINK_WARNING ("memmem is unportable and often quadratic - " \
66
"use gnulib module memmem-simple for portability, " \
67
"and module memmem for speed" ), \
68
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" );
71
130
/* Copy N bytes of SRC to DEST, return pointer to bytes after the
72
131
last written byte. */
73
132
#if @GNULIB_MEMPCPY@
74
133
# if ! @HAVE_MEMPCPY@
75
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);
78
143
#elif defined GNULIB_POSIXCHECK
80
# define mempcpy(a,b,n) \
81
(GL_LINK_WARNING ("mempcpy is unportable - " \
82
"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");
86
151
/* Search backwards through a block for a byte (specified as an int). */
87
152
#if @GNULIB_MEMRCHR@
88
153
# if ! @HAVE_DECL_MEMRCHR@
89
extern void *memrchr (void const *, int, size_t)
90
__attribute__ ((__pure__));
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);
92
171
#elif defined GNULIB_POSIXCHECK
94
# define memrchr(a,b,c) \
95
(GL_LINK_WARNING ("memrchr is unportable - " \
96
"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");
100
179
/* Find the first occurrence of C in S. More efficient than
102
181
occur within N bytes. */
103
182
#if @GNULIB_RAWMEMCHR@
104
183
# if ! @HAVE_RAWMEMCHR@
105
extern void *rawmemchr (void const *__s, int __c_in)
106
__attribute__ ((__pure__));
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);
108
201
#elif defined GNULIB_POSIXCHECK
109
202
# undef rawmemchr
110
# define rawmemchr(a,b) \
111
(GL_LINK_WARNING ("rawmemchr is unportable - " \
112
"use gnulib module rawmemchr for portability"), \
203
# if HAVE_RAW_DECL_RAWMEMCHR
204
_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
205
"use gnulib module rawmemchr for portability");
116
209
/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
117
210
#if @GNULIB_STPCPY@
118
211
# if ! @HAVE_STPCPY@
119
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);
121
219
#elif defined GNULIB_POSIXCHECK
123
# define stpcpy(a,b) \
124
(GL_LINK_WARNING ("stpcpy is unportable - " \
125
"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");
129
227
/* Copy no more than N bytes of SRC to DST, returning a pointer past the
130
228
last non-NUL byte written into DST. */
131
229
#if @GNULIB_STPNCPY@
132
# if ! @HAVE_STPNCPY@
133
# define stpncpy gnu_stpncpy
134
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);
137
253
#elif defined GNULIB_POSIXCHECK
139
# define stpncpy(a,b,n) \
140
(GL_LINK_WARNING ("stpncpy is unportable - " \
141
"use gnulib module stpncpy for portability"), \
255
# if HAVE_RAW_DECL_STPNCPY
256
_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
257
"use gnulib module stpncpy for portability");
145
261
#if defined GNULIB_POSIXCHECK
146
262
/* strchr() does not work with multibyte strings if the locale encoding is
147
263
GB18030 and the character to be searched is a digit. */
149
# define strchr(s,c) \
150
(GL_LINK_WARNING ("strchr cannot work correctly on character strings " \
151
"in some multibyte locales - " \
152
"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");
156
271
/* Find the first occurrence of C in S or the final NUL byte. */
157
272
#if @GNULIB_STRCHRNUL@
158
273
# if ! @HAVE_STRCHRNUL@
159
extern char *strchrnul (char const *__s, int __c_in)
160
__attribute__ ((__pure__));
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);
162
291
#elif defined GNULIB_POSIXCHECK
163
292
# undef strchrnul
164
# define strchrnul(a,b) \
165
(GL_LINK_WARNING ("strchrnul is unportable - " \
166
"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");
170
299
/* Duplicate S, returning an identical malloc'd string. */
171
300
#if @GNULIB_STRDUP@
172
301
# if @REPLACE_STRDUP@
174
# define strdup rpl_strdup
176
# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
177
extern char *strdup (char const *__s);
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)
210
__attribute__ ((__pure__));
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);
212
393
#elif defined GNULIB_POSIXCHECK
214
# define strnlen(a,n) \
215
(GL_LINK_WARNING ("strnlen is unportable - " \
216
"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");
220
401
#if defined GNULIB_POSIXCHECK
296
487
See also strtok_r(). */
297
488
#if @GNULIB_STRSEP@
298
489
# if ! @HAVE_STRSEP@
299
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);
301
497
# if defined GNULIB_POSIXCHECK
303
# define strsep(s,d) \
304
(GL_LINK_WARNING ("strsep cannot work correctly on character strings " \
305
"in multibyte locales - " \
306
"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");
309
503
#elif defined GNULIB_POSIXCHECK
311
# define strsep(s,d) \
312
(GL_LINK_WARNING ("strsep is unportable - " \
313
"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");
317
511
#if @GNULIB_STRSTR@
318
512
# if @REPLACE_STRSTR@
319
# define strstr rpl_strstr
320
char *strstr (const char *haystack, const char *needle)
321
__attribute__ ((__pure__));
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);
323
536
#elif defined GNULIB_POSIXCHECK
324
537
/* strstr() does not work with multibyte strings if the locale encoding is
326
539
POSIX says that it operates on "strings", and "string" in POSIX is defined
327
540
as a sequence of bytes, not of characters. */
329
# define strstr(a,b) \
330
(GL_LINK_WARNING ("strstr is quadratic on many systems, and cannot " \
331
"work correctly on character strings in most " \
332
"multibyte locales - " \
333
"use mbsstr if you care about internationalization, " \
334
"or use strstr if you care about speed"), \
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");
338
550
/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
340
552
#if @GNULIB_STRCASESTR@
341
553
# if @REPLACE_STRCASESTR@
342
# define strcasestr rpl_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));
344
# if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
345
extern char *strcasestr (const char *haystack, const char *needle)
346
__attribute__ ((__pure__));
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);
348
583
#elif defined GNULIB_POSIXCHECK
349
584
/* strcasestr() does not work with multibyte strings:
350
585
It is a glibc extension, and glibc implements it only for unibyte
352
587
# undef strcasestr
353
# define strcasestr(a,b) \
354
(GL_LINK_WARNING ("strcasestr does work correctly on character strings " \
355
"in multibyte locales - " \
356
"use mbscasestr if you care about " \
357
"internationalization, or use c-strcasestr if you want " \
358
"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");
362
597
/* Parse S into tokens separated by characters in DELIM.
363
598
If S is NULL, the saved pointer in SAVE_PTR is used as
364
599
the next starting point. For example:
365
char s[] = "-abc-=-def";
367
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
368
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
369
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
372
607
This is a variant of strtok() that is multithread-safe.
383
618
See also strsep(). */
384
619
#if @GNULIB_STRTOK_R@
385
# if ! @HAVE_DECL_STRTOK_R@
386
extern char *strtok_r (char *restrict s, char const *restrict delim,
387
char **restrict save_ptr);
620
# if @REPLACE_STRTOK_R@
621
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
623
# define strtok_r rpl_strtok_r
625
_GL_FUNCDECL_RPL (strtok_r, char *,
626
(char *restrict s, char const *restrict delim,
627
char **restrict save_ptr)
628
_GL_ARG_NONNULL ((2, 3)));
629
_GL_CXXALIAS_RPL (strtok_r, char *,
630
(char *restrict s, char const *restrict delim,
631
char **restrict save_ptr));
633
# if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
636
# if ! @HAVE_DECL_STRTOK_R@
637
_GL_FUNCDECL_SYS (strtok_r, char *,
638
(char *restrict s, char const *restrict delim,
639
char **restrict save_ptr)
640
_GL_ARG_NONNULL ((2, 3)));
642
_GL_CXXALIAS_SYS (strtok_r, char *,
643
(char *restrict s, char const *restrict delim,
644
char **restrict save_ptr));
646
_GL_CXXALIASWARN (strtok_r);
389
647
# if defined GNULIB_POSIXCHECK
391
# define strtok_r(s,d,p) \
392
(GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \
393
"in multibyte locales - " \
394
"use mbstok_r if you care about internationalization"), \
648
_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
649
"strings in multibyte locales - "
650
"use mbstok_r if you care about internationalization");
397
652
#elif defined GNULIB_POSIXCHECK
399
# define strtok_r(s,d,p) \
400
(GL_LINK_WARNING ("strtok_r is unportable - " \
401
"use gnulib module strtok_r for portability"), \
654
# if HAVE_RAW_DECL_STRTOK_R
655
_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
656
"use gnulib module strtok_r for portability");
539
849
the character string DELIM.
540
850
If STRING is NULL, the saved pointer in SAVE_PTR is used as
541
851
the next starting point. For example:
542
char s[] = "-abc-=-def";
544
x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
545
x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
546
x = mbstok_r(NULL, "=", &sp); // x = NULL
852
char s[] = "-abc-=-def";
854
x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
855
x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
856
x = mbstok_r(NULL, "=", &sp); // x = NULL
549
859
Caveat: It modifies the original string.
550
860
Caveat: These functions cannot be used on constant strings.
551
861
Caveat: The identity of the delimiting character is lost.
553
863
See also mbssep(). */
554
extern char * mbstok_r (char *string, const char *delim, char **save_ptr);
864
_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
865
_GL_ARG_NONNULL ((2, 3));
557
868
/* Map any int, typically from errno, into an error message. */
558
869
#if @GNULIB_STRERROR@
559
870
# if @REPLACE_STRERROR@
561
# define strerror rpl_strerror
562
extern char *strerror (int);
871
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
873
# define strerror rpl_strerror
875
_GL_FUNCDECL_RPL (strerror, char *, (int));
876
_GL_CXXALIAS_RPL (strerror, char *, (int));
878
_GL_CXXALIAS_SYS (strerror, char *, (int));
880
_GL_CXXALIASWARN (strerror);
564
881
#elif defined GNULIB_POSIXCHECK
566
# define strerror(e) \
567
(GL_LINK_WARNING ("strerror is unportable - " \
568
"use gnulib module strerror to guarantee non-NULL result"), \
883
/* Assume strerror is always declared. */
884
_GL_WARN_ON_USE (strerror, "strerror is unportable - "
885
"use gnulib module strerror to guarantee non-NULL result");
572
888
#if @GNULIB_STRSIGNAL@
573
889
# if @REPLACE_STRSIGNAL@
574
# define strsignal rpl_strsignal
576
# if ! @HAVE_DECL_STRSIGNAL@ || @REPLACE_STRSIGNAL@
577
extern char *strsignal (int __sig);
890
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
891
# define strsignal rpl_strsignal
893
_GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
894
_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
896
# if ! @HAVE_DECL_STRSIGNAL@
897
_GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
899
/* Need to cast, because on Cygwin 1.5.x systems, the return type is
901
_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
903
_GL_CXXALIASWARN (strsignal);
579
904
#elif defined GNULIB_POSIXCHECK
580
905
# undef strsignal
581
# define strsignal(a) \
582
(GL_LINK_WARNING ("strsignal is unportable - " \
583
"use gnulib module strsignal for portability"), \
906
# if HAVE_RAW_DECL_STRSIGNAL
907
_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
908
"use gnulib module strsignal for portability");
587
912
#if @GNULIB_STRVERSCMP@
588
913
# if !@HAVE_STRVERSCMP@
589
extern int strverscmp (const char *, const char *);
914
_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
915
_GL_ARG_NONNULL ((1, 2)));
917
_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
918
_GL_CXXALIASWARN (strverscmp);
591
919
#elif defined GNULIB_POSIXCHECK
592
920
# undef strverscmp
593
# define strverscmp(a, b) \
594
(GL_LINK_WARNING ("strverscmp is unportable - " \
595
"use gnulib module strverscmp for portability"), \
921
# if HAVE_RAW_DECL_STRVERSCMP
922
_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
923
"use gnulib module strverscmp for portability");
604
928
#endif /* _GL_STRING_H */
605
929
#endif /* _GL_STRING_H */