22 #pragma GCC system_header
27 #include_next <string.h>
36 #if 0 && defined __MirBSD__
42 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
43 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
45 # define _GL_ATTRIBUTE_PURE
50 #if (0 || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
51 && ! defined __GLIBC__
120 #if defined __cplusplus
121 # define _GL_EXTERN_C extern "C"
123 # define _GL_EXTERN_C extern
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
145 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
146 _GL_EXTERN_C rettype func parameters_and_attributes
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 \
160 rettype (*const func) parameters = ::rpl_func; \
162 _GL_EXTERN_C int _gl_cxxalias_dummy
164 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
165 _GL_EXTERN_C int _gl_cxxalias_dummy
173 #if defined __cplusplus && defined GNULIB_NAMESPACE
174 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
175 namespace GNULIB_NAMESPACE \
177 rettype (*const func) parameters = \
178 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
180 _GL_EXTERN_C int _gl_cxxalias_dummy
182 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
183 _GL_EXTERN_C int _gl_cxxalias_dummy
193 #if defined __cplusplus && defined GNULIB_NAMESPACE
200 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
201 namespace GNULIB_NAMESPACE \
203 static rettype (*func) parameters = ::func; \
205 _GL_EXTERN_C int _gl_cxxalias_dummy
207 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
208 _GL_EXTERN_C int _gl_cxxalias_dummy
216 #if defined __cplusplus && defined GNULIB_NAMESPACE
217 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
218 namespace GNULIB_NAMESPACE \
220 static rettype (*func) parameters = \
221 reinterpret_cast<rettype(*)parameters>(::func); \
223 _GL_EXTERN_C int _gl_cxxalias_dummy
225 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
226 _GL_EXTERN_C int _gl_cxxalias_dummy
235 #if defined __cplusplus && defined GNULIB_NAMESPACE
241 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
242 namespace GNULIB_NAMESPACE \
244 static rettype (*func) parameters = \
245 reinterpret_cast<rettype(*)parameters>( \
246 (rettype2(*)parameters2)(::func)); \
248 _GL_EXTERN_C int _gl_cxxalias_dummy
250 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
251 _GL_EXTERN_C int _gl_cxxalias_dummy
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)
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
274 # define _GL_CXXALIASWARN_2(func,namespace) \
275 _GL_EXTERN_C int _gl_cxxalias_dummy
278 # define _GL_CXXALIASWARN(func) \
279 _GL_EXTERN_C int _gl_cxxalias_dummy
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, \
289 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
290 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
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
302 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
303 _GL_EXTERN_C int _gl_cxxalias_dummy
306 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
307 _GL_EXTERN_C int _gl_cxxalias_dummy
316 #ifndef _GL_ARG_NONNULL
317 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
318 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
320 # define _GL_ARG_NONNULL(params)
325 #ifndef _GL_WARN_ON_USE
327 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
329 # define _GL_WARN_ON_USE(function, message) \
330 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
331 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
333 # define _GL_WARN_ON_USE(function, message) \
334 extern __typeof__ (function) function
336 # define _GL_WARN_ON_USE(function, message) \
337 _GL_WARN_EXTERN_C int _gl_warn_on_use
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) \
350 extern rettype function parameters_and_attributes \
351 __attribute__ ((__warning__ (msg)))
352 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
354 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
355 extern rettype function parameters_and_attributes
357 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
358 _GL_WARN_EXTERN_C int _gl_warn_on_use
364 #ifndef _GL_WARN_EXTERN_C
365 # if defined __cplusplus
366 # define _GL_WARN_EXTERN_C extern "C"
368 # define _GL_WARN_EXTERN_C extern
380 #elif defined GNULIB_POSIXCHECK
382 # if HAVE_RAW_DECL_FFSL
395 #elif defined GNULIB_POSIXCHECK
397 # if HAVE_RAW_DECL_FFSLL
398 _GL_WARN_ON_USE (ffsll,
"ffsll is not portable - use the ffsll module");
406 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
407 # define memchr rpl_memchr
423 void *, (
void const *__s,
int __c,
size_t __n),
424 void const *, (
void const *__s,
int __c,
size_t __n));
426 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
427 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
430 (
void const *__s,
int __c,
size_t __n));
434 #elif defined GNULIB_POSIXCHECK
438 "use gnulib module memchr for portability" );
444 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
445 # define memmem rpl_memmem
448 (
void const *__haystack,
size_t __haystack_len,
449 void const *__needle,
size_t __needle_len)
453 (
void const *__haystack,
size_t __haystack_len,
454 void const *__needle,
size_t __needle_len));
458 (
void const *__haystack,
size_t __haystack_len,
459 void const *__needle,
size_t __needle_len)
464 (
void const *__haystack,
size_t __haystack_len,
465 void const *__needle,
size_t __needle_len));
468 #elif defined GNULIB_POSIXCHECK
470 # if HAVE_RAW_DECL_MEMMEM
472 "use gnulib module memmem-simple for portability, "
473 "and module memmem for speed" );
490 #elif defined GNULIB_POSIXCHECK
492 # if HAVE_RAW_DECL_MEMPCPY
494 "use gnulib module mempcpy for portability");
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))
518 #elif defined GNULIB_POSIXCHECK
520 # if HAVE_RAW_DECL_MEMRCHR
522 "use gnulib module memrchr for portability");
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))
548 #elif defined GNULIB_POSIXCHECK
550 # if HAVE_RAW_DECL_RAWMEMCHR
552 "use gnulib module rawmemchr for portability");
566 #elif defined GNULIB_POSIXCHECK
568 # if HAVE_RAW_DECL_STPCPY
570 "use gnulib module stpcpy for portability");
578 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
580 # define stpncpy rpl_stpncpy
601 #elif defined GNULIB_POSIXCHECK
603 # if HAVE_RAW_DECL_STPNCPY
605 "use gnulib module stpncpy for portability");
609 #if defined GNULIB_POSIXCHECK
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");
622 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
623 # define strchrnul rpl_strchrnul
629 (
const char *str,
int ch));
640 char *, (
char const *__s,
int __c_in),
641 char const *, (
char const *__s,
int __c_in));
643 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
644 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
650 #elif defined GNULIB_POSIXCHECK
652 # if HAVE_RAW_DECL_STRCHRNUL
654 "use gnulib module strchrnul for portability");
661 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
663 # define strdup rpl_strdup
668 # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
672 # if !(1 || defined strdup)
678 #elif defined GNULIB_POSIXCHECK
680 # if HAVE_RAW_DECL_STRDUP
682 "use gnulib module strdup for portability");
689 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
691 # define strncat rpl_strncat
695 _GL_CXXALIAS_RPL (strncat,
char *, (
char *dest,
const char *src,
size_t n));
697 _GL_CXXALIAS_SYS (strncat,
char *, (
char *dest,
const char *src,
size_t n));
700 #elif defined GNULIB_POSIXCHECK
702 # if HAVE_RAW_DECL_STRNCAT
704 "use gnulib module strncat for portability");
711 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
713 # define strndup rpl_strndup
726 #elif defined GNULIB_POSIXCHECK
728 # if HAVE_RAW_DECL_STRNDUP
730 "use gnulib module strndup for portability");
739 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
741 # define strnlen rpl_strnlen
746 _GL_CXXALIAS_RPL (strnlen,
size_t, (
char const *__string,
size_t __maxlen));
753 _GL_CXXALIAS_SYS (strnlen,
size_t, (
char const *__string,
size_t __maxlen));
756 #elif defined GNULIB_POSIXCHECK
758 # if HAVE_RAW_DECL_STRNLEN
760 "use gnulib module strnlen for portability");
764 #if defined GNULIB_POSIXCHECK
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");
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))
793 (
char const *__s,
char const *__accept));
797 # if defined GNULIB_POSIXCHECK
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");
807 #elif defined GNULIB_POSIXCHECK
809 # if HAVE_RAW_DECL_STRPBRK
811 "use gnulib module strpbrk for portability");
815 #if defined GNULIB_POSIXCHECK
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");
825 #if defined GNULIB_POSIXCHECK
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");
860 # if defined GNULIB_POSIXCHECK
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");
866 #elif defined GNULIB_POSIXCHECK
868 # if HAVE_RAW_DECL_STRSEP
870 "use gnulib module strsep for portability");
876 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
877 # define strstr rpl_strstr
879 _GL_FUNCDECL_RPL (strstr,
char *, (
const char *haystack,
const char *needle)
882 _GL_CXXALIAS_RPL (strstr,
char *, (
const char *haystack,
const char *needle));
888 char *, (
const char *haystack,
const char *needle),
889 const char *, (
const char *haystack,
const char *needle));
891 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
892 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
895 (
const char *haystack,
const char *needle));
899 #elif defined GNULIB_POSIXCHECK
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");
917 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
918 # define strcasestr rpl_strcasestr
921 (
const char *haystack,
const char *needle)
925 (
const char *haystack,
const char *needle));
929 (
const char *haystack,
const char *needle)
937 char *, (
const char *haystack,
const char *needle),
938 const char *, (
const char *haystack,
const char *needle));
940 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
941 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
944 (
const char *haystack,
const char *needle));
948 #elif defined GNULIB_POSIXCHECK
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");
986 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
988 # define strtok_r rpl_strtok_r
998 # if 0 || defined GNULIB_POSIXCHECK
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");
1017 #elif defined GNULIB_POSIXCHECK
1019 # if HAVE_RAW_DECL_STRTOK_R
1021 "use gnulib module strtok_r for portability");
1036 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1037 # define mbslen rpl_mbslen
1055 _GL_EXTERN_C size_t mbsnlen (
const char *
string,
size_t len)
1066 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1067 # define mbschr rpl_mbschr
1087 # if defined __hpux || defined __INTERIX
1088 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1089 # define mbsrchr rpl_mbsrchr
1109 _GL_EXTERN_C char * mbsstr (
const char *haystack,
const char *needle)
1121 _GL_EXTERN_C int mbscasecmp (
const char *s1,
const char *s2)
1136 _GL_EXTERN_C int mbsncasecmp (
const char *s1,
const char *s2,
size_t n)
1150 _GL_EXTERN_C char * mbspcasecmp (
const char *
string,
const char *prefix)
1161 _GL_EXTERN_C char * mbscasestr (
const char *haystack,
const char *needle)
1172 _GL_EXTERN_C size_t mbscspn (
const char *
string,
const char *accept)
1183 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1184 # define mbspbrk rpl_mbspbrk
1186 _GL_FUNCDECL_RPL (mbspbrk,
char *, (
const char *
string,
const char *accept)
1189 _GL_CXXALIAS_RPL (mbspbrk,
char *, (
const char *
string,
const char *accept));
1191 _GL_FUNCDECL_SYS (mbspbrk,
char *, (
const char *
string,
const char *accept)
1194 _GL_CXXALIAS_SYS (mbspbrk,
char *, (
const char *
string,
const char *accept));
1205 _GL_EXTERN_C size_t mbsspn (
const char *
string,
const char *reject)
1225 _GL_EXTERN_C char * mbssep (
char **stringp,
const char *delim)
1246 _GL_EXTERN_C char * mbstok_r (
char *
string,
const char *delim,
char **save_ptr)
1253 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1255 # define strerror rpl_strerror
1263 #elif defined GNULIB_POSIXCHECK
1267 "use gnulib module strerror to guarantee non-NULL result");
1274 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1276 # define strerror_r rpl_strerror_r
1280 _GL_CXXALIAS_RPL (strerror_r,
int, (
int errnum,
char *buf,
size_t buflen));
1286 _GL_CXXALIAS_SYS (strerror_r,
int, (
int errnum,
char *buf,
size_t buflen));
1291 #elif defined GNULIB_POSIXCHECK
1293 # if HAVE_RAW_DECL_STRERROR_R
1295 "use gnulib module strerror_r-posix for portability");
1301 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1302 # define strsignal rpl_strsignal
1315 #elif defined GNULIB_POSIXCHECK
1317 # if HAVE_RAW_DECL_STRSIGNAL
1319 "use gnulib module strsignal for portability");
1331 #elif defined GNULIB_POSIXCHECK
1333 # if HAVE_RAW_DECL_STRVERSCMP
1335 "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)