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