Blame gl/string.in.h

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