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