root/lib/string.in.h

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

/* [<][>][^][v][top][bottom][index][help] */