20 #pragma GCC system_header 24 #if defined _GL_ALREADY_INCLUDING_STRING_H 31 #include_next <string.h> 38 #define _GL_ALREADY_INCLUDING_STRING_H 41 #include_next <string.h> 43 #undef _GL_ALREADY_INCLUDING_STRING_H 52 #if 0 && defined __MirBSD__ 58 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 59 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 61 # define _GL_ATTRIBUTE_PURE 66 #if (0 || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ 67 && ! defined __GLIBC__ 76 #if defined __cplusplus && defined GNULIB_NAMESPACE 77 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { 78 # define _GL_END_NAMESPACE } 80 # define _GL_BEGIN_NAMESPACE 81 # define _GL_END_NAMESPACE 145 #if defined __cplusplus 146 # define _GL_EXTERN_C extern "C" 148 # define _GL_EXTERN_C extern 158 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 159 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 160 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 161 _GL_EXTERN_C rettype rpl_func parameters_and_attributes 170 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 171 _GL_EXTERN_C rettype func parameters_and_attributes 182 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 183 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 184 #if defined __cplusplus && defined GNULIB_NAMESPACE 185 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 186 namespace GNULIB_NAMESPACE \ 188 static const struct _gl_ ## func ## _wrapper \ 190 typedef rettype (*type) parameters; \ 191 inline type rpl () const { return ::rpl_func; } \ 192 inline operator type () const { return rpl (); } \ 195 _GL_EXTERN_C int _gl_cxxalias_dummy 197 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 198 _GL_EXTERN_C int _gl_cxxalias_dummy 206 #if defined __cplusplus && defined GNULIB_NAMESPACE 207 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 208 namespace GNULIB_NAMESPACE \ 210 static const struct _gl_ ## func ## _wrapper \ 212 typedef rettype (*type) parameters; \ 213 inline type rpl () const \ 214 { return reinterpret_cast<type>(::rpl_func); } \ 215 inline operator type () const { return rpl (); } \ 218 _GL_EXTERN_C int _gl_cxxalias_dummy 220 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 221 _GL_EXTERN_C int _gl_cxxalias_dummy 234 #if defined __cplusplus && defined GNULIB_NAMESPACE 235 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 236 namespace GNULIB_NAMESPACE \ 238 static const struct _gl_ ## func ## _wrapper \ 240 typedef rettype (*type) parameters; \ 241 inline type rpl () const { return ::func; } \ 242 inline operator type () const { return rpl (); } \ 245 _GL_EXTERN_C int _gl_cxxalias_dummy 247 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 248 _GL_EXTERN_C int _gl_cxxalias_dummy 256 #if defined __cplusplus && defined GNULIB_NAMESPACE 257 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 258 namespace GNULIB_NAMESPACE \ 260 static const struct _gl_ ## func ## _wrapper \ 262 typedef rettype (*type) parameters; \ 263 inline type rpl () const \ 264 { return reinterpret_cast<type>(::func); } \ 265 inline operator type () const { return rpl (); }\ 268 _GL_EXTERN_C int _gl_cxxalias_dummy 270 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 271 _GL_EXTERN_C int _gl_cxxalias_dummy 280 #if defined __cplusplus && defined GNULIB_NAMESPACE 286 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 287 namespace GNULIB_NAMESPACE \ 289 static const struct _gl_ ## func ## _wrapper \ 291 typedef rettype (*type) parameters; \ 293 inline type rpl () const \ 294 { return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); }\ 296 inline operator type () const { return rpl (); } \ 299 _GL_EXTERN_C int _gl_cxxalias_dummy 301 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 302 _GL_EXTERN_C int _gl_cxxalias_dummy 309 #if defined __cplusplus && defined GNULIB_NAMESPACE 310 # define _GL_CXXALIASWARN(func) \ 311 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 312 # define _GL_CXXALIASWARN_1(func,namespace) \ 313 _GL_CXXALIASWARN_2 (func, namespace) 317 # define _GL_CXXALIASWARN_2(func,namespace) \ 318 _GL_WARN_ON_USE (func, \ 319 "The symbol ::" #func " refers to the system function. " \ 320 "Use " #namespace "::" #func " instead.") 321 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 322 # define _GL_CXXALIASWARN_2(func,namespace) \ 323 extern __typeof__ (func) func 325 # define _GL_CXXALIASWARN_2(func,namespace) \ 326 _GL_EXTERN_C int _gl_cxxalias_dummy 329 # define _GL_CXXALIASWARN(func) \ 330 _GL_EXTERN_C int _gl_cxxalias_dummy 336 #if defined __cplusplus && defined GNULIB_NAMESPACE 337 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 338 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 340 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 341 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 345 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 346 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 347 "The symbol ::" #func " refers to the system function. " \ 348 "Use " #namespace "::" #func " instead.") 349 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 350 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 351 extern __typeof__ (func) func 353 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 354 _GL_EXTERN_C int _gl_cxxalias_dummy 357 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 358 _GL_EXTERN_C int _gl_cxxalias_dummy 367 #ifndef _GL_ARG_NONNULL 368 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 369 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 371 # define _GL_ARG_NONNULL(params) 376 #ifndef _GL_WARN_ON_USE 378 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 380 # define _GL_WARN_ON_USE(function, message) \ 381 extern __typeof__ (function) function __attribute__ ((__warning__ (message))) 382 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 384 # define _GL_WARN_ON_USE(function, message) \ 385 extern __typeof__ (function) function 387 # define _GL_WARN_ON_USE(function, message) \ 388 _GL_WARN_EXTERN_C int _gl_warn_on_use 398 #ifndef _GL_WARN_ON_USE_CXX 399 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 400 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 401 extern rettype function parameters_and_attributes \ 402 __attribute__ ((__warning__ (msg))) 403 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 405 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 406 extern rettype function parameters_and_attributes 408 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 409 _GL_WARN_EXTERN_C int _gl_warn_on_use 415 #ifndef _GL_WARN_EXTERN_C 416 # if defined __cplusplus 417 # define _GL_WARN_EXTERN_C extern "C" 419 # define _GL_WARN_EXTERN_C extern 431 #elif defined GNULIB_POSIXCHECK 433 # if HAVE_RAW_DECL_FFSL 446 #elif defined GNULIB_POSIXCHECK 448 # if HAVE_RAW_DECL_FFSLL 449 _GL_WARN_ON_USE (ffsll,
"ffsll is not portable - use the ffsll module");
457 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 458 # define memchr rpl_memchr 474 void *, (
void const *__s,
int __c,
size_t __n),
475 void const *, (
void const *__s,
int __c,
size_t __n));
477 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 478 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 481 (
void const *__s,
int __c,
size_t __n));
485 #elif defined GNULIB_POSIXCHECK 489 "use gnulib module memchr for portability" );
495 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 496 # define memmem rpl_memmem 499 (
void const *__haystack,
size_t __haystack_len,
500 void const *__needle,
size_t __needle_len)
504 (
void const *__haystack,
size_t __haystack_len,
505 void const *__needle,
size_t __needle_len));
509 (
void const *__haystack,
size_t __haystack_len,
510 void const *__needle,
size_t __needle_len)
515 (
void const *__haystack,
size_t __haystack_len,
516 void const *__needle,
size_t __needle_len));
519 #elif defined GNULIB_POSIXCHECK 521 # if HAVE_RAW_DECL_MEMMEM 523 "use gnulib module memmem-simple for portability, " 524 "and module memmem for speed" );
541 #elif defined GNULIB_POSIXCHECK 543 # if HAVE_RAW_DECL_MEMPCPY 545 "use gnulib module mempcpy for portability");
560 void *, (
void const *,
int,
size_t),
561 void const *, (
void const *,
int,
size_t));
562 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 563 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 569 #elif defined GNULIB_POSIXCHECK 571 # if HAVE_RAW_DECL_MEMRCHR 573 "use gnulib module memrchr for portability");
590 void *, (
void const *__s,
int __c_in),
591 void const *, (
void const *__s,
int __c_in));
592 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 593 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 599 #elif defined GNULIB_POSIXCHECK 601 # if HAVE_RAW_DECL_RAWMEMCHR 603 "use gnulib module rawmemchr for portability");
617 #elif defined GNULIB_POSIXCHECK 619 # if HAVE_RAW_DECL_STPCPY 621 "use gnulib module stpcpy for portability");
629 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 631 # define stpncpy rpl_stpncpy 652 #elif defined GNULIB_POSIXCHECK 654 # if HAVE_RAW_DECL_STPNCPY 656 "use gnulib module stpncpy for portability");
660 #if defined GNULIB_POSIXCHECK 665 _GL_WARN_ON_USE (strchr,
"strchr cannot work correctly on character strings " 666 "in some multibyte locales - " 667 "use mbschr if you care about internationalization");
673 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 674 # define strchrnul rpl_strchrnul 680 (
const char *str,
int ch));
691 char *, (
char const *__s,
int __c_in),
692 char const *, (
char const *__s,
int __c_in));
694 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 695 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 701 #elif defined GNULIB_POSIXCHECK 703 # if HAVE_RAW_DECL_STRCHRNUL 705 "use gnulib module strchrnul for portability");
712 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 714 # define strdup rpl_strdup 719 # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup 723 # if !(1 || defined strdup) 729 #elif defined GNULIB_POSIXCHECK 731 # if HAVE_RAW_DECL_STRDUP 733 "use gnulib module strdup for portability");
740 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 742 # define strncat rpl_strncat 746 _GL_CXXALIAS_RPL (strncat,
char *, (
char *dest,
const char *src,
size_t n));
748 _GL_CXXALIAS_SYS (strncat,
char *, (
char *dest,
const char *src,
size_t n));
751 #elif defined GNULIB_POSIXCHECK 753 # if HAVE_RAW_DECL_STRNCAT 755 "use gnulib module strncat for portability");
762 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 764 # define strndup rpl_strndup 777 #elif defined GNULIB_POSIXCHECK 779 # if HAVE_RAW_DECL_STRNDUP 781 "use gnulib module strndup for portability");
790 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 792 # define strnlen rpl_strnlen 807 #elif defined GNULIB_POSIXCHECK 809 # if HAVE_RAW_DECL_STRNLEN 811 "use gnulib module strnlen for portability");
815 #if defined GNULIB_POSIXCHECK 822 _GL_WARN_ON_USE (strcspn,
"strcspn cannot work correctly on character strings " 823 "in multibyte locales - " 824 "use mbscspn if you care about internationalization");
838 char *, (
char const *__s,
char const *__accept),
839 const char *, (
char const *__s,
char const *__accept));
840 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 841 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 844 (
char const *__s,
char const *__accept));
848 # if defined GNULIB_POSIXCHECK 854 _GL_WARN_ON_USE (strpbrk,
"strpbrk cannot work correctly on character strings " 855 "in multibyte locales - " 856 "use mbspbrk if you care about internationalization");
858 #elif defined GNULIB_POSIXCHECK 860 # if HAVE_RAW_DECL_STRPBRK 862 "use gnulib module strpbrk for portability");
866 #if defined GNULIB_POSIXCHECK 871 _GL_WARN_ON_USE (strspn,
"strspn cannot work correctly on character strings " 872 "in multibyte locales - " 873 "use mbsspn if you care about internationalization");
876 #if defined GNULIB_POSIXCHECK 881 _GL_WARN_ON_USE (strrchr,
"strrchr cannot work correctly on character strings " 882 "in some multibyte locales - " 883 "use mbsrchr if you care about internationalization");
911 # if defined GNULIB_POSIXCHECK 913 _GL_WARN_ON_USE (strsep,
"strsep cannot work correctly on character strings " 914 "in multibyte locales - " 915 "use mbssep if you care about internationalization");
917 #elif defined GNULIB_POSIXCHECK 919 # if HAVE_RAW_DECL_STRSEP 921 "use gnulib module strsep for portability");
927 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 928 # define strstr rpl_strstr 930 _GL_FUNCDECL_RPL (strstr,
char *, (
const char *haystack,
const char *needle)
933 _GL_CXXALIAS_RPL (strstr,
char *, (
const char *haystack,
const char *needle));
939 char *, (
const char *haystack,
const char *needle),
940 const char *, (
const char *haystack,
const char *needle));
942 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 943 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 946 (
const char *haystack,
const char *needle));
950 #elif defined GNULIB_POSIXCHECK 957 _GL_WARN_ON_USE (strstr,
"strstr is quadratic on many systems, and cannot " 958 "work correctly on character strings in most " 959 "multibyte locales - " 960 "use mbsstr if you care about internationalization, " 961 "or use strstr if you care about speed");
968 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 969 # define strcasestr rpl_strcasestr 972 (
const char *haystack,
const char *needle)
976 (
const char *haystack,
const char *needle));
980 (
const char *haystack,
const char *needle)
988 char *, (
const char *haystack,
const char *needle),
989 const char *, (
const char *haystack,
const char *needle));
991 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 992 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 995 (
const char *haystack,
const char *needle));
999 #elif defined GNULIB_POSIXCHECK 1004 # if HAVE_RAW_DECL_STRCASESTR 1005 _GL_WARN_ON_USE (strcasestr,
"strcasestr does work correctly on character " 1006 "strings in multibyte locales - " 1007 "use mbscasestr if you care about " 1008 "internationalization, or use c-strcasestr if you want " 1009 "a locale independent function");
1037 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1039 # define strtok_r rpl_strtok_r 1049 # if 0 || defined GNULIB_POSIXCHECK 1063 # if defined GNULIB_POSIXCHECK 1064 _GL_WARN_ON_USE (strtok_r,
"strtok_r cannot work correctly on character " 1065 "strings in multibyte locales - " 1066 "use mbstok_r if you care about internationalization");
1068 #elif defined GNULIB_POSIXCHECK 1070 # if HAVE_RAW_DECL_STRTOK_R 1072 "use gnulib module strtok_r for portability");
1087 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1088 # define mbslen rpl_mbslen 1106 _GL_EXTERN_C size_t mbsnlen (
const char *
string,
size_t len)
1117 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1118 # define mbschr rpl_mbschr 1138 # if defined __hpux || defined __INTERIX 1139 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1140 # define mbsrchr rpl_mbsrchr 1160 _GL_EXTERN_C char * mbsstr (
const char *haystack,
const char *needle)
1172 _GL_EXTERN_C int mbscasecmp (
const char *s1,
const char *s2)
1187 _GL_EXTERN_C int mbsncasecmp (
const char *s1,
const char *s2,
size_t n)
1201 _GL_EXTERN_C char * mbspcasecmp (
const char *
string,
const char *prefix)
1212 _GL_EXTERN_C char * mbscasestr (
const char *haystack,
const char *needle)
1223 _GL_EXTERN_C size_t mbscspn (
const char *
string,
const char *accept)
1234 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1235 # define mbspbrk rpl_mbspbrk 1237 _GL_FUNCDECL_RPL (mbspbrk,
char *, (
const char *
string,
const char *accept)
1240 _GL_CXXALIAS_RPL (mbspbrk,
char *, (
const char *
string,
const char *accept));
1242 _GL_FUNCDECL_SYS (mbspbrk,
char *, (
const char *
string,
const char *accept)
1245 _GL_CXXALIAS_SYS (mbspbrk,
char *, (
const char *
string,
const char *accept));
1256 _GL_EXTERN_C size_t mbsspn (
const char *
string,
const char *reject)
1276 _GL_EXTERN_C char * mbssep (
char **stringp,
const char *delim)
1297 _GL_EXTERN_C char * mbstok_r (
char *
string,
const char *delim,
char **save_ptr)
1304 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1306 # define strerror rpl_strerror 1314 #elif defined GNULIB_POSIXCHECK 1318 "use gnulib module strerror to guarantee non-NULL result");
1325 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1327 # define strerror_r rpl_strerror_r 1331 _GL_CXXALIAS_RPL (strerror_r,
int, (
int errnum,
char *buf,
size_t buflen));
1337 _GL_CXXALIAS_SYS (strerror_r,
int, (
int errnum,
char *buf,
size_t buflen));
1342 #elif defined GNULIB_POSIXCHECK 1344 # if HAVE_RAW_DECL_STRERROR_R 1346 "use gnulib module strerror_r-posix for portability");
1352 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1353 # define strsignal rpl_strsignal 1366 #elif defined GNULIB_POSIXCHECK 1368 # if HAVE_RAW_DECL_STRSIGNAL 1370 "use gnulib module strsignal for portability");
1382 #elif defined GNULIB_POSIXCHECK 1384 # if HAVE_RAW_DECL_STRVERSCMP 1386 "use gnulib module strverscmp for portability");
#define _GL_CXXALIAS_SYS_CAST2(func, rettype, parameters, rettype2, parameters2)
#define _GL_ATTRIBUTE_PURE
#define _GL_CXXALIASWARN(func)
#define _GL_CXXALIAS_SYS(func, rettype, parameters)
#define _GL_CXXALIAS_SYS_CAST(func, rettype, parameters)
#define _GL_CXXALIAS_RPL(func, rettype, parameters)
#define _GL_ARG_NONNULL(params)
#define _GL_CXXALIASWARN1(func, rettype, parameters_and_attributes)
#define _GL_FUNCDECL_RPL(func, rettype, parameters_and_attributes)
#define _GL_WARN_ON_USE(function, message)
#define _GL_FUNCDECL_SYS(func, rettype, parameters_and_attributes)