~ubuntu-branches/ubuntu/quantal/gnutls26/quantal-security

« back to all changes in this revision

Viewing changes to lib/gl/string.in.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-05-20 13:07:18 UTC
  • mfrom: (12.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110520130718-db41dybbanzfvlji
Tags: 2.10.5-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Fix build failure with --no-add-needed.
  - Build for multiarch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* A GNU-like <string.h>.
2
2
 
3
 
   Copyright (C) 1995-1996, 2001-2008 Free Software Foundation, Inc.
 
3
   Copyright (C) 1995-1996, 2001-2010 Free Software Foundation, Inc.
4
4
 
5
5
   This program is free software; you can redistribute it and/or modify
6
6
   it under the terms of the GNU Lesser General Public License as published by
28
28
#ifndef _GL_STRING_H
29
29
#define _GL_STRING_H
30
30
 
 
31
/* NetBSD 5.0 mis-defines NULL.  */
 
32
#include <stddef.h>
 
33
 
 
34
/* MirBSD defines mbslen as a macro.  */
 
35
#if @GNULIB_MBSLEN@ && defined __MirBSD__
 
36
# include <wchar.h>
 
37
#endif
31
38
 
32
39
#ifndef __attribute__
33
40
/* This feature is available in gcc versions 2.5 and later.  */
41
48
#endif
42
49
 
43
50
 
44
 
/* The definition of GL_LINK_WARNING is copied here.  */
45
 
 
46
 
 
47
 
#ifdef __cplusplus
48
 
extern "C" {
 
51
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
52
 
 
53
/* The definition of _GL_ARG_NONNULL is copied here.  */
 
54
 
 
55
/* The definition of _GL_WARN_ON_USE is copied here.  */
 
56
 
 
57
 
 
58
/* Return the first instance of C within N bytes of S, or NULL.  */
 
59
#if @GNULIB_MEMCHR@
 
60
# if @REPLACE_MEMCHR@
 
61
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
62
#   define memchr rpl_memchr
 
63
#  endif
 
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));
 
68
# else
 
69
#  if ! @HAVE_MEMCHR@
 
70
_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
 
71
                                  __attribute__ ((__pure__))
 
72
                                  _GL_ARG_NONNULL ((1)));
 
73
#  endif
 
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));
 
80
# endif
 
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));
 
86
# else
 
87
_GL_CXXALIASWARN (memchr);
 
88
# endif
 
89
#elif defined GNULIB_POSIXCHECK
 
90
# undef memchr
 
91
/* Assume memchr is always declared.  */
 
92
_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
 
93
                 "use gnulib module memchr for portability" );
49
94
#endif
50
95
 
51
 
 
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
56
 
# endif
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__));
61
 
# endif
 
99
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
100
#   define memmem rpl_memmem
 
101
#  endif
 
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));
 
109
# else
 
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)));
 
115
#  endif
 
116
_GL_CXXALIAS_SYS (memmem, void *,
 
117
                  (void const *__haystack, size_t __haystack_len,
 
118
                   void const *__needle, size_t __needle_len));
 
119
# endif
 
120
_GL_CXXALIASWARN (memmem);
62
121
#elif defined GNULIB_POSIXCHECK
63
122
# undef memmem
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" );
 
127
# endif
69
128
#endif
70
129
 
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,
76
 
                      size_t __n);
 
134
_GL_FUNCDECL_SYS (mempcpy, void *,
 
135
                  (void *restrict __dest, void const *restrict __src,
 
136
                   size_t __n)
 
137
                  _GL_ARG_NONNULL ((1, 2)));
77
138
# endif
 
139
_GL_CXXALIAS_SYS (mempcpy, void *,
 
140
                  (void *restrict __dest, void const *restrict __src,
 
141
                   size_t __n));
 
142
_GL_CXXALIASWARN (mempcpy);
78
143
#elif defined GNULIB_POSIXCHECK
79
144
# undef mempcpy
80
 
# define mempcpy(a,b,n) \
81
 
    (GL_LINK_WARNING ("mempcpy is unportable - " \
82
 
                      "use gnulib module mempcpy for portability"), \
83
 
     mempcpy (a, b, n))
 
145
# if HAVE_RAW_DECL_MEMPCPY
 
146
_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
 
147
                 "use gnulib module mempcpy for portability");
 
148
# endif
84
149
#endif
85
150
 
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)));
 
157
# endif
 
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));
 
168
# else
 
169
_GL_CXXALIASWARN (memrchr);
91
170
# endif
92
171
#elif defined GNULIB_POSIXCHECK
93
172
# undef memrchr
94
 
# define memrchr(a,b,c) \
95
 
    (GL_LINK_WARNING ("memrchr is unportable - " \
96
 
                      "use gnulib module memrchr for portability"), \
97
 
     memrchr (a, b, c))
 
173
# if HAVE_RAW_DECL_MEMRCHR
 
174
_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
 
175
                 "use gnulib module memrchr for portability");
 
176
# endif
98
177
#endif
99
178
 
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)));
 
187
# endif
 
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));
 
198
# else
 
199
_GL_CXXALIASWARN (rawmemchr);
107
200
# endif
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"), \
113
 
     rawmemchr (a, b))
 
203
# if HAVE_RAW_DECL_RAWMEMCHR
 
204
_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
 
205
                 "use gnulib module rawmemchr for portability");
 
206
# endif
114
207
#endif
115
208
 
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)));
120
215
# endif
 
216
_GL_CXXALIAS_SYS (stpcpy, char *,
 
217
                  (char *restrict __dst, char const *restrict __src));
 
218
_GL_CXXALIASWARN (stpcpy);
121
219
#elif defined GNULIB_POSIXCHECK
122
220
# undef stpcpy
123
 
# define stpcpy(a,b) \
124
 
    (GL_LINK_WARNING ("stpcpy is unportable - " \
125
 
                      "use gnulib module stpcpy for portability"), \
126
 
     stpcpy (a, b))
 
221
# if HAVE_RAW_DECL_STPCPY
 
222
_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
 
223
                 "use gnulib module stpcpy for portability");
 
224
# endif
127
225
#endif
128
226
 
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,
135
 
                      size_t __n);
 
230
# if @REPLACE_STPNCPY@
 
231
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
232
#   define stpncpy rpl_stpncpy
 
233
#  endif
 
234
_GL_FUNCDECL_RPL (stpncpy, char *,
 
235
                  (char *restrict __dst, char const *restrict __src,
 
236
                   size_t __n)
 
237
                  _GL_ARG_NONNULL ((1, 2)));
 
238
_GL_CXXALIAS_RPL (stpncpy, char *,
 
239
                  (char *restrict __dst, char const *restrict __src,
 
240
                   size_t __n));
 
241
# else
 
242
#  if ! @HAVE_STPNCPY@
 
243
_GL_FUNCDECL_SYS (stpncpy, char *,
 
244
                  (char *restrict __dst, char const *restrict __src,
 
245
                   size_t __n)
 
246
                  _GL_ARG_NONNULL ((1, 2)));
 
247
#  endif
 
248
_GL_CXXALIAS_SYS (stpncpy, char *,
 
249
                  (char *restrict __dst, char const *restrict __src,
 
250
                   size_t __n));
136
251
# endif
 
252
_GL_CXXALIASWARN (stpncpy);
137
253
#elif defined GNULIB_POSIXCHECK
138
254
# undef stpncpy
139
 
# define stpncpy(a,b,n) \
140
 
    (GL_LINK_WARNING ("stpncpy is unportable - " \
141
 
                      "use gnulib module stpncpy for portability"), \
142
 
     stpncpy (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");
 
258
# endif
143
259
#endif
144
260
 
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.  */
148
264
# undef strchr
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"), \
153
 
     strchr (s, c))
 
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");
154
269
#endif
155
270
 
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)));
 
277
# endif
 
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));
 
288
# else
 
289
_GL_CXXALIASWARN (strchrnul);
161
290
# endif
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"), \
167
 
     strchrnul (a, b))
 
293
# if HAVE_RAW_DECL_STRCHRNUL
 
294
_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
 
295
                 "use gnulib module strchrnul for portability");
 
296
# endif
168
297
#endif
169
298
 
170
299
/* Duplicate S, returning an identical malloc'd string.  */
171
300
#if @GNULIB_STRDUP@
172
301
# if @REPLACE_STRDUP@
173
 
#  undef strdup
174
 
#  define strdup rpl_strdup
175
 
# endif
176
 
# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
177
 
extern char *strdup (char const *__s);
178
 
# endif
 
302
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
303
#   undef strdup
 
304
#   define strdup rpl_strdup
 
305
#  endif
 
306
_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
 
307
_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
 
308
# else
 
309
#  if !(@HAVE_DECL_STRDUP@ || defined strdup)
 
310
_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
 
311
#  endif
 
312
_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
 
313
# endif
 
314
_GL_CXXALIASWARN (strdup);
179
315
#elif defined GNULIB_POSIXCHECK
180
316
# undef strdup
181
 
# define strdup(a) \
182
 
    (GL_LINK_WARNING ("strdup is unportable - " \
183
 
                      "use gnulib module strdup for portability"), \
184
 
     strdup (a))
 
317
# if HAVE_RAW_DECL_STRDUP
 
318
_GL_WARN_ON_USE (strdup, "strdup is unportable - "
 
319
                 "use gnulib module strdup for portability");
 
320
# endif
 
321
#endif
 
322
 
 
323
/* Append no more than N characters from SRC onto DEST.  */
 
324
#if @GNULIB_STRNCAT@
 
325
# if @REPLACE_STRNCAT@
 
326
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
327
#   undef strncat
 
328
#   define strncat rpl_strncat
 
329
#  endif
 
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));
 
333
# else
 
334
_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
 
335
# endif
 
336
_GL_CXXALIASWARN (strncat);
 
337
#elif defined GNULIB_POSIXCHECK
 
338
# undef strncat
 
339
# if HAVE_RAW_DECL_STRNCAT
 
340
_GL_WARN_ON_USE (strncat, "strncat is unportable - "
 
341
                 "use gnulib module strncat for portability");
 
342
# endif
185
343
#endif
186
344
 
187
345
/* Return a newly allocated copy of at most N bytes of STRING.  */
188
346
#if @GNULIB_STRNDUP@
189
 
# if ! @HAVE_STRNDUP@
190
 
#  undef strndup
191
 
#  define strndup rpl_strndup
192
 
# endif
193
 
# if ! @HAVE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
194
 
extern char *strndup (char const *__string, size_t __n);
195
 
# endif
 
347
# if @REPLACE_STRNDUP@
 
348
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
349
#   undef strndup
 
350
#   define strndup rpl_strndup
 
351
#  endif
 
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));
 
355
# else
 
356
#  if ! @HAVE_DECL_STRNDUP@
 
357
_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
 
358
                                   _GL_ARG_NONNULL ((1)));
 
359
#  endif
 
360
_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
 
361
# endif
 
362
_GL_CXXALIASWARN (strndup);
196
363
#elif defined GNULIB_POSIXCHECK
197
364
# undef strndup
198
 
# define strndup(a,n) \
199
 
    (GL_LINK_WARNING ("strndup is unportable - " \
200
 
                      "use gnulib module strndup for portability"), \
201
 
     strndup (a, n))
 
365
# if HAVE_RAW_DECL_STRNDUP
 
366
_GL_WARN_ON_USE (strndup, "strndup is unportable - "
 
367
                 "use gnulib module strndup for portability");
 
368
# endif
202
369
#endif
203
370
 
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)
 
377
#   undef strnlen
 
378
#   define strnlen rpl_strnlen
 
379
#  endif
 
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));
 
384
# else
 
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)));
 
389
#  endif
 
390
_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
211
391
# endif
 
392
_GL_CXXALIASWARN (strnlen);
212
393
#elif defined GNULIB_POSIXCHECK
213
394
# undef strnlen
214
 
# define strnlen(a,n) \
215
 
    (GL_LINK_WARNING ("strnlen is unportable - " \
216
 
                      "use gnulib module strnlen for portability"), \
217
 
     strnlen (a, n))
 
395
# if HAVE_RAW_DECL_STRNLEN
 
396
_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
 
397
                 "use gnulib module strnlen for portability");
 
398
# endif
218
399
#endif
219
400
 
220
401
#if defined GNULIB_POSIXCHECK
223
404
   locale encoding is GB18030 and one of the characters to be searched is a
224
405
   digit.  */
225
406
# undef strcspn
226
 
# define strcspn(s,a) \
227
 
    (GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \
228
 
                      "in multibyte locales - " \
229
 
                      "use mbscspn if you care about internationalization"), \
230
 
     strcspn (s, a))
 
407
/* Assume strcspn is always declared.  */
 
408
_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
 
409
                 "in multibyte locales - "
 
410
                 "use mbscspn if you care about internationalization");
231
411
#endif
232
412
 
233
413
/* Find the first occurrence in S of any character in ACCEPT.  */
234
414
#if @GNULIB_STRPBRK@
235
415
# if ! @HAVE_STRPBRK@
236
 
extern char *strpbrk (char const *__s, char const *__accept)
237
 
  __attribute__ ((__pure__));
 
416
_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
 
417
                                   __attribute__ ((__pure__))
 
418
                                   _GL_ARG_NONNULL ((1, 2)));
 
419
# endif
 
420
  /* On some systems, this function is defined as an overloaded function:
 
421
       extern "C" { const char * strpbrk (const char *, const char *); }
 
422
       extern "C++" { char * strpbrk (char *, const char *); }  */
 
423
_GL_CXXALIAS_SYS_CAST2 (strpbrk,
 
424
                        char *, (char const *__s, char const *__accept),
 
425
                        const char *, (char const *__s, char const *__accept));
 
426
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
 
427
     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
 
428
_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
 
429
_GL_CXXALIASWARN1 (strpbrk, char const *,
 
430
                   (char const *__s, char const *__accept));
 
431
# else
 
432
_GL_CXXALIASWARN (strpbrk);
238
433
# endif
239
434
# if defined GNULIB_POSIXCHECK
240
435
/* strpbrk() assumes the second argument is a list of single-byte characters.
242
437
   locale encoding is GB18030 and one of the characters to be searched is a
243
438
   digit.  */
244
439
#  undef strpbrk
245
 
#  define strpbrk(s,a) \
246
 
     (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \
247
 
                       "in multibyte locales - " \
248
 
                       "use mbspbrk if you care about internationalization"), \
249
 
      strpbrk (s, a))
 
440
_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
 
441
                 "in multibyte locales - "
 
442
                 "use mbspbrk if you care about internationalization");
250
443
# endif
251
444
#elif defined GNULIB_POSIXCHECK
252
445
# undef strpbrk
253
 
# define strpbrk(s,a) \
254
 
    (GL_LINK_WARNING ("strpbrk is unportable - " \
255
 
                      "use gnulib module strpbrk for portability"), \
256
 
     strpbrk (s, a))
 
446
# if HAVE_RAW_DECL_STRPBRK
 
447
_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
 
448
                 "use gnulib module strpbrk for portability");
 
449
# endif
257
450
#endif
258
451
 
259
452
#if defined GNULIB_POSIXCHECK
260
453
/* strspn() assumes the second argument is a list of single-byte characters.
261
454
   Even in this simple case, it cannot work with multibyte strings.  */
262
455
# undef strspn
263
 
# define strspn(s,a) \
264
 
    (GL_LINK_WARNING ("strspn cannot work correctly on character strings " \
265
 
                      "in multibyte locales - " \
266
 
                      "use mbsspn if you care about internationalization"), \
267
 
     strspn (s, a))
 
456
/* Assume strspn is always declared.  */
 
457
_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
 
458
                 "in multibyte locales - "
 
459
                 "use mbsspn if you care about internationalization");
268
460
#endif
269
461
 
270
462
#if defined GNULIB_POSIXCHECK
271
463
/* strrchr() does not work with multibyte strings if the locale encoding is
272
464
   GB18030 and the character to be searched is a digit.  */
273
465
# undef strrchr
274
 
# define strrchr(s,c) \
275
 
    (GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \
276
 
                      "in some multibyte locales - " \
277
 
                      "use mbsrchr if you care about internationalization"), \
278
 
     strrchr (s, c))
 
466
/* Assume strrchr is always declared.  */
 
467
_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
 
468
                 "in some multibyte locales - "
 
469
                 "use mbsrchr if you care about internationalization");
279
470
#endif
280
471
 
281
472
/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
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)));
300
493
# endif
 
494
_GL_CXXALIAS_SYS (strsep, char *,
 
495
                  (char **restrict __stringp, char const *restrict __delim));
 
496
_GL_CXXALIASWARN (strsep);
301
497
# if defined GNULIB_POSIXCHECK
302
498
#  undef strsep
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"), \
307
 
      strsep (s, d))
 
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");
308
502
# endif
309
503
#elif defined GNULIB_POSIXCHECK
310
504
# undef strsep
311
 
# define strsep(s,d) \
312
 
    (GL_LINK_WARNING ("strsep is unportable - " \
313
 
                      "use gnulib module strsep for portability"), \
314
 
     strsep (s, d))
 
505
# if HAVE_RAW_DECL_STRSEP
 
506
_GL_WARN_ON_USE (strsep, "strsep is unportable - "
 
507
                 "use gnulib module strsep for portability");
 
508
# endif
315
509
#endif
316
510
 
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
 
515
#  endif
 
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));
 
520
# else
 
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));
 
527
# endif
 
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));
 
533
# else
 
534
_GL_CXXALIASWARN (strstr);
322
535
# endif
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.  */
328
541
# undef strstr
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"), \
335
 
     strstr (a, b))
 
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");
336
548
#endif
337
549
 
338
550
/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
339
551
   comparison.  */
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
 
556
#  endif
 
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));
 
562
# else
 
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)));
 
567
#  endif
 
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));
343
574
# endif
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));
 
580
# else
 
581
_GL_CXXALIASWARN (strcasestr);
347
582
# endif
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
351
586
   locales.  */
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"), \
359
 
     strcasestr (a, b))
 
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");
 
594
# endif
360
595
#endif
361
596
 
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";
366
 
        char *sp;
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
370
 
                // s = "abc\0-def\0"
 
600
        char s[] = "-abc-=-def";
 
601
        char *sp;
 
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
 
605
                // s = "abc\0-def\0"
371
606
 
372
607
   This is a variant of strtok() that is multithread-safe.
373
608
 
382
617
 
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)
 
622
#   undef strtok_r
 
623
#   define strtok_r rpl_strtok_r
 
624
#  endif
 
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));
 
632
# else
 
633
#  if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
 
634
#   undef strtok_r
 
635
#  endif
 
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)));
 
641
#  endif
 
642
_GL_CXXALIAS_SYS (strtok_r, char *,
 
643
                  (char *restrict s, char const *restrict delim,
 
644
                   char **restrict save_ptr));
388
645
# endif
 
646
_GL_CXXALIASWARN (strtok_r);
389
647
# if defined GNULIB_POSIXCHECK
390
 
#  undef strtok_r
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"), \
395
 
      strtok_r (s, d, p))
 
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");
396
651
# endif
397
652
#elif defined GNULIB_POSIXCHECK
398
653
# undef strtok_r
399
 
# define strtok_r(s,d,p) \
400
 
    (GL_LINK_WARNING ("strtok_r is unportable - " \
401
 
                      "use gnulib module strtok_r for portability"), \
402
 
     strtok_r (s, d, p))
 
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");
 
657
# endif
403
658
#endif
404
659
 
405
660
 
409
664
#if @GNULIB_MBSLEN@
410
665
/* Return the number of multibyte characters in the character string STRING.
411
666
   This considers multibyte characters, unlike strlen, which counts bytes.  */
412
 
extern size_t mbslen (const char *string);
 
667
# ifdef __MirBSD__  /* MirBSD defines mbslen as a macro.  Override it.  */
 
668
#  undef mbslen
 
669
# endif
 
670
# if @HAVE_MBSLEN@  /* AIX, OSF/1, MirBSD define mbslen already in libc.  */
 
671
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
672
#   define mbslen rpl_mbslen
 
673
#  endif
 
674
_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
 
675
_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
 
676
# else
 
677
_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
 
678
_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
 
679
# endif
 
680
_GL_CXXALIASWARN (mbslen);
413
681
#endif
414
682
 
415
683
#if @GNULIB_MBSNLEN@
416
684
/* Return the number of multibyte characters in the character string starting
417
685
   at STRING and ending at STRING + LEN.  */
418
 
extern size_t mbsnlen (const char *string, size_t len);
 
686
_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
 
687
     _GL_ARG_NONNULL ((1));
419
688
#endif
420
689
 
421
690
#if @GNULIB_MBSCHR@
423
692
   and return a pointer to it.  Return NULL if C is not found in STRING.
424
693
   Unlike strchr(), this function works correctly in multibyte locales with
425
694
   encodings such as GB18030.  */
426
 
# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
427
 
extern char * mbschr (const char *string, int c);
 
695
# if defined __hpux
 
696
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
697
#   define mbschr rpl_mbschr /* avoid collision with HP-UX function */
 
698
#  endif
 
699
_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
 
700
                                  _GL_ARG_NONNULL ((1)));
 
701
_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
 
702
# else
 
703
_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
 
704
                                  _GL_ARG_NONNULL ((1)));
 
705
_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
 
706
# endif
 
707
_GL_CXXALIASWARN (mbschr);
428
708
#endif
429
709
 
430
710
#if @GNULIB_MBSRCHR@
432
712
   and return a pointer to it.  Return NULL if C is not found in STRING.
433
713
   Unlike strrchr(), this function works correctly in multibyte locales with
434
714
   encodings such as GB18030.  */
435
 
# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
436
 
extern char * mbsrchr (const char *string, int c);
 
715
# if defined __hpux
 
716
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
717
#   define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
 
718
#  endif
 
719
_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
 
720
                                   _GL_ARG_NONNULL ((1)));
 
721
_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
 
722
# else
 
723
_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
 
724
                                   _GL_ARG_NONNULL ((1)));
 
725
_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
 
726
# endif
 
727
_GL_CXXALIASWARN (mbsrchr);
437
728
#endif
438
729
 
439
730
#if @GNULIB_MBSSTR@
441
732
   string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
442
733
   Unlike strstr(), this function works correctly in multibyte locales with
443
734
   encodings different from UTF-8.  */
444
 
extern char * mbsstr (const char *haystack, const char *needle);
 
735
_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
 
736
     _GL_ARG_NONNULL ((1, 2));
445
737
#endif
446
738
 
447
739
#if @GNULIB_MBSCASECMP@
451
743
   Note: This function may, in multibyte locales, return 0 for strings of
452
744
   different lengths!
453
745
   Unlike strcasecmp(), this function works correctly in multibyte locales.  */
454
 
extern int mbscasecmp (const char *s1, const char *s2);
 
746
_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
 
747
     _GL_ARG_NONNULL ((1, 2));
455
748
#endif
456
749
 
457
750
#if @GNULIB_MBSNCASECMP@
464
757
   of different lengths!
465
758
   Unlike strncasecmp(), this function works correctly in multibyte locales.
466
759
   But beware that N is not a byte count but a character count!  */
467
 
extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
 
760
_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
 
761
     _GL_ARG_NONNULL ((1, 2));
468
762
#endif
469
763
 
470
764
#if @GNULIB_MBSPCASECMP@
477
771
   smaller length than PREFIX!
478
772
   Unlike strncasecmp(), this function works correctly in multibyte
479
773
   locales.  */
480
 
extern char * mbspcasecmp (const char *string, const char *prefix);
 
774
_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
 
775
     _GL_ARG_NONNULL ((1, 2));
481
776
#endif
482
777
 
483
778
#if @GNULIB_MBSCASESTR@
486
781
   Note: This function may, in multibyte locales, return success even if
487
782
   strlen (haystack) < strlen (needle) !
488
783
   Unlike strcasestr(), this function works correctly in multibyte locales.  */
489
 
extern char * mbscasestr (const char *haystack, const char *needle);
 
784
_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
 
785
     _GL_ARG_NONNULL ((1, 2));
490
786
#endif
491
787
 
492
788
#if @GNULIB_MBSCSPN@
495
791
   beginning of the string to this occurrence, or to the end of the string
496
792
   if none exists.
497
793
   Unlike strcspn(), this function works correctly in multibyte locales.  */
498
 
extern size_t mbscspn (const char *string, const char *accept);
 
794
_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
 
795
     _GL_ARG_NONNULL ((1, 2));
499
796
#endif
500
797
 
501
798
#if @GNULIB_MBSPBRK@
503
800
   in the character string ACCEPT.  Return the pointer to it, or NULL if none
504
801
   exists.
505
802
   Unlike strpbrk(), this function works correctly in multibyte locales.  */
506
 
# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
507
 
extern char * mbspbrk (const char *string, const char *accept);
 
803
# if defined __hpux
 
804
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
805
#   define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
 
806
#  endif
 
807
_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
 
808
                                   _GL_ARG_NONNULL ((1, 2)));
 
809
_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
 
810
# else
 
811
_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
 
812
                                   _GL_ARG_NONNULL ((1, 2)));
 
813
_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
 
814
# endif
 
815
_GL_CXXALIASWARN (mbspbrk);
508
816
#endif
509
817
 
510
818
#if @GNULIB_MBSSPN@
513
821
   beginning of the string to this occurrence, or to the end of the string
514
822
   if none exists.
515
823
   Unlike strspn(), this function works correctly in multibyte locales.  */
516
 
extern size_t mbsspn (const char *string, const char *reject);
 
824
_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
 
825
     _GL_ARG_NONNULL ((1, 2));
517
826
#endif
518
827
 
519
828
#if @GNULIB_MBSSEP@
531
840
   Caveat: The identity of the delimiting character is lost.
532
841
 
533
842
   See also mbstok_r().  */
534
 
extern char * mbssep (char **stringp, const char *delim);
 
843
_GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
 
844
     _GL_ARG_NONNULL ((1, 2));
535
845
#endif
536
846
 
537
847
#if @GNULIB_MBSTOK_R@
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";
543
 
        char *sp;
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
547
 
                // s = "abc\0-def\0"
 
852
        char s[] = "-abc-=-def";
 
853
        char *sp;
 
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
 
857
                // s = "abc\0-def\0"
548
858
 
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.
552
862
 
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));
555
866
#endif
556
867
 
557
868
/* Map any int, typically from errno, into an error message.  */
558
869
#if @GNULIB_STRERROR@
559
870
# if @REPLACE_STRERROR@
560
 
#  undef strerror
561
 
#  define strerror rpl_strerror
562
 
extern char *strerror (int);
 
871
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
872
#   undef strerror
 
873
#   define strerror rpl_strerror
 
874
#  endif
 
875
_GL_FUNCDECL_RPL (strerror, char *, (int));
 
876
_GL_CXXALIAS_RPL (strerror, char *, (int));
 
877
# else
 
878
_GL_CXXALIAS_SYS (strerror, char *, (int));
563
879
# endif
 
880
_GL_CXXALIASWARN (strerror);
564
881
#elif defined GNULIB_POSIXCHECK
565
882
# undef strerror
566
 
# define strerror(e) \
567
 
    (GL_LINK_WARNING ("strerror is unportable - " \
568
 
                      "use gnulib module strerror to guarantee non-NULL result"), \
569
 
     strerror (e))
 
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");
570
886
#endif
571
887
 
572
888
#if @GNULIB_STRSIGNAL@
573
889
# if @REPLACE_STRSIGNAL@
574
 
#  define strsignal rpl_strsignal
575
 
# endif
576
 
# if ! @HAVE_DECL_STRSIGNAL@ || @REPLACE_STRSIGNAL@
577
 
extern char *strsignal (int __sig);
578
 
# endif
 
890
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
891
#   define strsignal rpl_strsignal
 
892
#  endif
 
893
_GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
 
894
_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
 
895
# else
 
896
#  if ! @HAVE_DECL_STRSIGNAL@
 
897
_GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
 
898
#  endif
 
899
/* Need to cast, because on Cygwin 1.5.x systems, the return type is
 
900
   'const char *'.  */
 
901
_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
 
902
# endif
 
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"), \
584
 
     strsignal (a))
 
906
# if HAVE_RAW_DECL_STRSIGNAL
 
907
_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
 
908
                 "use gnulib module strsignal for portability");
 
909
# endif
585
910
#endif
586
911
 
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)));
590
916
# endif
 
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"), \
596
 
     strverscmp (a, b))
597
 
#endif
598
 
 
599
 
 
600
 
#ifdef __cplusplus
601
 
}
602
 
#endif
 
921
# if HAVE_RAW_DECL_STRVERSCMP
 
922
_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
 
923
                 "use gnulib module strverscmp for portability");
 
924
# endif
 
925
#endif
 
926
 
603
927
 
604
928
#endif /* _GL_STRING_H */
605
929
#endif /* _GL_STRING_H */