~ubuntu-branches/ubuntu/quantal/gengetopt/quantal

« back to all changes in this revision

Viewing changes to gl/string.in.h

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2011-09-26 10:27:31 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: package-import@ubuntu.com-20110926102731-vh42p0vriqz4kp3h
Tags: 2.22.5-1
* New upstream release:
  - correctly wraps and preprocess the specified usage string
  - handle escaped newline chars in the .ggo file correctly
  - initialize enum variables with a generated null value (makes
    the parser compilable in C++)
  - removed warnings in generated parser when only flags are used
* Fix gbp config file.
* Bump Standards.
* Drop unneeded dependency on dpkg (>= 1.15.4), stable has a newer version.
* Refresh patches.

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-2009 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 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.  */
34
41
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
35
42
#  define __attribute__(Spec) /* empty */
36
43
# endif
 
44
#endif
37
45
/* The attribute __pure__ was added in gcc 2.96.  */
38
 
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
39
 
#  define __pure__ /* empty */
40
 
# endif
41
 
#endif
42
 
 
43
 
 
44
 
/* The definition of GL_LINK_WARNING is copied here.  */
45
 
 
46
 
 
47
 
#ifdef __cplusplus
48
 
extern "C" {
49
 
#endif
 
46
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
 
47
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
 
48
#else
 
49
# define _GL_ATTRIBUTE_PURE /* empty */
 
50
#endif
 
51
 
 
52
 
 
53
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
54
 
 
55
/* The definition of _GL_ARG_NONNULL is copied here.  */
 
56
 
 
57
/* The definition of _GL_WARN_ON_USE is copied here.  */
50
58
 
51
59
 
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
 
65
#  endif
 
66
_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
 
67
                                  _GL_ATTRIBUTE_PURE
 
68
                                  _GL_ARG_NONNULL ((1)));
 
69
_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
 
70
# else
 
71
#  if ! @HAVE_MEMCHR@
 
72
_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
 
73
                                  _GL_ATTRIBUTE_PURE
 
74
                                  _GL_ARG_NONNULL ((1)));
 
75
#  endif
 
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));
56
82
# endif
57
 
# if @REPLACE_MEMCHR@
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));
 
88
# else
 
89
_GL_CXXALIASWARN (memchr);
60
90
# endif
61
91
#elif defined GNULIB_POSIXCHECK
62
92
# undef memchr
63
 
# define memchr(s,c,n) \
64
 
    (GL_LINK_WARNING ("memchr has platform-specific bugs - " \
65
 
                      "use gnulib module memchr for portability" ), \
66
 
     memchr (s, c, n))
 
93
/* Assume memchr is always declared.  */
 
94
_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
 
95
                 "use gnulib module memchr for portability" );
67
96
#endif
68
97
 
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
73
 
# endif
74
 
# if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
75
 
extern void *memmem (void const *__haystack, size_t __haystack_len,
76
 
                     void const *__needle, size_t __needle_len)
77
 
  __attribute__ ((__pure__));
78
 
# endif
 
101
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
102
#   define memmem rpl_memmem
 
103
#  endif
 
104
_GL_FUNCDECL_RPL (memmem, void *,
 
105
                  (void const *__haystack, size_t __haystack_len,
 
106
                   void const *__needle, size_t __needle_len)
 
107
                  _GL_ATTRIBUTE_PURE
 
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));
 
112
# else
 
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)
 
117
                  _GL_ATTRIBUTE_PURE
 
118
                  _GL_ARG_NONNULL ((1, 3)));
 
119
#  endif
 
120
_GL_CXXALIAS_SYS (memmem, void *,
 
121
                  (void const *__haystack, size_t __haystack_len,
 
122
                   void const *__needle, size_t __needle_len));
 
123
# endif
 
124
_GL_CXXALIASWARN (memmem);
79
125
#elif defined GNULIB_POSIXCHECK
80
126
# undef memmem
81
 
# define memmem(a,al,b,bl) \
82
 
    (GL_LINK_WARNING ("memmem is unportable and often quadratic - " \
83
 
                      "use gnulib module memmem-simple for portability, " \
84
 
                      "and module memmem for speed" ), \
85
 
     memmem (a, al, b, bl))
 
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" );
 
131
# endif
86
132
#endif
87
133
 
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,
93
 
                      size_t __n);
 
138
_GL_FUNCDECL_SYS (mempcpy, void *,
 
139
                  (void *restrict __dest, void const *restrict __src,
 
140
                   size_t __n)
 
141
                  _GL_ARG_NONNULL ((1, 2)));
94
142
# endif
 
143
_GL_CXXALIAS_SYS (mempcpy, void *,
 
144
                  (void *restrict __dest, void const *restrict __src,
 
145
                   size_t __n));
 
146
_GL_CXXALIASWARN (mempcpy);
95
147
#elif defined GNULIB_POSIXCHECK
96
148
# undef mempcpy
97
 
# define mempcpy(a,b,n) \
98
 
    (GL_LINK_WARNING ("mempcpy is unportable - " \
99
 
                      "use gnulib module mempcpy for portability"), \
100
 
     mempcpy (a, b, n))
 
149
# if HAVE_RAW_DECL_MEMPCPY
 
150
_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
 
151
                 "use gnulib module mempcpy for portability");
 
152
# endif
101
153
#endif
102
154
 
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)
 
159
                                   _GL_ATTRIBUTE_PURE
 
160
                                   _GL_ARG_NONNULL ((1)));
 
161
# endif
 
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));
 
172
# else
 
173
_GL_CXXALIASWARN (memrchr);
108
174
# endif
109
175
#elif defined GNULIB_POSIXCHECK
110
176
# undef memrchr
111
 
# define memrchr(a,b,c) \
112
 
    (GL_LINK_WARNING ("memrchr is unportable - " \
113
 
                      "use gnulib module memrchr for portability"), \
114
 
     memrchr (a, b, c))
 
177
# if HAVE_RAW_DECL_MEMRCHR
 
178
_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
 
179
                 "use gnulib module memrchr for portability");
 
180
# endif
115
181
#endif
116
182
 
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)
 
189
                                     _GL_ATTRIBUTE_PURE
 
190
                                     _GL_ARG_NONNULL ((1)));
 
191
# endif
 
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));
 
202
# else
 
203
_GL_CXXALIASWARN (rawmemchr);
124
204
# endif
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"), \
130
 
     rawmemchr (a, b))
 
207
# if HAVE_RAW_DECL_RAWMEMCHR
 
208
_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
 
209
                 "use gnulib module rawmemchr for portability");
 
210
# endif
131
211
#endif
132
212
 
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)));
137
219
# endif
 
220
_GL_CXXALIAS_SYS (stpcpy, char *,
 
221
                  (char *restrict __dst, char const *restrict __src));
 
222
_GL_CXXALIASWARN (stpcpy);
138
223
#elif defined GNULIB_POSIXCHECK
139
224
# undef stpcpy
140
 
# define stpcpy(a,b) \
141
 
    (GL_LINK_WARNING ("stpcpy is unportable - " \
142
 
                      "use gnulib module stpcpy for portability"), \
143
 
     stpcpy (a, b))
 
225
# if HAVE_RAW_DECL_STPCPY
 
226
_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
 
227
                 "use gnulib module stpcpy for portability");
 
228
# endif
144
229
#endif
145
230
 
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,
152
 
                      size_t __n);
 
234
# if @REPLACE_STPNCPY@
 
235
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
236
#   undef stpncpy
 
237
#   define stpncpy rpl_stpncpy
 
238
#  endif
 
239
_GL_FUNCDECL_RPL (stpncpy, char *,
 
240
                  (char *restrict __dst, char const *restrict __src,
 
241
                   size_t __n)
 
242
                  _GL_ARG_NONNULL ((1, 2)));
 
243
_GL_CXXALIAS_RPL (stpncpy, char *,
 
244
                  (char *restrict __dst, char const *restrict __src,
 
245
                   size_t __n));
 
246
# else
 
247
#  if ! @HAVE_STPNCPY@
 
248
_GL_FUNCDECL_SYS (stpncpy, char *,
 
249
                  (char *restrict __dst, char const *restrict __src,
 
250
                   size_t __n)
 
251
                  _GL_ARG_NONNULL ((1, 2)));
 
252
#  endif
 
253
_GL_CXXALIAS_SYS (stpncpy, char *,
 
254
                  (char *restrict __dst, char const *restrict __src,
 
255
                   size_t __n));
153
256
# endif
 
257
_GL_CXXALIASWARN (stpncpy);
154
258
#elif defined GNULIB_POSIXCHECK
155
259
# undef stpncpy
156
 
# define stpncpy(a,b,n) \
157
 
    (GL_LINK_WARNING ("stpncpy is unportable - " \
158
 
                      "use gnulib module stpncpy for portability"), \
159
 
     stpncpy (a, b, n))
 
260
# if HAVE_RAW_DECL_STPNCPY
 
261
_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
 
262
                 "use gnulib module stpncpy for portability");
 
263
# endif
160
264
#endif
161
265
 
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.  */
165
269
# undef strchr
166
 
# define strchr(s,c) \
167
 
    (GL_LINK_WARNING ("strchr cannot work correctly on character strings " \
168
 
                      "in some multibyte locales - " \
169
 
                      "use mbschr if you care about internationalization"), \
170
 
     strchr (s, c))
 
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");
171
274
#endif
172
275
 
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)
 
280
                                     _GL_ATTRIBUTE_PURE
 
281
                                     _GL_ARG_NONNULL ((1)));
 
282
# endif
 
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));
 
293
# else
 
294
_GL_CXXALIASWARN (strchrnul);
178
295
# endif
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"), \
184
 
     strchrnul (a, b))
 
298
# if HAVE_RAW_DECL_STRCHRNUL
 
299
_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
 
300
                 "use gnulib module strchrnul for portability");
 
301
# endif
185
302
#endif
186
303
 
187
304
/* Duplicate S, returning an identical malloc'd string.  */
188
305
#if @GNULIB_STRDUP@
189
306
# if @REPLACE_STRDUP@
190
 
#  undef strdup
191
 
#  define strdup rpl_strdup
192
 
# endif
193
 
# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
194
 
extern char *strdup (char const *__s);
195
 
# endif
 
307
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
308
#   undef strdup
 
309
#   define strdup rpl_strdup
 
310
#  endif
 
311
_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
 
312
_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
 
313
# else
 
314
#  if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
 
315
    /* strdup exists as a function and as a macro.  Get rid of the macro.  */
 
316
#   undef strdup
 
317
#  endif
 
318
#  if !(@HAVE_DECL_STRDUP@ || defined strdup)
 
319
_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
 
320
#  endif
 
321
_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
 
322
# endif
 
323
_GL_CXXALIASWARN (strdup);
196
324
#elif defined GNULIB_POSIXCHECK
197
325
# undef strdup
198
 
# define strdup(a) \
199
 
    (GL_LINK_WARNING ("strdup is unportable - " \
200
 
                      "use gnulib module strdup for portability"), \
201
 
     strdup (a))
 
326
# if HAVE_RAW_DECL_STRDUP
 
327
_GL_WARN_ON_USE (strdup, "strdup is unportable - "
 
328
                 "use gnulib module strdup for portability");
 
329
# endif
 
330
#endif
 
331
 
 
332
/* Append no more than N characters from SRC onto DEST.  */
 
333
#if @GNULIB_STRNCAT@
 
334
# if @REPLACE_STRNCAT@
 
335
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
336
#   undef strncat
 
337
#   define strncat rpl_strncat
 
338
#  endif
 
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));
 
342
# else
 
343
_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
 
344
# endif
 
345
_GL_CXXALIASWARN (strncat);
 
346
#elif defined GNULIB_POSIXCHECK
 
347
# undef strncat
 
348
# if HAVE_RAW_DECL_STRNCAT
 
349
_GL_WARN_ON_USE (strncat, "strncat is unportable - "
 
350
                 "use gnulib module strncat for portability");
 
351
# endif
202
352
#endif
203
353
 
204
354
/* Return a newly allocated copy of at most N bytes of STRING.  */
205
355
#if @GNULIB_STRNDUP@
206
 
# if ! @HAVE_STRNDUP@
207
 
#  undef strndup
208
 
#  define strndup rpl_strndup
209
 
# endif
210
 
# if ! @HAVE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
211
 
extern char *strndup (char const *__string, size_t __n);
212
 
# endif
 
356
# if @REPLACE_STRNDUP@
 
357
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
358
#   undef strndup
 
359
#   define strndup rpl_strndup
 
360
#  endif
 
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));
 
364
# else
 
365
#  if ! @HAVE_DECL_STRNDUP@
 
366
_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
 
367
                                   _GL_ARG_NONNULL ((1)));
 
368
#  endif
 
369
_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
 
370
# endif
 
371
_GL_CXXALIASWARN (strndup);
213
372
#elif defined GNULIB_POSIXCHECK
214
373
# undef strndup
215
 
# define strndup(a,n) \
216
 
    (GL_LINK_WARNING ("strndup is unportable - " \
217
 
                      "use gnulib module strndup for portability"), \
218
 
     strndup (a, n))
 
374
# if HAVE_RAW_DECL_STRNDUP
 
375
_GL_WARN_ON_USE (strndup, "strndup is unportable - "
 
376
                 "use gnulib module strndup for portability");
 
377
# endif
219
378
#endif
220
379
 
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)
 
386
#   undef strnlen
 
387
#   define strnlen rpl_strnlen
 
388
#  endif
 
389
_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
 
390
                                   _GL_ATTRIBUTE_PURE
 
391
                                   _GL_ARG_NONNULL ((1)));
 
392
_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
 
393
# else
 
394
#  if ! @HAVE_DECL_STRNLEN@
 
395
_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
 
396
                                   _GL_ATTRIBUTE_PURE
 
397
                                   _GL_ARG_NONNULL ((1)));
 
398
#  endif
 
399
_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
228
400
# endif
 
401
_GL_CXXALIASWARN (strnlen);
229
402
#elif defined GNULIB_POSIXCHECK
230
403
# undef strnlen
231
 
# define strnlen(a,n) \
232
 
    (GL_LINK_WARNING ("strnlen is unportable - " \
233
 
                      "use gnulib module strnlen for portability"), \
234
 
     strnlen (a, n))
 
404
# if HAVE_RAW_DECL_STRNLEN
 
405
_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
 
406
                 "use gnulib module strnlen for portability");
 
407
# endif
235
408
#endif
236
409
 
237
410
#if defined GNULIB_POSIXCHECK
240
413
   locale encoding is GB18030 and one of the characters to be searched is a
241
414
   digit.  */
242
415
# undef strcspn
243
 
# define strcspn(s,a) \
244
 
    (GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \
245
 
                      "in multibyte locales - " \
246
 
                      "use mbscspn if you care about internationalization"), \
247
 
     strcspn (s, a))
 
416
/* Assume strcspn is always declared.  */
 
417
_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
 
418
                 "in multibyte locales - "
 
419
                 "use mbscspn if you care about internationalization");
248
420
#endif
249
421
 
250
422
/* Find the first occurrence in S of any character in ACCEPT.  */
251
423
#if @GNULIB_STRPBRK@
252
424
# if ! @HAVE_STRPBRK@
253
 
extern char *strpbrk (char const *__s, char const *__accept)
254
 
  __attribute__ ((__pure__));
 
425
_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
 
426
                                   _GL_ATTRIBUTE_PURE
 
427
                                   _GL_ARG_NONNULL ((1, 2)));
 
428
# endif
 
429
  /* On some systems, this function is defined as an overloaded function:
 
430
       extern "C" { const char * strpbrk (const char *, const char *); }
 
431
       extern "C++" { char * strpbrk (char *, const char *); }  */
 
432
_GL_CXXALIAS_SYS_CAST2 (strpbrk,
 
433
                        char *, (char const *__s, char const *__accept),
 
434
                        const char *, (char const *__s, char const *__accept));
 
435
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
 
436
     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
 
437
_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
 
438
_GL_CXXALIASWARN1 (strpbrk, char const *,
 
439
                   (char const *__s, char const *__accept));
 
440
# else
 
441
_GL_CXXALIASWARN (strpbrk);
255
442
# endif
256
443
# if defined GNULIB_POSIXCHECK
257
444
/* strpbrk() assumes the second argument is a list of single-byte characters.
259
446
   locale encoding is GB18030 and one of the characters to be searched is a
260
447
   digit.  */
261
448
#  undef strpbrk
262
 
#  define strpbrk(s,a) \
263
 
     (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \
264
 
                       "in multibyte locales - " \
265
 
                       "use mbspbrk if you care about internationalization"), \
266
 
      strpbrk (s, a))
 
449
_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
 
450
                 "in multibyte locales - "
 
451
                 "use mbspbrk if you care about internationalization");
267
452
# endif
268
453
#elif defined GNULIB_POSIXCHECK
269
454
# undef strpbrk
270
 
# define strpbrk(s,a) \
271
 
    (GL_LINK_WARNING ("strpbrk is unportable - " \
272
 
                      "use gnulib module strpbrk for portability"), \
273
 
     strpbrk (s, a))
 
455
# if HAVE_RAW_DECL_STRPBRK
 
456
_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
 
457
                 "use gnulib module strpbrk for portability");
 
458
# endif
274
459
#endif
275
460
 
276
461
#if defined GNULIB_POSIXCHECK
277
462
/* strspn() assumes the second argument is a list of single-byte characters.
278
463
   Even in this simple case, it cannot work with multibyte strings.  */
279
464
# undef strspn
280
 
# define strspn(s,a) \
281
 
    (GL_LINK_WARNING ("strspn cannot work correctly on character strings " \
282
 
                      "in multibyte locales - " \
283
 
                      "use mbsspn if you care about internationalization"), \
284
 
     strspn (s, a))
 
465
/* Assume strspn is always declared.  */
 
466
_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
 
467
                 "in multibyte locales - "
 
468
                 "use mbsspn if you care about internationalization");
285
469
#endif
286
470
 
287
471
#if defined GNULIB_POSIXCHECK
288
472
/* strrchr() does not work with multibyte strings if the locale encoding is
289
473
   GB18030 and the character to be searched is a digit.  */
290
474
# undef strrchr
291
 
# define strrchr(s,c) \
292
 
    (GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \
293
 
                      "in some multibyte locales - " \
294
 
                      "use mbsrchr if you care about internationalization"), \
295
 
     strrchr (s, c))
 
475
/* Assume strrchr is always declared.  */
 
476
_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
 
477
                 "in some multibyte locales - "
 
478
                 "use mbsrchr if you care about internationalization");
296
479
#endif
297
480
 
298
481
/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
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)));
317
502
# endif
 
503
_GL_CXXALIAS_SYS (strsep, char *,
 
504
                  (char **restrict __stringp, char const *restrict __delim));
 
505
_GL_CXXALIASWARN (strsep);
318
506
# if defined GNULIB_POSIXCHECK
319
507
#  undef strsep
320
 
#  define strsep(s,d) \
321
 
     (GL_LINK_WARNING ("strsep cannot work correctly on character strings " \
322
 
                       "in multibyte locales - " \
323
 
                       "use mbssep if you care about internationalization"), \
324
 
      strsep (s, d))
 
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");
325
511
# endif
326
512
#elif defined GNULIB_POSIXCHECK
327
513
# undef strsep
328
 
# define strsep(s,d) \
329
 
    (GL_LINK_WARNING ("strsep is unportable - " \
330
 
                      "use gnulib module strsep for portability"), \
331
 
     strsep (s, d))
 
514
# if HAVE_RAW_DECL_STRSEP
 
515
_GL_WARN_ON_USE (strsep, "strsep is unportable - "
 
516
                 "use gnulib module strsep for portability");
 
517
# endif
332
518
#endif
333
519
 
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
 
524
#  endif
 
525
_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
 
526
                                  _GL_ATTRIBUTE_PURE
 
527
                                  _GL_ARG_NONNULL ((1, 2)));
 
528
_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
 
529
# else
 
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));
 
536
# endif
 
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));
 
542
# else
 
543
_GL_CXXALIASWARN (strstr);
339
544
# endif
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.  */
345
550
# undef strstr
346
 
# define strstr(a,b) \
347
 
    (GL_LINK_WARNING ("strstr is quadratic on many systems, and cannot " \
348
 
                      "work correctly on character strings in most "    \
349
 
                      "multibyte locales - " \
350
 
                      "use mbsstr if you care about internationalization, " \
351
 
                      "or use strstr if you care about speed"), \
352
 
     strstr (a, b))
 
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");
353
557
#endif
354
558
 
355
559
/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
356
560
   comparison.  */
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
 
565
#  endif
 
566
_GL_FUNCDECL_RPL (strcasestr, char *,
 
567
                  (const char *haystack, const char *needle)
 
568
                  _GL_ATTRIBUTE_PURE
 
569
                  _GL_ARG_NONNULL ((1, 2)));
 
570
_GL_CXXALIAS_RPL (strcasestr, char *,
 
571
                  (const char *haystack, const char *needle));
 
572
# else
 
573
#  if ! @HAVE_STRCASESTR@
 
574
_GL_FUNCDECL_SYS (strcasestr, char *,
 
575
                  (const char *haystack, const char *needle)
 
576
                  _GL_ATTRIBUTE_PURE
 
577
                  _GL_ARG_NONNULL ((1, 2)));
 
578
#  endif
 
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));
360
585
# endif
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));
 
591
# else
 
592
_GL_CXXALIASWARN (strcasestr);
364
593
# endif
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
368
597
   locales.  */
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"), \
376
 
     strcasestr (a, b))
 
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");
 
605
# endif
377
606
#endif
378
607
 
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";
383
 
        char *sp;
384
 
        x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
385
 
        x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
386
 
        x = strtok_r(NULL, "=", &sp);   // x = NULL
387
 
                // s = "abc\0-def\0"
 
611
        char s[] = "-abc-=-def";
 
612
        char *sp;
 
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
 
616
                // s = "abc\0-def\0"
388
617
 
389
618
   This is a variant of strtok() that is multithread-safe.
390
619
 
399
628
 
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)
 
633
#   undef strtok_r
 
634
#   define strtok_r rpl_strtok_r
 
635
#  endif
 
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));
 
643
# else
 
644
#  if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
 
645
#   undef strtok_r
 
646
#  endif
 
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)));
 
652
#  endif
 
653
_GL_CXXALIAS_SYS (strtok_r, char *,
 
654
                  (char *restrict s, char const *restrict delim,
 
655
                   char **restrict save_ptr));
405
656
# endif
 
657
_GL_CXXALIASWARN (strtok_r);
406
658
# if defined GNULIB_POSIXCHECK
407
 
#  undef strtok_r
408
 
#  define strtok_r(s,d,p) \
409
 
     (GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \
410
 
                       "in multibyte locales - " \
411
 
                       "use mbstok_r if you care about internationalization"), \
412
 
      strtok_r (s, d, p))
 
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");
413
662
# endif
414
663
#elif defined GNULIB_POSIXCHECK
415
664
# undef strtok_r
416
 
# define strtok_r(s,d,p) \
417
 
    (GL_LINK_WARNING ("strtok_r is unportable - " \
418
 
                      "use gnulib module strtok_r for portability"), \
419
 
     strtok_r (s, d, p))
 
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");
 
668
# endif
420
669
#endif
421
670
 
422
671
 
426
675
#if @GNULIB_MBSLEN@
427
676
/* Return the number of multibyte characters in the character string STRING.
428
677
   This considers multibyte characters, unlike strlen, which counts bytes.  */
429
 
extern size_t mbslen (const char *string);
 
678
# ifdef __MirBSD__  /* MirBSD defines mbslen as a macro.  Override it.  */
 
679
#  undef mbslen
 
680
# endif
 
681
# if @HAVE_MBSLEN@  /* AIX, OSF/1, MirBSD define mbslen already in libc.  */
 
682
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
683
#   define mbslen rpl_mbslen
 
684
#  endif
 
685
_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
 
686
_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
 
687
# else
 
688
_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
 
689
_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
 
690
# endif
 
691
_GL_CXXALIASWARN (mbslen);
430
692
#endif
431
693
 
432
694
#if @GNULIB_MBSNLEN@
433
695
/* Return the number of multibyte characters in the character string starting
434
696
   at STRING and ending at STRING + LEN.  */
435
 
extern size_t mbsnlen (const char *string, size_t len);
 
697
_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
 
698
     _GL_ARG_NONNULL ((1));
436
699
#endif
437
700
 
438
701
#if @GNULIB_MBSCHR@
440
703
   and return a pointer to it.  Return NULL if C is not found in STRING.
441
704
   Unlike strchr(), this function works correctly in multibyte locales with
442
705
   encodings such as GB18030.  */
443
 
# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
444
 
extern char * mbschr (const char *string, int c);
 
706
# if defined __hpux
 
707
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
708
#   define mbschr rpl_mbschr /* avoid collision with HP-UX function */
 
709
#  endif
 
710
_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
 
711
                                  _GL_ARG_NONNULL ((1)));
 
712
_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
 
713
# else
 
714
_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
 
715
                                  _GL_ARG_NONNULL ((1)));
 
716
_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
 
717
# endif
 
718
_GL_CXXALIASWARN (mbschr);
445
719
#endif
446
720
 
447
721
#if @GNULIB_MBSRCHR@
449
723
   and return a pointer to it.  Return NULL if C is not found in STRING.
450
724
   Unlike strrchr(), this function works correctly in multibyte locales with
451
725
   encodings such as GB18030.  */
452
 
# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
453
 
extern char * mbsrchr (const char *string, int c);
 
726
# if defined __hpux
 
727
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
728
#   define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
 
729
#  endif
 
730
_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
 
731
                                   _GL_ARG_NONNULL ((1)));
 
732
_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
 
733
# else
 
734
_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
 
735
                                   _GL_ARG_NONNULL ((1)));
 
736
_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
 
737
# endif
 
738
_GL_CXXALIASWARN (mbsrchr);
454
739
#endif
455
740
 
456
741
#if @GNULIB_MBSSTR@
458
743
   string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
459
744
   Unlike strstr(), this function works correctly in multibyte locales with
460
745
   encodings different from UTF-8.  */
461
 
extern char * mbsstr (const char *haystack, const char *needle);
 
746
_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
 
747
     _GL_ARG_NONNULL ((1, 2));
462
748
#endif
463
749
 
464
750
#if @GNULIB_MBSCASECMP@
468
754
   Note: This function may, in multibyte locales, return 0 for strings of
469
755
   different lengths!
470
756
   Unlike strcasecmp(), this function works correctly in multibyte locales.  */
471
 
extern int mbscasecmp (const char *s1, const char *s2);
 
757
_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
 
758
     _GL_ARG_NONNULL ((1, 2));
472
759
#endif
473
760
 
474
761
#if @GNULIB_MBSNCASECMP@
481
768
   of different lengths!
482
769
   Unlike strncasecmp(), this function works correctly in multibyte locales.
483
770
   But beware that N is not a byte count but a character count!  */
484
 
extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
 
771
_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
 
772
     _GL_ARG_NONNULL ((1, 2));
485
773
#endif
486
774
 
487
775
#if @GNULIB_MBSPCASECMP@
488
776
/* Compare the initial segment of the character string STRING consisting of
489
777
   at most mbslen (PREFIX) characters with the character string PREFIX,
490
 
   ignoring case, returning less than, equal to or greater than zero if this
491
 
   initial segment is lexicographically less than, equal to or greater than
492
 
   PREFIX.
493
 
   Note: This function may, in multibyte locales, return 0 if STRING is of
494
 
   smaller length than PREFIX!
 
778
   ignoring case.  If the two match, return a pointer to the first byte
 
779
   after this prefix in STRING.  Otherwise, return NULL.
 
780
   Note: This function may, in multibyte locales, return non-NULL if STRING
 
781
   is of smaller length than PREFIX!
495
782
   Unlike strncasecmp(), this function works correctly in multibyte
496
783
   locales.  */
497
 
extern char * mbspcasecmp (const char *string, const char *prefix);
 
784
_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
 
785
     _GL_ARG_NONNULL ((1, 2));
498
786
#endif
499
787
 
500
788
#if @GNULIB_MBSCASESTR@
503
791
   Note: This function may, in multibyte locales, return success even if
504
792
   strlen (haystack) < strlen (needle) !
505
793
   Unlike strcasestr(), this function works correctly in multibyte locales.  */
506
 
extern char * mbscasestr (const char *haystack, const char *needle);
 
794
_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
 
795
     _GL_ARG_NONNULL ((1, 2));
507
796
#endif
508
797
 
509
798
#if @GNULIB_MBSCSPN@
512
801
   beginning of the string to this occurrence, or to the end of the string
513
802
   if none exists.
514
803
   Unlike strcspn(), this function works correctly in multibyte locales.  */
515
 
extern size_t mbscspn (const char *string, const char *accept);
 
804
_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
 
805
     _GL_ARG_NONNULL ((1, 2));
516
806
#endif
517
807
 
518
808
#if @GNULIB_MBSPBRK@
520
810
   in the character string ACCEPT.  Return the pointer to it, or NULL if none
521
811
   exists.
522
812
   Unlike strpbrk(), this function works correctly in multibyte locales.  */
523
 
# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
524
 
extern char * mbspbrk (const char *string, const char *accept);
 
813
# if defined __hpux
 
814
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
815
#   define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
 
816
#  endif
 
817
_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
 
818
                                   _GL_ARG_NONNULL ((1, 2)));
 
819
_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
 
820
# else
 
821
_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
 
822
                                   _GL_ARG_NONNULL ((1, 2)));
 
823
_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
 
824
# endif
 
825
_GL_CXXALIASWARN (mbspbrk);
525
826
#endif
526
827
 
527
828
#if @GNULIB_MBSSPN@
530
831
   beginning of the string to this occurrence, or to the end of the string
531
832
   if none exists.
532
833
   Unlike strspn(), this function works correctly in multibyte locales.  */
533
 
extern size_t mbsspn (const char *string, const char *reject);
 
834
_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
 
835
     _GL_ARG_NONNULL ((1, 2));
534
836
#endif
535
837
 
536
838
#if @GNULIB_MBSSEP@
548
850
   Caveat: The identity of the delimiting character is lost.
549
851
 
550
852
   See also mbstok_r().  */
551
 
extern char * mbssep (char **stringp, const char *delim);
 
853
_GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
 
854
     _GL_ARG_NONNULL ((1, 2));
552
855
#endif
553
856
 
554
857
#if @GNULIB_MBSTOK_R@
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";
560
 
        char *sp;
561
 
        x = mbstok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
562
 
        x = mbstok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
563
 
        x = mbstok_r(NULL, "=", &sp);   // x = NULL
564
 
                // s = "abc\0-def\0"
 
862
        char s[] = "-abc-=-def";
 
863
        char *sp;
 
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
 
867
                // s = "abc\0-def\0"
565
868
 
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.
569
872
 
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));
572
876
#endif
573
877
 
574
878
/* Map any int, typically from errno, into an error message.  */
575
879
#if @GNULIB_STRERROR@
576
880
# if @REPLACE_STRERROR@
577
 
#  undef strerror
578
 
#  define strerror rpl_strerror
579
 
extern char *strerror (int);
 
881
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
882
#   undef strerror
 
883
#   define strerror rpl_strerror
 
884
#  endif
 
885
_GL_FUNCDECL_RPL (strerror, char *, (int));
 
886
_GL_CXXALIAS_RPL (strerror, char *, (int));
 
887
# else
 
888
_GL_CXXALIAS_SYS (strerror, char *, (int));
580
889
# endif
 
890
_GL_CXXALIASWARN (strerror);
581
891
#elif defined GNULIB_POSIXCHECK
582
892
# undef strerror
583
 
# define strerror(e) \
584
 
    (GL_LINK_WARNING ("strerror is unportable - " \
585
 
                      "use gnulib module strerror to guarantee non-NULL result"), \
586
 
     strerror (e))
 
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");
587
896
#endif
588
897
 
589
898
#if @GNULIB_STRSIGNAL@
590
899
# if @REPLACE_STRSIGNAL@
591
 
#  define strsignal rpl_strsignal
592
 
# endif
593
 
# if ! @HAVE_DECL_STRSIGNAL@ || @REPLACE_STRSIGNAL@
594
 
extern char *strsignal (int __sig);
595
 
# endif
 
900
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
901
#   define strsignal rpl_strsignal
 
902
#  endif
 
903
_GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
 
904
_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
 
905
# else
 
906
#  if ! @HAVE_DECL_STRSIGNAL@
 
907
_GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
 
908
#  endif
 
909
/* Need to cast, because on Cygwin 1.5.x systems, the return type is
 
910
   'const char *'.  */
 
911
_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
 
912
# endif
 
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"), \
601
 
     strsignal (a))
 
916
# if HAVE_RAW_DECL_STRSIGNAL
 
917
_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
 
918
                 "use gnulib module strsignal for portability");
 
919
# endif
602
920
#endif
603
921
 
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)));
607
926
# endif
 
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"), \
613
 
     strverscmp (a, b))
614
 
#endif
615
 
 
616
 
 
617
 
#ifdef __cplusplus
618
 
}
619
 
#endif
 
931
# if HAVE_RAW_DECL_STRVERSCMP
 
932
_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
 
933
                 "use gnulib module strverscmp for portability");
 
934
# endif
 
935
#endif
 
936
 
620
937
 
621
938
#endif /* _GL_STRING_H */
622
939
#endif /* _GL_STRING_H */