Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / gnu / usr.bin / diff / libdiffutils / string.h
1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* -*- buffer-read-only: t -*- vi: set ro: */
3 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
4 /* A GNU-like <string.h>.
5
6    Copyright (C) 1995-1996, 2001-2011 Free Software Foundation, Inc.
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3, or (at your option)
11    any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software Foundation,
20    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
21
22 #ifndef _GL_STRING_H
23
24 #if __GNUC__ >= 3
25 #pragma GCC system_header
26 #endif
27
28
29 /* The include_next requires a split double-inclusion guard.  */
30 #include_next <string.h>
31
32 #ifndef _GL_STRING_H
33 #define _GL_STRING_H
34
35 /* NetBSD 5.0 mis-defines NULL.  */
36 #include <stddef.h>
37
38 /* MirBSD defines mbslen as a macro.  */
39 #if 1 && defined __MirBSD__
40 # include <wchar.h>
41 #endif
42
43 /* The __attribute__ feature is available in gcc versions 2.5 and later.
44    The attribute __pure__ was added in gcc 2.96.  */
45 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
46 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
47 #else
48 # define _GL_ATTRIBUTE_PURE /* empty */
49 #endif
50
51 /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>.  */
52 /* But in any case avoid namespace pollution on glibc systems.  */
53 #if (0 || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
54     && ! defined __GLIBC__
55 # include <unistd.h>
56 #endif
57
58 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
59 #ifndef _GL_CXXDEFS_H
60 #define _GL_CXXDEFS_H
61
62 /* The three most frequent use cases of these macros are:
63
64    * For providing a substitute for a function that is missing on some
65      platforms, but is declared and works fine on the platforms on which
66      it exists:
67
68        #if @GNULIB_FOO@
69        # if !@HAVE_FOO@
70        _GL_FUNCDECL_SYS (foo, ...);
71        # endif
72        _GL_CXXALIAS_SYS (foo, ...);
73        _GL_CXXALIASWARN (foo);
74        #elif defined GNULIB_POSIXCHECK
75        ...
76        #endif
77
78    * For providing a replacement for a function that exists on all platforms,
79      but is broken/insufficient and needs to be replaced on some platforms:
80
81        #if @GNULIB_FOO@
82        # if @REPLACE_FOO@
83        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
84        #   undef foo
85        #   define foo rpl_foo
86        #  endif
87        _GL_FUNCDECL_RPL (foo, ...);
88        _GL_CXXALIAS_RPL (foo, ...);
89        # else
90        _GL_CXXALIAS_SYS (foo, ...);
91        # endif
92        _GL_CXXALIASWARN (foo);
93        #elif defined GNULIB_POSIXCHECK
94        ...
95        #endif
96
97    * For providing a replacement for a function that exists on some platforms
98      but is broken/insufficient and needs to be replaced on some of them and
99      is additionally either missing or undeclared on some other platforms:
100
101        #if @GNULIB_FOO@
102        # if @REPLACE_FOO@
103        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
104        #   undef foo
105        #   define foo rpl_foo
106        #  endif
107        _GL_FUNCDECL_RPL (foo, ...);
108        _GL_CXXALIAS_RPL (foo, ...);
109        # else
110        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
111        _GL_FUNCDECL_SYS (foo, ...);
112        #  endif
113        _GL_CXXALIAS_SYS (foo, ...);
114        # endif
115        _GL_CXXALIASWARN (foo);
116        #elif defined GNULIB_POSIXCHECK
117        ...
118        #endif
119 */
120
121 /* _GL_EXTERN_C declaration;
122    performs the declaration with C linkage.  */
123 #if defined __cplusplus
124 # define _GL_EXTERN_C extern "C"
125 #else
126 # define _GL_EXTERN_C extern
127 #endif
128
129 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
130    declares a replacement function, named rpl_func, with the given prototype,
131    consisting of return type, parameters, and attributes.
132    Example:
133      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
134                                   _GL_ARG_NONNULL ((1)));
135  */
136 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
137   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
138 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
139   _GL_EXTERN_C rettype rpl_func parameters_and_attributes
140
141 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
142    declares the system function, named func, with the given prototype,
143    consisting of return type, parameters, and attributes.
144    Example:
145      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
146                                   _GL_ARG_NONNULL ((1)));
147  */
148 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
149   _GL_EXTERN_C rettype func parameters_and_attributes
150
151 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
152    declares a C++ alias called GNULIB_NAMESPACE::func
153    that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
154    Example:
155      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
156  */
157 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
158   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
159 #if defined __cplusplus && defined GNULIB_NAMESPACE
160 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
161     namespace GNULIB_NAMESPACE                                \
162     {                                                         \
163       rettype (*const func) parameters = ::rpl_func;          \
164     }                                                         \
165     _GL_EXTERN_C int _gl_cxxalias_dummy
166 #else
167 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
168     _GL_EXTERN_C int _gl_cxxalias_dummy
169 #endif
170
171 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
172    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
173    except that the C function rpl_func may have a slightly different
174    declaration.  A cast is used to silence the "invalid conversion" error
175    that would otherwise occur.  */
176 #if defined __cplusplus && defined GNULIB_NAMESPACE
177 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
178     namespace GNULIB_NAMESPACE                                     \
179     {                                                              \
180       rettype (*const func) parameters =                           \
181         reinterpret_cast<rettype(*)parameters>(::rpl_func);        \
182     }                                                              \
183     _GL_EXTERN_C int _gl_cxxalias_dummy
184 #else
185 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
186     _GL_EXTERN_C int _gl_cxxalias_dummy
187 #endif
188
189 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
190    declares a C++ alias called GNULIB_NAMESPACE::func
191    that redirects to the system provided function func, if GNULIB_NAMESPACE
192    is defined.
193    Example:
194      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
195  */
196 #if defined __cplusplus && defined GNULIB_NAMESPACE
197   /* If we were to write
198        rettype (*const func) parameters = ::func;
199      like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
200      better (remove an indirection through a 'static' pointer variable),
201      but then the _GL_CXXALIASWARN macro below would cause a warning not only
202      for uses of ::func but also for uses of GNULIB_NAMESPACE::func.  */
203 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
204     namespace GNULIB_NAMESPACE                     \
205     {                                              \
206       static rettype (*func) parameters = ::func;  \
207     }                                              \
208     _GL_EXTERN_C int _gl_cxxalias_dummy
209 #else
210 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
211     _GL_EXTERN_C int _gl_cxxalias_dummy
212 #endif
213
214 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
215    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
216    except that the C function func may have a slightly different declaration.
217    A cast is used to silence the "invalid conversion" error that would
218    otherwise occur.  */
219 #if defined __cplusplus && defined GNULIB_NAMESPACE
220 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
221     namespace GNULIB_NAMESPACE                          \
222     {                                                   \
223       static rettype (*func) parameters =               \
224         reinterpret_cast<rettype(*)parameters>(::func); \
225     }                                                   \
226     _GL_EXTERN_C int _gl_cxxalias_dummy
227 #else
228 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
229     _GL_EXTERN_C int _gl_cxxalias_dummy
230 #endif
231
232 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
233    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
234    except that the C function is picked among a set of overloaded functions,
235    namely the one with rettype2 and parameters2.  Two consecutive casts
236    are used to silence the "cannot find a match" and "invalid conversion"
237    errors that would otherwise occur.  */
238 #if defined __cplusplus && defined GNULIB_NAMESPACE
239   /* The outer cast must be a reinterpret_cast.
240      The inner cast: When the function is defined as a set of overloaded
241      functions, it works as a static_cast<>, choosing the designated variant.
242      When the function is defined as a single variant, it works as a
243      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
244 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
245     namespace GNULIB_NAMESPACE                                                \
246     {                                                                         \
247       static rettype (*func) parameters =                                     \
248         reinterpret_cast<rettype(*)parameters>(                               \
249           (rettype2(*)parameters2)(::func));                                  \
250     }                                                                         \
251     _GL_EXTERN_C int _gl_cxxalias_dummy
252 #else
253 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
254     _GL_EXTERN_C int _gl_cxxalias_dummy
255 #endif
256
257 /* _GL_CXXALIASWARN (func);
258    causes a warning to be emitted when ::func is used but not when
259    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
260    variants.  */
261 #if defined __cplusplus && defined GNULIB_NAMESPACE
262 # define _GL_CXXALIASWARN(func) \
263    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
264 # define _GL_CXXALIASWARN_1(func,namespace) \
265    _GL_CXXALIASWARN_2 (func, namespace)
266 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
267    we enable the warning only when not optimizing.  */
268 # if !__OPTIMIZE__
269 #  define _GL_CXXALIASWARN_2(func,namespace) \
270     _GL_WARN_ON_USE (func, \
271                      "The symbol ::" #func " refers to the system function. " \
272                      "Use " #namespace "::" #func " instead.")
273 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
274 #  define _GL_CXXALIASWARN_2(func,namespace) \
275      extern __typeof__ (func) func
276 # else
277 #  define _GL_CXXALIASWARN_2(func,namespace) \
278      _GL_EXTERN_C int _gl_cxxalias_dummy
279 # endif
280 #else
281 # define _GL_CXXALIASWARN(func) \
282     _GL_EXTERN_C int _gl_cxxalias_dummy
283 #endif
284
285 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
286    causes a warning to be emitted when the given overloaded variant of ::func
287    is used but not when GNULIB_NAMESPACE::func is used.  */
288 #if defined __cplusplus && defined GNULIB_NAMESPACE
289 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
290    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
291                         GNULIB_NAMESPACE)
292 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
293    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
294 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
295    we enable the warning only when not optimizing.  */
296 # if !__OPTIMIZE__
297 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
298     _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
299                          "The symbol ::" #func " refers to the system function. " \
300                          "Use " #namespace "::" #func " instead.")
301 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
302 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
303      extern __typeof__ (func) func
304 # else
305 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
306      _GL_EXTERN_C int _gl_cxxalias_dummy
307 # endif
308 #else
309 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
310     _GL_EXTERN_C int _gl_cxxalias_dummy
311 #endif
312
313 #endif /* _GL_CXXDEFS_H */
314
315 /* The definition of _GL_ARG_NONNULL is copied here.  */
316 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
317    that the values passed as arguments n, ..., m must be non-NULL pointers.
318    n = 1 stands for the first argument, n = 2 for the second argument etc.  */
319 #ifndef _GL_ARG_NONNULL
320 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
321 #  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
322 # else
323 #  define _GL_ARG_NONNULL(params)
324 # endif
325 #endif
326
327 /* The definition of _GL_WARN_ON_USE is copied here.  */
328 #ifndef _GL_WARN_ON_USE
329
330 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
331 /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
332 #  define _GL_WARN_ON_USE(function, message) \
333 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
334 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
335 /* Verify the existence of the function.  */
336 #  define _GL_WARN_ON_USE(function, message) \
337 extern __typeof__ (function) function
338 # else /* Unsupported.  */
339 #  define _GL_WARN_ON_USE(function, message) \
340 _GL_WARN_EXTERN_C int _gl_warn_on_use
341 # endif
342 #endif
343
344 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
345    is like _GL_WARN_ON_USE (function, "string"), except that the function is
346    declared with the given prototype, consisting of return type, parameters,
347    and attributes.
348    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
349    not work in this case.  */
350 #ifndef _GL_WARN_ON_USE_CXX
351 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
352 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
353 extern rettype function parameters_and_attributes \
354      __attribute__ ((__warning__ (msg)))
355 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
356 /* Verify the existence of the function.  */
357 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
358 extern rettype function parameters_and_attributes
359 # else /* Unsupported.  */
360 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
361 _GL_WARN_EXTERN_C int _gl_warn_on_use
362 # endif
363 #endif
364
365 /* _GL_WARN_EXTERN_C declaration;
366    performs the declaration with C linkage.  */
367 #ifndef _GL_WARN_EXTERN_C
368 # if defined __cplusplus
369 #  define _GL_WARN_EXTERN_C extern "C"
370 # else
371 #  define _GL_WARN_EXTERN_C extern
372 # endif
373 #endif
374
375
376 /* Find the index of the least-significant set bit.  */
377 #if 0
378 # if !1
379 _GL_FUNCDECL_SYS (ffsl, int, (long int i));
380 # endif
381 _GL_CXXALIAS_SYS (ffsl, int, (long int i));
382 _GL_CXXALIASWARN (ffsl);
383 #elif defined GNULIB_POSIXCHECK
384 # undef ffsl
385 # if HAVE_RAW_DECL_FFSL
386 _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
387 # endif
388 #endif
389
390
391 /* Find the index of the least-significant set bit.  */
392 #if 0
393 # if !1
394 _GL_FUNCDECL_SYS (ffsll, int, (long long int i));
395 # endif
396 _GL_CXXALIAS_SYS (ffsll, int, (long long int i));
397 _GL_CXXALIASWARN (ffsll);
398 #elif defined GNULIB_POSIXCHECK
399 # undef ffsll
400 # if HAVE_RAW_DECL_FFSLL
401 _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
402 # endif
403 #endif
404
405
406 /* Return the first instance of C within N bytes of S, or NULL.  */
407 #if 1
408 # if 0
409 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
410 #   define memchr rpl_memchr
411 #  endif
412 _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
413                                   _GL_ATTRIBUTE_PURE
414                                   _GL_ARG_NONNULL ((1)));
415 _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
416 # else
417 #  if ! 1
418 _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
419                                   _GL_ATTRIBUTE_PURE
420                                   _GL_ARG_NONNULL ((1)));
421 #  endif
422   /* On some systems, this function is defined as an overloaded function:
423        extern "C" { const void * std::memchr (const void *, int, size_t); }
424        extern "C++" { void * std::memchr (void *, int, size_t); }  */
425 _GL_CXXALIAS_SYS_CAST2 (memchr,
426                         void *, (void const *__s, int __c, size_t __n),
427                         void const *, (void const *__s, int __c, size_t __n));
428 # endif
429 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
430      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
431 _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
432 _GL_CXXALIASWARN1 (memchr, void const *,
433                    (void const *__s, int __c, size_t __n));
434 # else
435 _GL_CXXALIASWARN (memchr);
436 # endif
437 #elif defined GNULIB_POSIXCHECK
438 # undef memchr
439 /* Assume memchr is always declared.  */
440 _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
441                  "use gnulib module memchr for portability" );
442 #endif
443
444 /* Return the first occurrence of NEEDLE in HAYSTACK.  */
445 #if 0
446 # if 0
447 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
448 #   define memmem rpl_memmem
449 #  endif
450 _GL_FUNCDECL_RPL (memmem, void *,
451                   (void const *__haystack, size_t __haystack_len,
452                    void const *__needle, size_t __needle_len)
453                   _GL_ATTRIBUTE_PURE
454                   _GL_ARG_NONNULL ((1, 3)));
455 _GL_CXXALIAS_RPL (memmem, void *,
456                   (void const *__haystack, size_t __haystack_len,
457                    void const *__needle, size_t __needle_len));
458 # else
459 #  if ! 1
460 _GL_FUNCDECL_SYS (memmem, void *,
461                   (void const *__haystack, size_t __haystack_len,
462                    void const *__needle, size_t __needle_len)
463                   _GL_ATTRIBUTE_PURE
464                   _GL_ARG_NONNULL ((1, 3)));
465 #  endif
466 _GL_CXXALIAS_SYS (memmem, void *,
467                   (void const *__haystack, size_t __haystack_len,
468                    void const *__needle, size_t __needle_len));
469 # endif
470 _GL_CXXALIASWARN (memmem);
471 #elif defined GNULIB_POSIXCHECK
472 # undef memmem
473 # if HAVE_RAW_DECL_MEMMEM
474 _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
475                  "use gnulib module memmem-simple for portability, "
476                  "and module memmem for speed" );
477 # endif
478 #endif
479
480 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
481    last written byte.  */
482 #if 0
483 # if ! 1
484 _GL_FUNCDECL_SYS (mempcpy, void *,
485                   (void *restrict __dest, void const *restrict __src,
486                    size_t __n)
487                   _GL_ARG_NONNULL ((1, 2)));
488 # endif
489 _GL_CXXALIAS_SYS (mempcpy, void *,
490                   (void *restrict __dest, void const *restrict __src,
491                    size_t __n));
492 _GL_CXXALIASWARN (mempcpy);
493 #elif defined GNULIB_POSIXCHECK
494 # undef mempcpy
495 # if HAVE_RAW_DECL_MEMPCPY
496 _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
497                  "use gnulib module mempcpy for portability");
498 # endif
499 #endif
500
501 /* Search backwards through a block for a byte (specified as an int).  */
502 #if 0
503 # if ! 1
504 _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
505                                    _GL_ATTRIBUTE_PURE
506                                    _GL_ARG_NONNULL ((1)));
507 # endif
508   /* On some systems, this function is defined as an overloaded function:
509        extern "C++" { const void * std::memrchr (const void *, int, size_t); }
510        extern "C++" { void * std::memrchr (void *, int, size_t); }  */
511 _GL_CXXALIAS_SYS_CAST2 (memrchr,
512                         void *, (void const *, int, size_t),
513                         void const *, (void const *, int, size_t));
514 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
515      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
516 _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
517 _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
518 # else
519 _GL_CXXALIASWARN (memrchr);
520 # endif
521 #elif defined GNULIB_POSIXCHECK
522 # undef memrchr
523 # if HAVE_RAW_DECL_MEMRCHR
524 _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
525                  "use gnulib module memrchr for portability");
526 # endif
527 #endif
528
529 /* Find the first occurrence of C in S.  More efficient than
530    memchr(S,C,N), at the expense of undefined behavior if C does not
531    occur within N bytes.  */
532 #if 0
533 # if ! 1
534 _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
535                                      _GL_ATTRIBUTE_PURE
536                                      _GL_ARG_NONNULL ((1)));
537 # endif
538   /* On some systems, this function is defined as an overloaded function:
539        extern "C++" { const void * std::rawmemchr (const void *, int); }
540        extern "C++" { void * std::rawmemchr (void *, int); }  */
541 _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
542                         void *, (void const *__s, int __c_in),
543                         void const *, (void const *__s, int __c_in));
544 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
545      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
546 _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
547 _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
548 # else
549 _GL_CXXALIASWARN (rawmemchr);
550 # endif
551 #elif defined GNULIB_POSIXCHECK
552 # undef rawmemchr
553 # if HAVE_RAW_DECL_RAWMEMCHR
554 _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
555                  "use gnulib module rawmemchr for portability");
556 # endif
557 #endif
558
559 /* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
560 #if 0
561 # if ! 1
562 _GL_FUNCDECL_SYS (stpcpy, char *,
563                   (char *restrict __dst, char const *restrict __src)
564                   _GL_ARG_NONNULL ((1, 2)));
565 # endif
566 _GL_CXXALIAS_SYS (stpcpy, char *,
567                   (char *restrict __dst, char const *restrict __src));
568 _GL_CXXALIASWARN (stpcpy);
569 #elif defined GNULIB_POSIXCHECK
570 # undef stpcpy
571 # if HAVE_RAW_DECL_STPCPY
572 _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
573                  "use gnulib module stpcpy for portability");
574 # endif
575 #endif
576
577 /* Copy no more than N bytes of SRC to DST, returning a pointer past the
578    last non-NUL byte written into DST.  */
579 #if 0
580 # if 0
581 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
582 #   undef stpncpy
583 #   define stpncpy rpl_stpncpy
584 #  endif
585 _GL_FUNCDECL_RPL (stpncpy, char *,
586                   (char *restrict __dst, char const *restrict __src,
587                    size_t __n)
588                   _GL_ARG_NONNULL ((1, 2)));
589 _GL_CXXALIAS_RPL (stpncpy, char *,
590                   (char *restrict __dst, char const *restrict __src,
591                    size_t __n));
592 # else
593 #  if ! 1
594 _GL_FUNCDECL_SYS (stpncpy, char *,
595                   (char *restrict __dst, char const *restrict __src,
596                    size_t __n)
597                   _GL_ARG_NONNULL ((1, 2)));
598 #  endif
599 _GL_CXXALIAS_SYS (stpncpy, char *,
600                   (char *restrict __dst, char const *restrict __src,
601                    size_t __n));
602 # endif
603 _GL_CXXALIASWARN (stpncpy);
604 #elif defined GNULIB_POSIXCHECK
605 # undef stpncpy
606 # if HAVE_RAW_DECL_STPNCPY
607 _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
608                  "use gnulib module stpncpy for portability");
609 # endif
610 #endif
611
612 #if defined GNULIB_POSIXCHECK
613 /* strchr() does not work with multibyte strings if the locale encoding is
614    GB18030 and the character to be searched is a digit.  */
615 # undef strchr
616 /* Assume strchr is always declared.  */
617 _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
618                  "in some multibyte locales - "
619                  "use mbschr if you care about internationalization");
620 #endif
621
622 /* Find the first occurrence of C in S or the final NUL byte.  */
623 #if 0
624 # if 0
625 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
626 #   define strchrnul rpl_strchrnul
627 #  endif
628 _GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
629                                      _GL_ATTRIBUTE_PURE
630                                      _GL_ARG_NONNULL ((1)));
631 _GL_CXXALIAS_RPL (strchrnul, char *,
632                   (const char *str, int ch));
633 # else
634 #  if ! 1
635 _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
636                                      _GL_ATTRIBUTE_PURE
637                                      _GL_ARG_NONNULL ((1)));
638 #  endif
639   /* On some systems, this function is defined as an overloaded function:
640        extern "C++" { const char * std::strchrnul (const char *, int); }
641        extern "C++" { char * std::strchrnul (char *, int); }  */
642 _GL_CXXALIAS_SYS_CAST2 (strchrnul,
643                         char *, (char const *__s, int __c_in),
644                         char const *, (char const *__s, int __c_in));
645 # endif
646 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
647      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
648 _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
649 _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
650 # else
651 _GL_CXXALIASWARN (strchrnul);
652 # endif
653 #elif defined GNULIB_POSIXCHECK
654 # undef strchrnul
655 # if HAVE_RAW_DECL_STRCHRNUL
656 _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
657                  "use gnulib module strchrnul for portability");
658 # endif
659 #endif
660
661 /* Duplicate S, returning an identical malloc'd string.  */
662 #if 0
663 # if 0
664 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
665 #   undef strdup
666 #   define strdup rpl_strdup
667 #  endif
668 _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
669 _GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
670 # else
671 #  if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
672     /* strdup exists as a function and as a macro.  Get rid of the macro.  */
673 #   undef strdup
674 #  endif
675 #  if !(1 || defined strdup)
676 _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
677 #  endif
678 _GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
679 # endif
680 _GL_CXXALIASWARN (strdup);
681 #elif defined GNULIB_POSIXCHECK
682 # undef strdup
683 # if HAVE_RAW_DECL_STRDUP
684 _GL_WARN_ON_USE (strdup, "strdup is unportable - "
685                  "use gnulib module strdup for portability");
686 # endif
687 #endif
688
689 /* Append no more than N characters from SRC onto DEST.  */
690 #if 0
691 # if 0
692 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
693 #   undef strncat
694 #   define strncat rpl_strncat
695 #  endif
696 _GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
697                                    _GL_ARG_NONNULL ((1, 2)));
698 _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
699 # else
700 _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
701 # endif
702 _GL_CXXALIASWARN (strncat);
703 #elif defined GNULIB_POSIXCHECK
704 # undef strncat
705 # if HAVE_RAW_DECL_STRNCAT
706 _GL_WARN_ON_USE (strncat, "strncat is unportable - "
707                  "use gnulib module strncat for portability");
708 # endif
709 #endif
710
711 /* Return a newly allocated copy of at most N bytes of STRING.  */
712 #if 1
713 # if 0
714 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
715 #   undef strndup
716 #   define strndup rpl_strndup
717 #  endif
718 _GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n)
719                                    _GL_ARG_NONNULL ((1)));
720 _GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n));
721 # else
722 #  if ! 1
723 _GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
724                                    _GL_ARG_NONNULL ((1)));
725 #  endif
726 _GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
727 # endif
728 _GL_CXXALIASWARN (strndup);
729 #elif defined GNULIB_POSIXCHECK
730 # undef strndup
731 # if HAVE_RAW_DECL_STRNDUP
732 _GL_WARN_ON_USE (strndup, "strndup is unportable - "
733                  "use gnulib module strndup for portability");
734 # endif
735 #endif
736
737 /* Find the length (number of bytes) of STRING, but scan at most
738    MAXLEN bytes.  If no '\0' terminator is found in that many bytes,
739    return MAXLEN.  */
740 #if 1
741 # if 0
742 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
743 #   undef strnlen
744 #   define strnlen rpl_strnlen
745 #  endif
746 _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
747                                    _GL_ATTRIBUTE_PURE
748                                    _GL_ARG_NONNULL ((1)));
749 _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
750 # else
751 #  if ! 1
752 _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
753                                    _GL_ATTRIBUTE_PURE
754                                    _GL_ARG_NONNULL ((1)));
755 #  endif
756 _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
757 # endif
758 _GL_CXXALIASWARN (strnlen);
759 #elif defined GNULIB_POSIXCHECK
760 # undef strnlen
761 # if HAVE_RAW_DECL_STRNLEN
762 _GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
763                  "use gnulib module strnlen for portability");
764 # endif
765 #endif
766
767 #if defined GNULIB_POSIXCHECK
768 /* strcspn() assumes the second argument is a list of single-byte characters.
769    Even in this simple case, it does not work with multibyte strings if the
770    locale encoding is GB18030 and one of the characters to be searched is a
771    digit.  */
772 # undef strcspn
773 /* Assume strcspn is always declared.  */
774 _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
775                  "in multibyte locales - "
776                  "use mbscspn if you care about internationalization");
777 #endif
778
779 /* Find the first occurrence in S of any character in ACCEPT.  */
780 #if 0
781 # if ! 1
782 _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
783                                    _GL_ATTRIBUTE_PURE
784                                    _GL_ARG_NONNULL ((1, 2)));
785 # endif
786   /* On some systems, this function is defined as an overloaded function:
787        extern "C" { const char * strpbrk (const char *, const char *); }
788        extern "C++" { char * strpbrk (char *, const char *); }  */
789 _GL_CXXALIAS_SYS_CAST2 (strpbrk,
790                         char *, (char const *__s, char const *__accept),
791                         const char *, (char const *__s, char const *__accept));
792 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
793      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
794 _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
795 _GL_CXXALIASWARN1 (strpbrk, char const *,
796                    (char const *__s, char const *__accept));
797 # else
798 _GL_CXXALIASWARN (strpbrk);
799 # endif
800 # if defined GNULIB_POSIXCHECK
801 /* strpbrk() assumes the second argument is a list of single-byte characters.
802    Even in this simple case, it does not work with multibyte strings if the
803    locale encoding is GB18030 and one of the characters to be searched is a
804    digit.  */
805 #  undef strpbrk
806 _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
807                  "in multibyte locales - "
808                  "use mbspbrk if you care about internationalization");
809 # endif
810 #elif defined GNULIB_POSIXCHECK
811 # undef strpbrk
812 # if HAVE_RAW_DECL_STRPBRK
813 _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
814                  "use gnulib module strpbrk for portability");
815 # endif
816 #endif
817
818 #if defined GNULIB_POSIXCHECK
819 /* strspn() assumes the second argument is a list of single-byte characters.
820    Even in this simple case, it cannot work with multibyte strings.  */
821 # undef strspn
822 /* Assume strspn is always declared.  */
823 _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
824                  "in multibyte locales - "
825                  "use mbsspn if you care about internationalization");
826 #endif
827
828 #if defined GNULIB_POSIXCHECK
829 /* strrchr() does not work with multibyte strings if the locale encoding is
830    GB18030 and the character to be searched is a digit.  */
831 # undef strrchr
832 /* Assume strrchr is always declared.  */
833 _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
834                  "in some multibyte locales - "
835                  "use mbsrchr if you care about internationalization");
836 #endif
837
838 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
839    If one is found, overwrite it with a NUL, and advance *STRINGP
840    to point to the next char after it.  Otherwise, set *STRINGP to NULL.
841    If *STRINGP was already NULL, nothing happens.
842    Return the old value of *STRINGP.
843
844    This is a variant of strtok() that is multithread-safe and supports
845    empty fields.
846
847    Caveat: It modifies the original string.
848    Caveat: These functions cannot be used on constant strings.
849    Caveat: The identity of the delimiting character is lost.
850    Caveat: It doesn't work with multibyte strings unless all of the delimiter
851            characters are ASCII characters < 0x30.
852
853    See also strtok_r().  */
854 #if 0
855 # if ! 1
856 _GL_FUNCDECL_SYS (strsep, char *,
857                   (char **restrict __stringp, char const *restrict __delim)
858                   _GL_ARG_NONNULL ((1, 2)));
859 # endif
860 _GL_CXXALIAS_SYS (strsep, char *,
861                   (char **restrict __stringp, char const *restrict __delim));
862 _GL_CXXALIASWARN (strsep);
863 # if defined GNULIB_POSIXCHECK
864 #  undef strsep
865 _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
866                  "in multibyte locales - "
867                  "use mbssep if you care about internationalization");
868 # endif
869 #elif defined GNULIB_POSIXCHECK
870 # undef strsep
871 # if HAVE_RAW_DECL_STRSEP
872 _GL_WARN_ON_USE (strsep, "strsep is unportable - "
873                  "use gnulib module strsep for portability");
874 # endif
875 #endif
876
877 #if 0
878 # if 0
879 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
880 #   define strstr rpl_strstr
881 #  endif
882 _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
883                                   _GL_ATTRIBUTE_PURE
884                                   _GL_ARG_NONNULL ((1, 2)));
885 _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
886 # else
887   /* On some systems, this function is defined as an overloaded function:
888        extern "C++" { const char * strstr (const char *, const char *); }
889        extern "C++" { char * strstr (char *, const char *); }  */
890 _GL_CXXALIAS_SYS_CAST2 (strstr,
891                         char *, (const char *haystack, const char *needle),
892                         const char *, (const char *haystack, const char *needle));
893 # endif
894 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
895      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
896 _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
897 _GL_CXXALIASWARN1 (strstr, const char *,
898                    (const char *haystack, const char *needle));
899 # else
900 _GL_CXXALIASWARN (strstr);
901 # endif
902 #elif defined GNULIB_POSIXCHECK
903 /* strstr() does not work with multibyte strings if the locale encoding is
904    different from UTF-8:
905    POSIX says that it operates on "strings", and "string" in POSIX is defined
906    as a sequence of bytes, not of characters.  */
907 # undef strstr
908 /* Assume strstr is always declared.  */
909 _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
910                  "work correctly on character strings in most "
911                  "multibyte locales - "
912                  "use mbsstr if you care about internationalization, "
913                  "or use strstr if you care about speed");
914 #endif
915
916 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
917    comparison.  */
918 #if 0
919 # if 0
920 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
921 #   define strcasestr rpl_strcasestr
922 #  endif
923 _GL_FUNCDECL_RPL (strcasestr, char *,
924                   (const char *haystack, const char *needle)
925                   _GL_ATTRIBUTE_PURE
926                   _GL_ARG_NONNULL ((1, 2)));
927 _GL_CXXALIAS_RPL (strcasestr, char *,
928                   (const char *haystack, const char *needle));
929 # else
930 #  if ! 1
931 _GL_FUNCDECL_SYS (strcasestr, char *,
932                   (const char *haystack, const char *needle)
933                   _GL_ATTRIBUTE_PURE
934                   _GL_ARG_NONNULL ((1, 2)));
935 #  endif
936   /* On some systems, this function is defined as an overloaded function:
937        extern "C++" { const char * strcasestr (const char *, const char *); }
938        extern "C++" { char * strcasestr (char *, const char *); }  */
939 _GL_CXXALIAS_SYS_CAST2 (strcasestr,
940                         char *, (const char *haystack, const char *needle),
941                         const char *, (const char *haystack, const char *needle));
942 # endif
943 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
944      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
945 _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
946 _GL_CXXALIASWARN1 (strcasestr, const char *,
947                    (const char *haystack, const char *needle));
948 # else
949 _GL_CXXALIASWARN (strcasestr);
950 # endif
951 #elif defined GNULIB_POSIXCHECK
952 /* strcasestr() does not work with multibyte strings:
953    It is a glibc extension, and glibc implements it only for unibyte
954    locales.  */
955 # undef strcasestr
956 # if HAVE_RAW_DECL_STRCASESTR
957 _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
958                  "strings in multibyte locales - "
959                  "use mbscasestr if you care about "
960                  "internationalization, or use c-strcasestr if you want "
961                  "a locale independent function");
962 # endif
963 #endif
964
965 /* Parse S into tokens separated by characters in DELIM.
966    If S is NULL, the saved pointer in SAVE_PTR is used as
967    the next starting point.  For example:
968         char s[] = "-abc-=-def";
969         char *sp;
970         x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
971         x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
972         x = strtok_r(NULL, "=", &sp);   // x = NULL
973                 // s = "abc\0-def\0"
974
975    This is a variant of strtok() that is multithread-safe.
976
977    For the POSIX documentation for this function, see:
978    http://www.opengroup.org/susv3xsh/strtok.html
979
980    Caveat: It modifies the original string.
981    Caveat: These functions cannot be used on constant strings.
982    Caveat: The identity of the delimiting character is lost.
983    Caveat: It doesn't work with multibyte strings unless all of the delimiter
984            characters are ASCII characters < 0x30.
985
986    See also strsep().  */
987 #if 0
988 # if 0
989 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
990 #   undef strtok_r
991 #   define strtok_r rpl_strtok_r
992 #  endif
993 _GL_FUNCDECL_RPL (strtok_r, char *,
994                   (char *restrict s, char const *restrict delim,
995                    char **restrict save_ptr)
996                   _GL_ARG_NONNULL ((2, 3)));
997 _GL_CXXALIAS_RPL (strtok_r, char *,
998                   (char *restrict s, char const *restrict delim,
999                    char **restrict save_ptr));
1000 # else
1001 #  if 0 || defined GNULIB_POSIXCHECK
1002 #   undef strtok_r
1003 #  endif
1004 #  if ! 1
1005 _GL_FUNCDECL_SYS (strtok_r, char *,
1006                   (char *restrict s, char const *restrict delim,
1007                    char **restrict save_ptr)
1008                   _GL_ARG_NONNULL ((2, 3)));
1009 #  endif
1010 _GL_CXXALIAS_SYS (strtok_r, char *,
1011                   (char *restrict s, char const *restrict delim,
1012                    char **restrict save_ptr));
1013 # endif
1014 _GL_CXXALIASWARN (strtok_r);
1015 # if defined GNULIB_POSIXCHECK
1016 _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
1017                  "strings in multibyte locales - "
1018                  "use mbstok_r if you care about internationalization");
1019 # endif
1020 #elif defined GNULIB_POSIXCHECK
1021 # undef strtok_r
1022 # if HAVE_RAW_DECL_STRTOK_R
1023 _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
1024                  "use gnulib module strtok_r for portability");
1025 # endif
1026 #endif
1027
1028
1029 /* The following functions are not specified by POSIX.  They are gnulib
1030    extensions.  */
1031
1032 #if 1
1033 /* Return the number of multibyte characters in the character string STRING.
1034    This considers multibyte characters, unlike strlen, which counts bytes.  */
1035 # ifdef __MirBSD__  /* MirBSD defines mbslen as a macro.  Override it.  */
1036 #  undef mbslen
1037 # endif
1038 # if 0  /* AIX, OSF/1, MirBSD define mbslen already in libc.  */
1039 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1040 #   define mbslen rpl_mbslen
1041 #  endif
1042 _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
1043 _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
1044 # else
1045 _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
1046 _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
1047 # endif
1048 _GL_CXXALIASWARN (mbslen);
1049 #endif
1050
1051 #if 0
1052 /* Return the number of multibyte characters in the character string starting
1053    at STRING and ending at STRING + LEN.  */
1054 _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
1055      _GL_ARG_NONNULL ((1));
1056 #endif
1057
1058 #if 0
1059 /* Locate the first single-byte character C in the character string STRING,
1060    and return a pointer to it.  Return NULL if C is not found in STRING.
1061    Unlike strchr(), this function works correctly in multibyte locales with
1062    encodings such as GB18030.  */
1063 # if defined __hpux
1064 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1065 #   define mbschr rpl_mbschr /* avoid collision with HP-UX function */
1066 #  endif
1067 _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
1068                                   _GL_ARG_NONNULL ((1)));
1069 _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
1070 # else
1071 _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
1072                                   _GL_ARG_NONNULL ((1)));
1073 _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
1074 # endif
1075 _GL_CXXALIASWARN (mbschr);
1076 #endif
1077
1078 #if 0
1079 /* Locate the last single-byte character C in the character string STRING,
1080    and return a pointer to it.  Return NULL if C is not found in STRING.
1081    Unlike strrchr(), this function works correctly in multibyte locales with
1082    encodings such as GB18030.  */
1083 # if defined __hpux || defined __INTERIX
1084 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1085 #   define mbsrchr rpl_mbsrchr /* avoid collision with system function */
1086 #  endif
1087 _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
1088                                    _GL_ARG_NONNULL ((1)));
1089 _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
1090 # else
1091 _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
1092                                    _GL_ARG_NONNULL ((1)));
1093 _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
1094 # endif
1095 _GL_CXXALIASWARN (mbsrchr);
1096 #endif
1097
1098 #if 1
1099 /* Find the first occurrence of the character string NEEDLE in the character
1100    string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
1101    Unlike strstr(), this function works correctly in multibyte locales with
1102    encodings different from UTF-8.  */
1103 _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
1104      _GL_ARG_NONNULL ((1, 2));
1105 #endif
1106
1107 #if 1
1108 /* Compare the character strings S1 and S2, ignoring case, returning less than,
1109    equal to or greater than zero if S1 is lexicographically less than, equal to
1110    or greater than S2.
1111    Note: This function may, in multibyte locales, return 0 for strings of
1112    different lengths!
1113    Unlike strcasecmp(), this function works correctly in multibyte locales.  */
1114 _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
1115      _GL_ARG_NONNULL ((1, 2));
1116 #endif
1117
1118 #if 0
1119 /* Compare the initial segment of the character string S1 consisting of at most
1120    N characters with the initial segment of the character string S2 consisting
1121    of at most N characters, ignoring case, returning less than, equal to or
1122    greater than zero if the initial segment of S1 is lexicographically less
1123    than, equal to or greater than the initial segment of S2.
1124    Note: This function may, in multibyte locales, return 0 for initial segments
1125    of different lengths!
1126    Unlike strncasecmp(), this function works correctly in multibyte locales.
1127    But beware that N is not a byte count but a character count!  */
1128 _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
1129      _GL_ARG_NONNULL ((1, 2));
1130 #endif
1131
1132 #if 0
1133 /* Compare the initial segment of the character string STRING consisting of
1134    at most mbslen (PREFIX) characters with the character string PREFIX,
1135    ignoring case.  If the two match, return a pointer to the first byte
1136    after this prefix in STRING.  Otherwise, return NULL.
1137    Note: This function may, in multibyte locales, return non-NULL if STRING
1138    is of smaller length than PREFIX!
1139    Unlike strncasecmp(), this function works correctly in multibyte
1140    locales.  */
1141 _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1142      _GL_ARG_NONNULL ((1, 2));
1143 #endif
1144
1145 #if 0
1146 /* Find the first occurrence of the character string NEEDLE in the character
1147    string HAYSTACK, using case-insensitive comparison.
1148    Note: This function may, in multibyte locales, return success even if
1149    strlen (haystack) < strlen (needle) !
1150    Unlike strcasestr(), this function works correctly in multibyte locales.  */
1151 _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
1152      _GL_ARG_NONNULL ((1, 2));
1153 #endif
1154
1155 #if 0
1156 /* Find the first occurrence in the character string STRING of any character
1157    in the character string ACCEPT.  Return the number of bytes from the
1158    beginning of the string to this occurrence, or to the end of the string
1159    if none exists.
1160    Unlike strcspn(), this function works correctly in multibyte locales.  */
1161 _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
1162      _GL_ARG_NONNULL ((1, 2));
1163 #endif
1164
1165 #if 0
1166 /* Find the first occurrence in the character string STRING of any character
1167    in the character string ACCEPT.  Return the pointer to it, or NULL if none
1168    exists.
1169    Unlike strpbrk(), this function works correctly in multibyte locales.  */
1170 # if defined __hpux
1171 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1172 #   define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
1173 #  endif
1174 _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
1175                                    _GL_ARG_NONNULL ((1, 2)));
1176 _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
1177 # else
1178 _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
1179                                    _GL_ARG_NONNULL ((1, 2)));
1180 _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
1181 # endif
1182 _GL_CXXALIASWARN (mbspbrk);
1183 #endif
1184
1185 #if 0
1186 /* Find the first occurrence in the character string STRING of any character
1187    not in the character string REJECT.  Return the number of bytes from the
1188    beginning of the string to this occurrence, or to the end of the string
1189    if none exists.
1190    Unlike strspn(), this function works correctly in multibyte locales.  */
1191 _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
1192      _GL_ARG_NONNULL ((1, 2));
1193 #endif
1194
1195 #if 0
1196 /* Search the next delimiter (multibyte character listed in the character
1197    string DELIM) starting at the character string *STRINGP.
1198    If one is found, overwrite it with a NUL, and advance *STRINGP to point
1199    to the next multibyte character after it.  Otherwise, set *STRINGP to NULL.
1200    If *STRINGP was already NULL, nothing happens.
1201    Return the old value of *STRINGP.
1202
1203    This is a variant of mbstok_r() that supports empty fields.
1204
1205    Caveat: It modifies the original string.
1206    Caveat: These functions cannot be used on constant strings.
1207    Caveat: The identity of the delimiting character is lost.
1208
1209    See also mbstok_r().  */
1210 _GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
1211      _GL_ARG_NONNULL ((1, 2));
1212 #endif
1213
1214 #if 0
1215 /* Parse the character string STRING into tokens separated by characters in
1216    the character string DELIM.
1217    If STRING is NULL, the saved pointer in SAVE_PTR is used as
1218    the next starting point.  For example:
1219         char s[] = "-abc-=-def";
1220         char *sp;
1221         x = mbstok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
1222         x = mbstok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
1223         x = mbstok_r(NULL, "=", &sp);   // x = NULL
1224                 // s = "abc\0-def\0"
1225
1226    Caveat: It modifies the original string.
1227    Caveat: These functions cannot be used on constant strings.
1228    Caveat: The identity of the delimiting character is lost.
1229
1230    See also mbssep().  */
1231 _GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
1232      _GL_ARG_NONNULL ((2, 3));
1233 #endif
1234
1235 /* Map any int, typically from errno, into an error message.  */
1236 #if 1
1237 # if 1
1238 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1239 #   undef strerror
1240 #   define strerror rpl_strerror
1241 #  endif
1242 _GL_FUNCDECL_RPL (strerror, char *, (int));
1243 _GL_CXXALIAS_RPL (strerror, char *, (int));
1244 # else
1245 _GL_CXXALIAS_SYS (strerror, char *, (int));
1246 # endif
1247 _GL_CXXALIASWARN (strerror);
1248 #elif defined GNULIB_POSIXCHECK
1249 # undef strerror
1250 /* Assume strerror is always declared.  */
1251 _GL_WARN_ON_USE (strerror, "strerror is unportable - "
1252                  "use gnulib module strerror to guarantee non-NULL result");
1253 #endif
1254
1255 /* Map any int, typically from errno, into an error message.  Multithread-safe.
1256    Uses the POSIX declaration, not the glibc declaration.  */
1257 #if 0
1258 # if 0
1259 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1260 #   undef strerror_r
1261 #   define strerror_r rpl_strerror_r
1262 #  endif
1263 _GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
1264                                    _GL_ARG_NONNULL ((2)));
1265 _GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
1266 # else
1267 #  if !1
1268 _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
1269                                    _GL_ARG_NONNULL ((2)));
1270 #  endif
1271 _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
1272 # endif
1273 # if 1
1274 _GL_CXXALIASWARN (strerror_r);
1275 # endif
1276 #elif defined GNULIB_POSIXCHECK
1277 # undef strerror_r
1278 # if HAVE_RAW_DECL_STRERROR_R
1279 _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1280                  "use gnulib module strerror_r-posix for portability");
1281 # endif
1282 #endif
1283
1284 #if 0
1285 # if 0
1286 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1287 #   define strsignal rpl_strsignal
1288 #  endif
1289 _GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
1290 _GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
1291 # else
1292 #  if ! 1
1293 _GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
1294 #  endif
1295 /* Need to cast, because on Cygwin 1.5.x systems, the return type is
1296    'const char *'.  */
1297 _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
1298 # endif
1299 _GL_CXXALIASWARN (strsignal);
1300 #elif defined GNULIB_POSIXCHECK
1301 # undef strsignal
1302 # if HAVE_RAW_DECL_STRSIGNAL
1303 _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
1304                  "use gnulib module strsignal for portability");
1305 # endif
1306 #endif
1307
1308 #if 0
1309 # if !1
1310 _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
1311                                    _GL_ARG_NONNULL ((1, 2)));
1312 # endif
1313 _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
1314 _GL_CXXALIASWARN (strverscmp);
1315 #elif defined GNULIB_POSIXCHECK
1316 # undef strverscmp
1317 # if HAVE_RAW_DECL_STRVERSCMP
1318 _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1319                  "use gnulib module strverscmp for portability");
1320 # endif
1321 #endif
1322
1323
1324 #endif /* _GL_STRING_H */
1325 #endif /* _GL_STRING_H */