Blame lib/string.in.h

Packit 1ac44c
/* A GNU-like <string.h>.
Packit 1ac44c
Packit 1ac44c
   Copyright (C) 1995-1996, 2001-2018 Free Software Foundation, Inc.
Packit 1ac44c
Packit 1ac44c
   This program is free software; you can redistribute it and/or modify
Packit 1ac44c
   it under the terms of the GNU General Public License as published by
Packit 1ac44c
   the Free Software Foundation; either version 3, or (at your option)
Packit 1ac44c
   any later version.
Packit 1ac44c
Packit 1ac44c
   This program is distributed in the hope that it will be useful,
Packit 1ac44c
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 1ac44c
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 1ac44c
   GNU General Public License for more details.
Packit 1ac44c
Packit 1ac44c
   You should have received a copy of the GNU General Public License
Packit 1ac44c
   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit 1ac44c
Packit 1ac44c
#if __GNUC__ >= 3
Packit 1ac44c
@PRAGMA_SYSTEM_HEADER@
Packit 1ac44c
#endif
Packit 1ac44c
@PRAGMA_COLUMNS@
Packit 1ac44c
Packit 1ac44c
#if defined _GL_ALREADY_INCLUDING_STRING_H
Packit 1ac44c
/* Special invocation convention:
Packit 1ac44c
   - On OS X/NetBSD we have a sequence of nested includes
Packit 1ac44c
       <string.h> -> <strings.h> -> "string.h"
Packit 1ac44c
     In this situation system _chk variants due to -D_FORTIFY_SOURCE
Packit 1ac44c
     might be used after any replacements defined here.  */
Packit 1ac44c
Packit 1ac44c
#@INCLUDE_NEXT@ @NEXT_STRING_H@
Packit 1ac44c
Packit 1ac44c
#else
Packit 1ac44c
/* Normal invocation convention.  */
Packit 1ac44c
Packit 1ac44c
#ifndef _@GUARD_PREFIX@_STRING_H
Packit 1ac44c
Packit 1ac44c
#define _GL_ALREADY_INCLUDING_STRING_H
Packit 1ac44c
Packit 1ac44c
/* The include_next requires a split double-inclusion guard.  */
Packit 1ac44c
#@INCLUDE_NEXT@ @NEXT_STRING_H@
Packit 1ac44c
Packit 1ac44c
#undef _GL_ALREADY_INCLUDING_STRING_H
Packit 1ac44c
Packit 1ac44c
#ifndef _@GUARD_PREFIX@_STRING_H
Packit 1ac44c
#define _@GUARD_PREFIX@_STRING_H
Packit 1ac44c
Packit 1ac44c
/* NetBSD 5.0 mis-defines NULL.  */
Packit 1ac44c
#include <stddef.h>
Packit 1ac44c
Packit 1ac44c
/* MirBSD defines mbslen as a macro.  */
Packit 1ac44c
#if @GNULIB_MBSLEN@ && defined __MirBSD__
Packit 1ac44c
# include <wchar.h>
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* The __attribute__ feature is available in gcc versions 2.5 and later.
Packit 1ac44c
   The attribute __pure__ was added in gcc 2.96.  */
Packit 1ac44c
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
Packit 1ac44c
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
Packit 1ac44c
#else
Packit 1ac44c
# define _GL_ATTRIBUTE_PURE /* empty */
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>.  */
Packit 1ac44c
/* But in any case avoid namespace pollution on glibc systems.  */
Packit 1ac44c
#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
Packit 1ac44c
    && ! defined __GLIBC__
Packit 1ac44c
# include <unistd.h>
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
Packit 1ac44c
Packit 1ac44c
/* The definition of _GL_ARG_NONNULL is copied here.  */
Packit 1ac44c
Packit 1ac44c
/* The definition of _GL_WARN_ON_USE is copied here.  */
Packit 1ac44c
Packit 1ac44c
Packit 1ac44c
/* Clear a block of memory.  The compiler will not delete a call to
Packit 1ac44c
   this function, even if the block is dead after the call.  */
Packit 1ac44c
#if @GNULIB_EXPLICIT_BZERO@
Packit 1ac44c
# if ! @HAVE_EXPLICIT_BZERO@
Packit 1ac44c
_GL_FUNCDECL_SYS (explicit_bzero, void,
Packit 1ac44c
                  (void *__dest, size_t __n) _GL_ARG_NONNULL ((1)));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
Packit 1ac44c
_GL_CXXALIASWARN (explicit_bzero);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef explicit_bzero
Packit 1ac44c
# if HAVE_RAW_DECL_EXPLICIT_BZERO
Packit 1ac44c
_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
Packit 1ac44c
                 "use gnulib module explicit_bzero for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Find the index of the least-significant set bit.  */
Packit 1ac44c
#if @GNULIB_FFSL@
Packit 1ac44c
# if !@HAVE_FFSL@
Packit 1ac44c
_GL_FUNCDECL_SYS (ffsl, int, (long int i));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIAS_SYS (ffsl, int, (long int i));
Packit 1ac44c
_GL_CXXALIASWARN (ffsl);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef ffsl
Packit 1ac44c
# if HAVE_RAW_DECL_FFSL
Packit 1ac44c
_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
Packit 1ac44c
/* Find the index of the least-significant set bit.  */
Packit 1ac44c
#if @GNULIB_FFSLL@
Packit 1ac44c
# if !@HAVE_FFSLL@
Packit 1ac44c
_GL_FUNCDECL_SYS (ffsll, int, (long long int i));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
Packit 1ac44c
_GL_CXXALIASWARN (ffsll);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef ffsll
Packit 1ac44c
# if HAVE_RAW_DECL_FFSLL
Packit 1ac44c
_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
Packit 1ac44c
/* Return the first instance of C within N bytes of S, or NULL.  */
Packit 1ac44c
#if @GNULIB_MEMCHR@
Packit 1ac44c
# if @REPLACE_MEMCHR@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   define memchr rpl_memchr
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
Packit 1ac44c
                                  _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                  _GL_ARG_NONNULL ((1)));
Packit 1ac44c
_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
Packit 1ac44c
# else
Packit 1ac44c
#  if ! @HAVE_MEMCHR@
Packit 1ac44c
_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
Packit 1ac44c
                                  _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                  _GL_ARG_NONNULL ((1)));
Packit 1ac44c
#  endif
Packit 1ac44c
  /* On some systems, this function is defined as an overloaded function:
Packit 1ac44c
       extern "C" { const void * std::memchr (const void *, int, size_t); }
Packit 1ac44c
       extern "C++" { void * std::memchr (void *, int, size_t); }  */
Packit 1ac44c
_GL_CXXALIAS_SYS_CAST2 (memchr,
Packit 1ac44c
                        void *, (void const *__s, int __c, size_t __n),
Packit 1ac44c
                        void const *, (void const *__s, int __c, size_t __n));
Packit 1ac44c
# endif
Packit 1ac44c
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
Packit 1ac44c
     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
Packit 1ac44c
_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
Packit 1ac44c
_GL_CXXALIASWARN1 (memchr, void const *,
Packit 1ac44c
                   (void const *__s, int __c, size_t __n));
Packit 1ac44c
# else
Packit 1ac44c
_GL_CXXALIASWARN (memchr);
Packit 1ac44c
# endif
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef memchr
Packit 1ac44c
/* Assume memchr is always declared.  */
Packit 1ac44c
_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
Packit 1ac44c
                 "use gnulib module memchr for portability" );
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Return the first occurrence of NEEDLE in HAYSTACK.  */
Packit 1ac44c
#if @GNULIB_MEMMEM@
Packit 1ac44c
# if @REPLACE_MEMMEM@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   define memmem rpl_memmem
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (memmem, void *,
Packit 1ac44c
                  (void const *__haystack, size_t __haystack_len,
Packit 1ac44c
                   void const *__needle, size_t __needle_len)
Packit 1ac44c
                  _GL_ATTRIBUTE_PURE
Packit 1ac44c
                  _GL_ARG_NONNULL ((1, 3)));
Packit 1ac44c
_GL_CXXALIAS_RPL (memmem, void *,
Packit 1ac44c
                  (void const *__haystack, size_t __haystack_len,
Packit 1ac44c
                   void const *__needle, size_t __needle_len));
Packit 1ac44c
# else
Packit 1ac44c
#  if ! @HAVE_DECL_MEMMEM@
Packit 1ac44c
_GL_FUNCDECL_SYS (memmem, void *,
Packit 1ac44c
                  (void const *__haystack, size_t __haystack_len,
Packit 1ac44c
                   void const *__needle, size_t __needle_len)
Packit 1ac44c
                  _GL_ATTRIBUTE_PURE
Packit 1ac44c
                  _GL_ARG_NONNULL ((1, 3)));
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_CXXALIAS_SYS (memmem, void *,
Packit 1ac44c
                  (void const *__haystack, size_t __haystack_len,
Packit 1ac44c
                   void const *__needle, size_t __needle_len));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (memmem);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef memmem
Packit 1ac44c
# if HAVE_RAW_DECL_MEMMEM
Packit 1ac44c
_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
Packit 1ac44c
                 "use gnulib module memmem-simple for portability, "
Packit 1ac44c
                 "and module memmem for speed" );
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Copy N bytes of SRC to DEST, return pointer to bytes after the
Packit 1ac44c
   last written byte.  */
Packit 1ac44c
#if @GNULIB_MEMPCPY@
Packit 1ac44c
# if ! @HAVE_MEMPCPY@
Packit 1ac44c
_GL_FUNCDECL_SYS (mempcpy, void *,
Packit 1ac44c
                  (void *restrict __dest, void const *restrict __src,
Packit 1ac44c
                   size_t __n)
Packit 1ac44c
                  _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIAS_SYS (mempcpy, void *,
Packit 1ac44c
                  (void *restrict __dest, void const *restrict __src,
Packit 1ac44c
                   size_t __n));
Packit 1ac44c
_GL_CXXALIASWARN (mempcpy);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef mempcpy
Packit 1ac44c
# if HAVE_RAW_DECL_MEMPCPY
Packit 1ac44c
_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
Packit 1ac44c
                 "use gnulib module mempcpy for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Search backwards through a block for a byte (specified as an int).  */
Packit 1ac44c
#if @GNULIB_MEMRCHR@
Packit 1ac44c
# if ! @HAVE_DECL_MEMRCHR@
Packit 1ac44c
_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
Packit 1ac44c
                                   _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                   _GL_ARG_NONNULL ((1)));
Packit 1ac44c
# endif
Packit 1ac44c
  /* On some systems, this function is defined as an overloaded function:
Packit 1ac44c
       extern "C++" { const void * std::memrchr (const void *, int, size_t); }
Packit 1ac44c
       extern "C++" { void * std::memrchr (void *, int, size_t); }  */
Packit 1ac44c
_GL_CXXALIAS_SYS_CAST2 (memrchr,
Packit 1ac44c
                        void *, (void const *, int, size_t),
Packit 1ac44c
                        void const *, (void const *, int, size_t));
Packit 1ac44c
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
Packit 1ac44c
     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
Packit 1ac44c
_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
Packit 1ac44c
_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
Packit 1ac44c
# else
Packit 1ac44c
_GL_CXXALIASWARN (memrchr);
Packit 1ac44c
# endif
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef memrchr
Packit 1ac44c
# if HAVE_RAW_DECL_MEMRCHR
Packit 1ac44c
_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
Packit 1ac44c
                 "use gnulib module memrchr for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Find the first occurrence of C in S.  More efficient than
Packit 1ac44c
   memchr(S,C,N), at the expense of undefined behavior if C does not
Packit 1ac44c
   occur within N bytes.  */
Packit 1ac44c
#if @GNULIB_RAWMEMCHR@
Packit 1ac44c
# if ! @HAVE_RAWMEMCHR@
Packit 1ac44c
_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
Packit 1ac44c
                                     _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                     _GL_ARG_NONNULL ((1)));
Packit 1ac44c
# endif
Packit 1ac44c
  /* On some systems, this function is defined as an overloaded function:
Packit 1ac44c
       extern "C++" { const void * std::rawmemchr (const void *, int); }
Packit 1ac44c
       extern "C++" { void * std::rawmemchr (void *, int); }  */
Packit 1ac44c
_GL_CXXALIAS_SYS_CAST2 (rawmemchr,
Packit 1ac44c
                        void *, (void const *__s, int __c_in),
Packit 1ac44c
                        void const *, (void const *__s, int __c_in));
Packit 1ac44c
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
Packit 1ac44c
     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
Packit 1ac44c
_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
Packit 1ac44c
_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
Packit 1ac44c
# else
Packit 1ac44c
_GL_CXXALIASWARN (rawmemchr);
Packit 1ac44c
# endif
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef rawmemchr
Packit 1ac44c
# if HAVE_RAW_DECL_RAWMEMCHR
Packit 1ac44c
_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
Packit 1ac44c
                 "use gnulib module rawmemchr for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
Packit 1ac44c
#if @GNULIB_STPCPY@
Packit 1ac44c
# if ! @HAVE_STPCPY@
Packit 1ac44c
_GL_FUNCDECL_SYS (stpcpy, char *,
Packit 1ac44c
                  (char *restrict __dst, char const *restrict __src)
Packit 1ac44c
                  _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIAS_SYS (stpcpy, char *,
Packit 1ac44c
                  (char *restrict __dst, char const *restrict __src));
Packit 1ac44c
_GL_CXXALIASWARN (stpcpy);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef stpcpy
Packit 1ac44c
# if HAVE_RAW_DECL_STPCPY
Packit 1ac44c
_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
Packit 1ac44c
                 "use gnulib module stpcpy for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Copy no more than N bytes of SRC to DST, returning a pointer past the
Packit 1ac44c
   last non-NUL byte written into DST.  */
Packit 1ac44c
#if @GNULIB_STPNCPY@
Packit 1ac44c
# if @REPLACE_STPNCPY@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   undef stpncpy
Packit 1ac44c
#   define stpncpy rpl_stpncpy
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (stpncpy, char *,
Packit 1ac44c
                  (char *restrict __dst, char const *restrict __src,
Packit 1ac44c
                   size_t __n)
Packit 1ac44c
                  _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
_GL_CXXALIAS_RPL (stpncpy, char *,
Packit 1ac44c
                  (char *restrict __dst, char const *restrict __src,
Packit 1ac44c
                   size_t __n));
Packit 1ac44c
# else
Packit 1ac44c
#  if ! @HAVE_STPNCPY@
Packit 1ac44c
_GL_FUNCDECL_SYS (stpncpy, char *,
Packit 1ac44c
                  (char *restrict __dst, char const *restrict __src,
Packit 1ac44c
                   size_t __n)
Packit 1ac44c
                  _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_CXXALIAS_SYS (stpncpy, char *,
Packit 1ac44c
                  (char *restrict __dst, char const *restrict __src,
Packit 1ac44c
                   size_t __n));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (stpncpy);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef stpncpy
Packit 1ac44c
# if HAVE_RAW_DECL_STPNCPY
Packit 1ac44c
_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
Packit 1ac44c
                 "use gnulib module stpncpy for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if defined GNULIB_POSIXCHECK
Packit 1ac44c
/* strchr() does not work with multibyte strings if the locale encoding is
Packit 1ac44c
   GB18030 and the character to be searched is a digit.  */
Packit 1ac44c
# undef strchr
Packit 1ac44c
/* Assume strchr is always declared.  */
Packit 1ac44c
_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
Packit 1ac44c
                 "in some multibyte locales - "
Packit 1ac44c
                 "use mbschr if you care about internationalization");
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Find the first occurrence of C in S or the final NUL byte.  */
Packit 1ac44c
#if @GNULIB_STRCHRNUL@
Packit 1ac44c
# if @REPLACE_STRCHRNUL@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   define strchrnul rpl_strchrnul
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
Packit 1ac44c
                                     _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                     _GL_ARG_NONNULL ((1)));
Packit 1ac44c
_GL_CXXALIAS_RPL (strchrnul, char *,
Packit 1ac44c
                  (const char *str, int ch));
Packit 1ac44c
# else
Packit 1ac44c
#  if ! @HAVE_STRCHRNUL@
Packit 1ac44c
_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
Packit 1ac44c
                                     _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                     _GL_ARG_NONNULL ((1)));
Packit 1ac44c
#  endif
Packit 1ac44c
  /* On some systems, this function is defined as an overloaded function:
Packit 1ac44c
       extern "C++" { const char * std::strchrnul (const char *, int); }
Packit 1ac44c
       extern "C++" { char * std::strchrnul (char *, int); }  */
Packit 1ac44c
_GL_CXXALIAS_SYS_CAST2 (strchrnul,
Packit 1ac44c
                        char *, (char const *__s, int __c_in),
Packit 1ac44c
                        char const *, (char const *__s, int __c_in));
Packit 1ac44c
# endif
Packit 1ac44c
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
Packit 1ac44c
     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
Packit 1ac44c
_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
Packit 1ac44c
_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
Packit 1ac44c
# else
Packit 1ac44c
_GL_CXXALIASWARN (strchrnul);
Packit 1ac44c
# endif
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef strchrnul
Packit 1ac44c
# if HAVE_RAW_DECL_STRCHRNUL
Packit 1ac44c
_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
Packit 1ac44c
                 "use gnulib module strchrnul for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Duplicate S, returning an identical malloc'd string.  */
Packit 1ac44c
#if @GNULIB_STRDUP@
Packit 1ac44c
# if @REPLACE_STRDUP@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   undef strdup
Packit 1ac44c
#   define strdup rpl_strdup
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
Packit 1ac44c
_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
Packit 1ac44c
# else
Packit 1ac44c
#  if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
Packit 1ac44c
    /* strdup exists as a function and as a macro.  Get rid of the macro.  */
Packit 1ac44c
#   undef strdup
Packit 1ac44c
#  endif
Packit 1ac44c
#  if !(@HAVE_DECL_STRDUP@ || defined strdup)
Packit 1ac44c
_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (strdup);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef strdup
Packit 1ac44c
# if HAVE_RAW_DECL_STRDUP
Packit 1ac44c
_GL_WARN_ON_USE (strdup, "strdup is unportable - "
Packit 1ac44c
                 "use gnulib module strdup for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Append no more than N characters from SRC onto DEST.  */
Packit 1ac44c
#if @GNULIB_STRNCAT@
Packit 1ac44c
# if @REPLACE_STRNCAT@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   undef strncat
Packit 1ac44c
#   define strncat rpl_strncat
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
Packit 1ac44c
                                   _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
Packit 1ac44c
# else
Packit 1ac44c
_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (strncat);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef strncat
Packit 1ac44c
# if HAVE_RAW_DECL_STRNCAT
Packit 1ac44c
_GL_WARN_ON_USE (strncat, "strncat is unportable - "
Packit 1ac44c
                 "use gnulib module strncat for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Return a newly allocated copy of at most N bytes of STRING.  */
Packit 1ac44c
#if @GNULIB_STRNDUP@
Packit 1ac44c
# if @REPLACE_STRNDUP@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   undef strndup
Packit 1ac44c
#   define strndup rpl_strndup
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n)
Packit 1ac44c
                                   _GL_ARG_NONNULL ((1)));
Packit 1ac44c
_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
Packit 1ac44c
# else
Packit 1ac44c
#  if ! @HAVE_DECL_STRNDUP@
Packit 1ac44c
_GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n)
Packit 1ac44c
                                   _GL_ARG_NONNULL ((1)));
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (strndup);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef strndup
Packit 1ac44c
# if HAVE_RAW_DECL_STRNDUP
Packit 1ac44c
_GL_WARN_ON_USE (strndup, "strndup is unportable - "
Packit 1ac44c
                 "use gnulib module strndup for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Find the length (number of bytes) of STRING, but scan at most
Packit 1ac44c
   MAXLEN bytes.  If no '\0' terminator is found in that many bytes,
Packit 1ac44c
   return MAXLEN.  */
Packit 1ac44c
#if @GNULIB_STRNLEN@
Packit 1ac44c
# if @REPLACE_STRNLEN@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   undef strnlen
Packit 1ac44c
#   define strnlen rpl_strnlen
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)
Packit 1ac44c
                                   _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                   _GL_ARG_NONNULL ((1)));
Packit 1ac44c
_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
Packit 1ac44c
# else
Packit 1ac44c
#  if ! @HAVE_DECL_STRNLEN@
Packit 1ac44c
_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)
Packit 1ac44c
                                   _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                   _GL_ARG_NONNULL ((1)));
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (strnlen);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef strnlen
Packit 1ac44c
# if HAVE_RAW_DECL_STRNLEN
Packit 1ac44c
_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
Packit 1ac44c
                 "use gnulib module strnlen for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if defined GNULIB_POSIXCHECK
Packit 1ac44c
/* strcspn() assumes the second argument is a list of single-byte characters.
Packit 1ac44c
   Even in this simple case, it does not work with multibyte strings if the
Packit 1ac44c
   locale encoding is GB18030 and one of the characters to be searched is a
Packit 1ac44c
   digit.  */
Packit 1ac44c
# undef strcspn
Packit 1ac44c
/* Assume strcspn is always declared.  */
Packit 1ac44c
_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
Packit 1ac44c
                 "in multibyte locales - "
Packit 1ac44c
                 "use mbscspn if you care about internationalization");
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Find the first occurrence in S of any character in ACCEPT.  */
Packit 1ac44c
#if @GNULIB_STRPBRK@
Packit 1ac44c
# if ! @HAVE_STRPBRK@
Packit 1ac44c
_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
Packit 1ac44c
                                   _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                   _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
# endif
Packit 1ac44c
  /* On some systems, this function is defined as an overloaded function:
Packit 1ac44c
       extern "C" { const char * strpbrk (const char *, const char *); }
Packit 1ac44c
       extern "C++" { char * strpbrk (char *, const char *); }  */
Packit 1ac44c
_GL_CXXALIAS_SYS_CAST2 (strpbrk,
Packit 1ac44c
                        char *, (char const *__s, char const *__accept),
Packit 1ac44c
                        const char *, (char const *__s, char const *__accept));
Packit 1ac44c
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
Packit 1ac44c
     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
Packit 1ac44c
_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
Packit 1ac44c
_GL_CXXALIASWARN1 (strpbrk, char const *,
Packit 1ac44c
                   (char const *__s, char const *__accept));
Packit 1ac44c
# else
Packit 1ac44c
_GL_CXXALIASWARN (strpbrk);
Packit 1ac44c
# endif
Packit 1ac44c
# if defined GNULIB_POSIXCHECK
Packit 1ac44c
/* strpbrk() assumes the second argument is a list of single-byte characters.
Packit 1ac44c
   Even in this simple case, it does not work with multibyte strings if the
Packit 1ac44c
   locale encoding is GB18030 and one of the characters to be searched is a
Packit 1ac44c
   digit.  */
Packit 1ac44c
#  undef strpbrk
Packit 1ac44c
_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
Packit 1ac44c
                 "in multibyte locales - "
Packit 1ac44c
                 "use mbspbrk if you care about internationalization");
Packit 1ac44c
# endif
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef strpbrk
Packit 1ac44c
# if HAVE_RAW_DECL_STRPBRK
Packit 1ac44c
_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
Packit 1ac44c
                 "use gnulib module strpbrk for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if defined GNULIB_POSIXCHECK
Packit 1ac44c
/* strspn() assumes the second argument is a list of single-byte characters.
Packit 1ac44c
   Even in this simple case, it cannot work with multibyte strings.  */
Packit 1ac44c
# undef strspn
Packit 1ac44c
/* Assume strspn is always declared.  */
Packit 1ac44c
_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
Packit 1ac44c
                 "in multibyte locales - "
Packit 1ac44c
                 "use mbsspn if you care about internationalization");
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if defined GNULIB_POSIXCHECK
Packit 1ac44c
/* strrchr() does not work with multibyte strings if the locale encoding is
Packit 1ac44c
   GB18030 and the character to be searched is a digit.  */
Packit 1ac44c
# undef strrchr
Packit 1ac44c
/* Assume strrchr is always declared.  */
Packit 1ac44c
_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
Packit 1ac44c
                 "in some multibyte locales - "
Packit 1ac44c
                 "use mbsrchr if you care about internationalization");
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
Packit 1ac44c
   If one is found, overwrite it with a NUL, and advance *STRINGP
Packit 1ac44c
   to point to the next char after it.  Otherwise, set *STRINGP to NULL.
Packit 1ac44c
   If *STRINGP was already NULL, nothing happens.
Packit 1ac44c
   Return the old value of *STRINGP.
Packit 1ac44c
Packit 1ac44c
   This is a variant of strtok() that is multithread-safe and supports
Packit 1ac44c
   empty fields.
Packit 1ac44c
Packit 1ac44c
   Caveat: It modifies the original string.
Packit 1ac44c
   Caveat: These functions cannot be used on constant strings.
Packit 1ac44c
   Caveat: The identity of the delimiting character is lost.
Packit 1ac44c
   Caveat: It doesn't work with multibyte strings unless all of the delimiter
Packit 1ac44c
           characters are ASCII characters < 0x30.
Packit 1ac44c
Packit 1ac44c
   See also strtok_r().  */
Packit 1ac44c
#if @GNULIB_STRSEP@
Packit 1ac44c
# if ! @HAVE_STRSEP@
Packit 1ac44c
_GL_FUNCDECL_SYS (strsep, char *,
Packit 1ac44c
                  (char **restrict __stringp, char const *restrict __delim)
Packit 1ac44c
                  _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIAS_SYS (strsep, char *,
Packit 1ac44c
                  (char **restrict __stringp, char const *restrict __delim));
Packit 1ac44c
_GL_CXXALIASWARN (strsep);
Packit 1ac44c
# if defined GNULIB_POSIXCHECK
Packit 1ac44c
#  undef strsep
Packit 1ac44c
_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
Packit 1ac44c
                 "in multibyte locales - "
Packit 1ac44c
                 "use mbssep if you care about internationalization");
Packit 1ac44c
# endif
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef strsep
Packit 1ac44c
# if HAVE_RAW_DECL_STRSEP
Packit 1ac44c
_GL_WARN_ON_USE (strsep, "strsep is unportable - "
Packit 1ac44c
                 "use gnulib module strsep for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_STRSTR@
Packit 1ac44c
# if @REPLACE_STRSTR@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   define strstr rpl_strstr
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
Packit 1ac44c
                                  _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                  _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
Packit 1ac44c
# else
Packit 1ac44c
  /* On some systems, this function is defined as an overloaded function:
Packit 1ac44c
       extern "C++" { const char * strstr (const char *, const char *); }
Packit 1ac44c
       extern "C++" { char * strstr (char *, const char *); }  */
Packit 1ac44c
_GL_CXXALIAS_SYS_CAST2 (strstr,
Packit 1ac44c
                        char *, (const char *haystack, const char *needle),
Packit 1ac44c
                        const char *, (const char *haystack, const char *needle));
Packit 1ac44c
# endif
Packit 1ac44c
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
Packit 1ac44c
     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
Packit 1ac44c
_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
Packit 1ac44c
_GL_CXXALIASWARN1 (strstr, const char *,
Packit 1ac44c
                   (const char *haystack, const char *needle));
Packit 1ac44c
# else
Packit 1ac44c
_GL_CXXALIASWARN (strstr);
Packit 1ac44c
# endif
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
/* strstr() does not work with multibyte strings if the locale encoding is
Packit 1ac44c
   different from UTF-8:
Packit 1ac44c
   POSIX says that it operates on "strings", and "string" in POSIX is defined
Packit 1ac44c
   as a sequence of bytes, not of characters.  */
Packit 1ac44c
# undef strstr
Packit 1ac44c
/* Assume strstr is always declared.  */
Packit 1ac44c
_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
Packit 1ac44c
                 "work correctly on character strings in most "
Packit 1ac44c
                 "multibyte locales - "
Packit 1ac44c
                 "use mbsstr if you care about internationalization, "
Packit 1ac44c
                 "or use strstr if you care about speed");
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
Packit 1ac44c
   comparison.  */
Packit 1ac44c
#if @GNULIB_STRCASESTR@
Packit 1ac44c
# if @REPLACE_STRCASESTR@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   define strcasestr rpl_strcasestr
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (strcasestr, char *,
Packit 1ac44c
                  (const char *haystack, const char *needle)
Packit 1ac44c
                  _GL_ATTRIBUTE_PURE
Packit 1ac44c
                  _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
_GL_CXXALIAS_RPL (strcasestr, char *,
Packit 1ac44c
                  (const char *haystack, const char *needle));
Packit 1ac44c
# else
Packit 1ac44c
#  if ! @HAVE_STRCASESTR@
Packit 1ac44c
_GL_FUNCDECL_SYS (strcasestr, char *,
Packit 1ac44c
                  (const char *haystack, const char *needle)
Packit 1ac44c
                  _GL_ATTRIBUTE_PURE
Packit 1ac44c
                  _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
#  endif
Packit 1ac44c
  /* On some systems, this function is defined as an overloaded function:
Packit 1ac44c
       extern "C++" { const char * strcasestr (const char *, const char *); }
Packit 1ac44c
       extern "C++" { char * strcasestr (char *, const char *); }  */
Packit 1ac44c
_GL_CXXALIAS_SYS_CAST2 (strcasestr,
Packit 1ac44c
                        char *, (const char *haystack, const char *needle),
Packit 1ac44c
                        const char *, (const char *haystack, const char *needle));
Packit 1ac44c
# endif
Packit 1ac44c
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
Packit 1ac44c
     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
Packit 1ac44c
_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
Packit 1ac44c
_GL_CXXALIASWARN1 (strcasestr, const char *,
Packit 1ac44c
                   (const char *haystack, const char *needle));
Packit 1ac44c
# else
Packit 1ac44c
_GL_CXXALIASWARN (strcasestr);
Packit 1ac44c
# endif
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
/* strcasestr() does not work with multibyte strings:
Packit 1ac44c
   It is a glibc extension, and glibc implements it only for unibyte
Packit 1ac44c
   locales.  */
Packit 1ac44c
# undef strcasestr
Packit 1ac44c
# if HAVE_RAW_DECL_STRCASESTR
Packit 1ac44c
_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
Packit 1ac44c
                 "strings in multibyte locales - "
Packit 1ac44c
                 "use mbscasestr if you care about "
Packit 1ac44c
                 "internationalization, or use c-strcasestr if you want "
Packit 1ac44c
                 "a locale independent function");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Parse S into tokens separated by characters in DELIM.
Packit 1ac44c
   If S is NULL, the saved pointer in SAVE_PTR is used as
Packit 1ac44c
   the next starting point.  For example:
Packit 1ac44c
        char s[] = "-abc-=-def";
Packit 1ac44c
        char *sp;
Packit 1ac44c
        x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
Packit 1ac44c
        x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
Packit 1ac44c
        x = strtok_r(NULL, "=", &sp);   // x = NULL
Packit 1ac44c
                // s = "abc\0-def\0"
Packit 1ac44c
Packit 1ac44c
   This is a variant of strtok() that is multithread-safe.
Packit 1ac44c
Packit 1ac44c
   For the POSIX documentation for this function, see:
Packit 1ac44c
   http://www.opengroup.org/susv3xsh/strtok.html
Packit 1ac44c
Packit 1ac44c
   Caveat: It modifies the original string.
Packit 1ac44c
   Caveat: These functions cannot be used on constant strings.
Packit 1ac44c
   Caveat: The identity of the delimiting character is lost.
Packit 1ac44c
   Caveat: It doesn't work with multibyte strings unless all of the delimiter
Packit 1ac44c
           characters are ASCII characters < 0x30.
Packit 1ac44c
Packit 1ac44c
   See also strsep().  */
Packit 1ac44c
#if @GNULIB_STRTOK_R@
Packit 1ac44c
# if @REPLACE_STRTOK_R@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   undef strtok_r
Packit 1ac44c
#   define strtok_r rpl_strtok_r
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (strtok_r, char *,
Packit 1ac44c
                  (char *restrict s, char const *restrict delim,
Packit 1ac44c
                   char **restrict save_ptr)
Packit 1ac44c
                  _GL_ARG_NONNULL ((2, 3)));
Packit 1ac44c
_GL_CXXALIAS_RPL (strtok_r, char *,
Packit 1ac44c
                  (char *restrict s, char const *restrict delim,
Packit 1ac44c
                   char **restrict save_ptr));
Packit 1ac44c
# else
Packit 1ac44c
#  if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
Packit 1ac44c
#   undef strtok_r
Packit 1ac44c
#  endif
Packit 1ac44c
#  if ! @HAVE_DECL_STRTOK_R@
Packit 1ac44c
_GL_FUNCDECL_SYS (strtok_r, char *,
Packit 1ac44c
                  (char *restrict s, char const *restrict delim,
Packit 1ac44c
                   char **restrict save_ptr)
Packit 1ac44c
                  _GL_ARG_NONNULL ((2, 3)));
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_CXXALIAS_SYS (strtok_r, char *,
Packit 1ac44c
                  (char *restrict s, char const *restrict delim,
Packit 1ac44c
                   char **restrict save_ptr));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (strtok_r);
Packit 1ac44c
# if defined GNULIB_POSIXCHECK
Packit 1ac44c
_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
Packit 1ac44c
                 "strings in multibyte locales - "
Packit 1ac44c
                 "use mbstok_r if you care about internationalization");
Packit 1ac44c
# endif
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef strtok_r
Packit 1ac44c
# if HAVE_RAW_DECL_STRTOK_R
Packit 1ac44c
_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
Packit 1ac44c
                 "use gnulib module strtok_r for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
Packit 1ac44c
/* The following functions are not specified by POSIX.  They are gnulib
Packit 1ac44c
   extensions.  */
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSLEN@
Packit 1ac44c
/* Return the number of multibyte characters in the character string STRING.
Packit 1ac44c
   This considers multibyte characters, unlike strlen, which counts bytes.  */
Packit 1ac44c
# ifdef __MirBSD__  /* MirBSD defines mbslen as a macro.  Override it.  */
Packit 1ac44c
#  undef mbslen
Packit 1ac44c
# endif
Packit 1ac44c
# if @HAVE_MBSLEN@  /* AIX, OSF/1, MirBSD define mbslen already in libc.  */
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   define mbslen rpl_mbslen
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string)
Packit 1ac44c
                                  _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                  _GL_ARG_NONNULL ((1)));
Packit 1ac44c
_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
Packit 1ac44c
# else
Packit 1ac44c
_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
Packit 1ac44c
                                  _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                  _GL_ARG_NONNULL ((1)));
Packit 1ac44c
_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (mbslen);
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSNLEN@
Packit 1ac44c
/* Return the number of multibyte characters in the character string starting
Packit 1ac44c
   at STRING and ending at STRING + LEN.  */
Packit 1ac44c
_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
Packit 1ac44c
     _GL_ATTRIBUTE_PURE
Packit 1ac44c
     _GL_ARG_NONNULL ((1));
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSCHR@
Packit 1ac44c
/* Locate the first single-byte character C in the character string STRING,
Packit 1ac44c
   and return a pointer to it.  Return NULL if C is not found in STRING.
Packit 1ac44c
   Unlike strchr(), this function works correctly in multibyte locales with
Packit 1ac44c
   encodings such as GB18030.  */
Packit 1ac44c
# if defined __hpux
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   define mbschr rpl_mbschr /* avoid collision with HP-UX function */
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
Packit 1ac44c
                                  _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                  _GL_ARG_NONNULL ((1)));
Packit 1ac44c
_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
Packit 1ac44c
# else
Packit 1ac44c
_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
Packit 1ac44c
                                  _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                  _GL_ARG_NONNULL ((1)));
Packit 1ac44c
_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (mbschr);
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSRCHR@
Packit 1ac44c
/* Locate the last single-byte character C in the character string STRING,
Packit 1ac44c
   and return a pointer to it.  Return NULL if C is not found in STRING.
Packit 1ac44c
   Unlike strrchr(), this function works correctly in multibyte locales with
Packit 1ac44c
   encodings such as GB18030.  */
Packit 1ac44c
# if defined __hpux || defined __INTERIX
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   define mbsrchr rpl_mbsrchr /* avoid collision with system function */
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
Packit 1ac44c
                                   _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                   _GL_ARG_NONNULL ((1)));
Packit 1ac44c
_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
Packit 1ac44c
# else
Packit 1ac44c
_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
Packit 1ac44c
                                   _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                   _GL_ARG_NONNULL ((1)));
Packit 1ac44c
_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (mbsrchr);
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSSTR@
Packit 1ac44c
/* Find the first occurrence of the character string NEEDLE in the character
Packit 1ac44c
   string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
Packit 1ac44c
   Unlike strstr(), this function works correctly in multibyte locales with
Packit 1ac44c
   encodings different from UTF-8.  */
Packit 1ac44c
_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
Packit 1ac44c
     _GL_ATTRIBUTE_PURE
Packit 1ac44c
     _GL_ARG_NONNULL ((1, 2));
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSCASECMP@
Packit 1ac44c
/* Compare the character strings S1 and S2, ignoring case, returning less than,
Packit 1ac44c
   equal to or greater than zero if S1 is lexicographically less than, equal to
Packit 1ac44c
   or greater than S2.
Packit 1ac44c
   Note: This function may, in multibyte locales, return 0 for strings of
Packit 1ac44c
   different lengths!
Packit 1ac44c
   Unlike strcasecmp(), this function works correctly in multibyte locales.  */
Packit 1ac44c
_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
Packit 1ac44c
     _GL_ATTRIBUTE_PURE
Packit 1ac44c
     _GL_ARG_NONNULL ((1, 2));
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSNCASECMP@
Packit 1ac44c
/* Compare the initial segment of the character string S1 consisting of at most
Packit 1ac44c
   N characters with the initial segment of the character string S2 consisting
Packit 1ac44c
   of at most N characters, ignoring case, returning less than, equal to or
Packit 1ac44c
   greater than zero if the initial segment of S1 is lexicographically less
Packit 1ac44c
   than, equal to or greater than the initial segment of S2.
Packit 1ac44c
   Note: This function may, in multibyte locales, return 0 for initial segments
Packit 1ac44c
   of different lengths!
Packit 1ac44c
   Unlike strncasecmp(), this function works correctly in multibyte locales.
Packit 1ac44c
   But beware that N is not a byte count but a character count!  */
Packit 1ac44c
_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
Packit 1ac44c
     _GL_ATTRIBUTE_PURE
Packit 1ac44c
     _GL_ARG_NONNULL ((1, 2));
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSPCASECMP@
Packit 1ac44c
/* Compare the initial segment of the character string STRING consisting of
Packit 1ac44c
   at most mbslen (PREFIX) characters with the character string PREFIX,
Packit 1ac44c
   ignoring case.  If the two match, return a pointer to the first byte
Packit 1ac44c
   after this prefix in STRING.  Otherwise, return NULL.
Packit 1ac44c
   Note: This function may, in multibyte locales, return non-NULL if STRING
Packit 1ac44c
   is of smaller length than PREFIX!
Packit 1ac44c
   Unlike strncasecmp(), this function works correctly in multibyte
Packit 1ac44c
   locales.  */
Packit 1ac44c
_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
Packit 1ac44c
     _GL_ATTRIBUTE_PURE
Packit 1ac44c
     _GL_ARG_NONNULL ((1, 2));
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSCASESTR@
Packit 1ac44c
/* Find the first occurrence of the character string NEEDLE in the character
Packit 1ac44c
   string HAYSTACK, using case-insensitive comparison.
Packit 1ac44c
   Note: This function may, in multibyte locales, return success even if
Packit 1ac44c
   strlen (haystack) < strlen (needle) !
Packit 1ac44c
   Unlike strcasestr(), this function works correctly in multibyte locales.  */
Packit 1ac44c
_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
Packit 1ac44c
     _GL_ATTRIBUTE_PURE
Packit 1ac44c
     _GL_ARG_NONNULL ((1, 2));
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSCSPN@
Packit 1ac44c
/* Find the first occurrence in the character string STRING of any character
Packit 1ac44c
   in the character string ACCEPT.  Return the number of bytes from the
Packit 1ac44c
   beginning of the string to this occurrence, or to the end of the string
Packit 1ac44c
   if none exists.
Packit 1ac44c
   Unlike strcspn(), this function works correctly in multibyte locales.  */
Packit 1ac44c
_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
Packit 1ac44c
     _GL_ATTRIBUTE_PURE
Packit 1ac44c
     _GL_ARG_NONNULL ((1, 2));
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSPBRK@
Packit 1ac44c
/* Find the first occurrence in the character string STRING of any character
Packit 1ac44c
   in the character string ACCEPT.  Return the pointer to it, or NULL if none
Packit 1ac44c
   exists.
Packit 1ac44c
   Unlike strpbrk(), this function works correctly in multibyte locales.  */
Packit 1ac44c
# if defined __hpux
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
Packit 1ac44c
                                   _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                   _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
Packit 1ac44c
# else
Packit 1ac44c
_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
Packit 1ac44c
                                   _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                   _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (mbspbrk);
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSSPN@
Packit 1ac44c
/* Find the first occurrence in the character string STRING of any character
Packit 1ac44c
   not in the character string REJECT.  Return the number of bytes from the
Packit 1ac44c
   beginning of the string to this occurrence, or to the end of the string
Packit 1ac44c
   if none exists.
Packit 1ac44c
   Unlike strspn(), this function works correctly in multibyte locales.  */
Packit 1ac44c
_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
Packit 1ac44c
     _GL_ATTRIBUTE_PURE
Packit 1ac44c
     _GL_ARG_NONNULL ((1, 2));
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSSEP@
Packit 1ac44c
/* Search the next delimiter (multibyte character listed in the character
Packit 1ac44c
   string DELIM) starting at the character string *STRINGP.
Packit 1ac44c
   If one is found, overwrite it with a NUL, and advance *STRINGP to point
Packit 1ac44c
   to the next multibyte character after it.  Otherwise, set *STRINGP to NULL.
Packit 1ac44c
   If *STRINGP was already NULL, nothing happens.
Packit 1ac44c
   Return the old value of *STRINGP.
Packit 1ac44c
Packit 1ac44c
   This is a variant of mbstok_r() that supports empty fields.
Packit 1ac44c
Packit 1ac44c
   Caveat: It modifies the original string.
Packit 1ac44c
   Caveat: These functions cannot be used on constant strings.
Packit 1ac44c
   Caveat: The identity of the delimiting character is lost.
Packit 1ac44c
Packit 1ac44c
   See also mbstok_r().  */
Packit 1ac44c
_GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
Packit 1ac44c
     _GL_ARG_NONNULL ((1, 2));
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_MBSTOK_R@
Packit 1ac44c
/* Parse the character string STRING into tokens separated by characters in
Packit 1ac44c
   the character string DELIM.
Packit 1ac44c
   If STRING is NULL, the saved pointer in SAVE_PTR is used as
Packit 1ac44c
   the next starting point.  For example:
Packit 1ac44c
        char s[] = "-abc-=-def";
Packit 1ac44c
        char *sp;
Packit 1ac44c
        x = mbstok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
Packit 1ac44c
        x = mbstok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
Packit 1ac44c
        x = mbstok_r(NULL, "=", &sp);   // x = NULL
Packit 1ac44c
                // s = "abc\0-def\0"
Packit 1ac44c
Packit 1ac44c
   Caveat: It modifies the original string.
Packit 1ac44c
   Caveat: These functions cannot be used on constant strings.
Packit 1ac44c
   Caveat: The identity of the delimiting character is lost.
Packit 1ac44c
Packit 1ac44c
   See also mbssep().  */
Packit 1ac44c
_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
Packit 1ac44c
     _GL_ARG_NONNULL ((2, 3));
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Map any int, typically from errno, into an error message.  */
Packit 1ac44c
#if @GNULIB_STRERROR@
Packit 1ac44c
# if @REPLACE_STRERROR@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   undef strerror
Packit 1ac44c
#   define strerror rpl_strerror
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (strerror, char *, (int));
Packit 1ac44c
_GL_CXXALIAS_RPL (strerror, char *, (int));
Packit 1ac44c
# else
Packit 1ac44c
_GL_CXXALIAS_SYS (strerror, char *, (int));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (strerror);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef strerror
Packit 1ac44c
/* Assume strerror is always declared.  */
Packit 1ac44c
_GL_WARN_ON_USE (strerror, "strerror is unportable - "
Packit 1ac44c
                 "use gnulib module strerror to guarantee non-NULL result");
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
/* Map any int, typically from errno, into an error message.  Multithread-safe.
Packit 1ac44c
   Uses the POSIX declaration, not the glibc declaration.  */
Packit 1ac44c
#if @GNULIB_STRERROR_R@
Packit 1ac44c
# if @REPLACE_STRERROR_R@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   undef strerror_r
Packit 1ac44c
#   define strerror_r rpl_strerror_r
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
Packit 1ac44c
                                   _GL_ARG_NONNULL ((2)));
Packit 1ac44c
_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
Packit 1ac44c
# else
Packit 1ac44c
#  if !@HAVE_DECL_STRERROR_R@
Packit 1ac44c
_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
Packit 1ac44c
                                   _GL_ARG_NONNULL ((2)));
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
Packit 1ac44c
# endif
Packit 1ac44c
# if @HAVE_DECL_STRERROR_R@
Packit 1ac44c
_GL_CXXALIASWARN (strerror_r);
Packit 1ac44c
# endif
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef strerror_r
Packit 1ac44c
# if HAVE_RAW_DECL_STRERROR_R
Packit 1ac44c
_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
Packit 1ac44c
                 "use gnulib module strerror_r-posix for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_STRSIGNAL@
Packit 1ac44c
# if @REPLACE_STRSIGNAL@
Packit 1ac44c
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 1ac44c
#   define strsignal rpl_strsignal
Packit 1ac44c
#  endif
Packit 1ac44c
_GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
Packit 1ac44c
_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
Packit 1ac44c
# else
Packit 1ac44c
#  if ! @HAVE_DECL_STRSIGNAL@
Packit 1ac44c
_GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
Packit 1ac44c
#  endif
Packit 1ac44c
/* Need to cast, because on Cygwin 1.5.x systems, the return type is
Packit 1ac44c
   'const char *'.  */
Packit 1ac44c
_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIASWARN (strsignal);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef strsignal
Packit 1ac44c
# if HAVE_RAW_DECL_STRSIGNAL
Packit 1ac44c
_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
Packit 1ac44c
                 "use gnulib module strsignal for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
#if @GNULIB_STRVERSCMP@
Packit 1ac44c
# if !@HAVE_STRVERSCMP@
Packit 1ac44c
_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
Packit 1ac44c
                                   _GL_ATTRIBUTE_PURE
Packit 1ac44c
                                   _GL_ARG_NONNULL ((1, 2)));
Packit 1ac44c
# endif
Packit 1ac44c
_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
Packit 1ac44c
_GL_CXXALIASWARN (strverscmp);
Packit 1ac44c
#elif defined GNULIB_POSIXCHECK
Packit 1ac44c
# undef strverscmp
Packit 1ac44c
# if HAVE_RAW_DECL_STRVERSCMP
Packit 1ac44c
_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
Packit 1ac44c
                 "use gnulib module strverscmp for portability");
Packit 1ac44c
# endif
Packit 1ac44c
#endif
Packit 1ac44c
Packit 1ac44c
Packit 1ac44c
#endif /* _@GUARD_PREFIX@_STRING_H */
Packit 1ac44c
#endif /* _@GUARD_PREFIX@_STRING_H */
Packit 1ac44c
#endif