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