summaryrefslogtreecommitdiffstats
path: root/gl/string.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/string.in.h')
-rw-r--r--gl/string.in.h120
1 files changed, 87 insertions, 33 deletions
diff --git a/gl/string.in.h b/gl/string.in.h
index afe7350..3996da9 100644
--- a/gl/string.in.h
+++ b/gl/string.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <string.h>. 1/* A GNU-like <string.h>.
2 2
3 Copyright (C) 1995-1996, 2001-2021 Free Software Foundation, Inc. 3 Copyright (C) 1995-1996, 2001-2022 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -112,13 +112,43 @@
112 112
113/* The definition of _GL_WARN_ON_USE is copied here. */ 113/* The definition of _GL_WARN_ON_USE is copied here. */
114 114
115/* Declare 'free' if needed for _GL_ATTRIBUTE_DEALLOC_FREE. */ 115/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
116_GL_EXTERN_C void free (void *); 116 been included yet. */
117#if @GNULIB_FREE_POSIX@ 117#if @GNULIB_FREE_POSIX@
118# if (@REPLACE_FREE@ && !defined free \ 118# if (@REPLACE_FREE@ && !defined free \
119 && !(defined __cplusplus && defined GNULIB_NAMESPACE)) 119 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
120# define free rpl_free 120/* We can't do '#define free rpl_free' here. */
121_GL_EXTERN_C void rpl_free (void *);
122# undef _GL_ATTRIBUTE_DEALLOC_FREE
123# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
124# else
125# if defined _MSC_VER && !defined free
126_GL_EXTERN_C
127# if defined _DLL
128 __declspec (dllimport)
129# endif
130 void __cdecl free (void *);
131# else
132# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
133_GL_EXTERN_C void free (void *) throw ();
134# else
121_GL_EXTERN_C void free (void *); 135_GL_EXTERN_C void free (void *);
136# endif
137# endif
138# endif
139#else
140# if defined _MSC_VER && !defined free
141_GL_EXTERN_C
142# if defined _DLL
143 __declspec (dllimport)
144# endif
145 void __cdecl free (void *);
146# else
147# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
148_GL_EXTERN_C void free (void *) throw ();
149# else
150_GL_EXTERN_C void free (void *);
151# endif
122# endif 152# endif
123#endif 153#endif
124 154
@@ -216,10 +246,11 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
216 void const *, (void const *__s, int __c, size_t __n)); 246 void const *, (void const *__s, int __c, size_t __n));
217# endif 247# endif
218# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 248# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
219 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 249 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
220_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); 250 || defined __clang__)
251_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n) throw ());
221_GL_CXXALIASWARN1 (memchr, void const *, 252_GL_CXXALIASWARN1 (memchr, void const *,
222 (void const *__s, int __c, size_t __n)); 253 (void const *__s, int __c, size_t __n) throw ());
223# elif __GLIBC__ >= 2 254# elif __GLIBC__ >= 2
224_GL_CXXALIASWARN (memchr); 255_GL_CXXALIASWARN (memchr);
225# endif 256# endif
@@ -301,9 +332,10 @@ _GL_CXXALIAS_SYS_CAST2 (memrchr,
301 void *, (void const *, int, size_t), 332 void *, (void const *, int, size_t),
302 void const *, (void const *, int, size_t)); 333 void const *, (void const *, int, size_t));
303# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 334# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
304 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 335 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
305_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); 336 || defined __clang__)
306_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); 337_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t) throw ());
338_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t) throw ());
307# else 339# else
308_GL_CXXALIASWARN (memrchr); 340_GL_CXXALIASWARN (memrchr);
309# endif 341# endif
@@ -331,9 +363,11 @@ _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
331 void *, (void const *__s, int __c_in), 363 void *, (void const *__s, int __c_in),
332 void const *, (void const *__s, int __c_in)); 364 void const *, (void const *__s, int __c_in));
333# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 365# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
334 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 366 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
335_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); 367 || defined __clang__)
336_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); 368_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in) throw ());
369_GL_CXXALIASWARN1 (rawmemchr, void const *,
370 (void const *__s, int __c_in) throw ());
337# else 371# else
338_GL_CXXALIASWARN (rawmemchr); 372_GL_CXXALIASWARN (rawmemchr);
339# endif 373# endif
@@ -435,9 +469,11 @@ _GL_CXXALIAS_SYS_CAST2 (strchrnul,
435 char const *, (char const *__s, int __c_in)); 469 char const *, (char const *__s, int __c_in));
436# endif 470# endif
437# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 471# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
438 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 472 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
439_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); 473 || defined __clang__)
440_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); 474_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in) throw ());
475_GL_CXXALIASWARN1 (strchrnul, char const *,
476 (char const *__s, int __c_in) throw ());
441# else 477# else
442_GL_CXXALIASWARN (strchrnul); 478_GL_CXXALIASWARN (strchrnul);
443# endif 479# endif
@@ -549,22 +585,35 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
549# undef strndup 585# undef strndup
550# define strndup rpl_strndup 586# define strndup rpl_strndup
551# endif 587# endif
552_GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n) 588_GL_FUNCDECL_RPL (strndup, char *,
553 _GL_ARG_NONNULL ((1))); 589 (char const *__s, size_t __n)
590 _GL_ARG_NONNULL ((1))
591 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
554_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); 592_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
555# else 593# else
556# if ! @HAVE_DECL_STRNDUP@ 594# if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup)
557_GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n) 595_GL_FUNCDECL_SYS (strndup, char *,
558 _GL_ARG_NONNULL ((1))); 596 (char const *__s, size_t __n)
597 _GL_ARG_NONNULL ((1))
598 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
559# endif 599# endif
560_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n)); 600_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
561# endif 601# endif
562_GL_CXXALIASWARN (strndup); 602_GL_CXXALIASWARN (strndup);
563#elif defined GNULIB_POSIXCHECK 603#else
564# undef strndup 604# if __GNUC__ >= 11 && !defined strndup
565# if HAVE_RAW_DECL_STRNDUP 605/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */
606_GL_FUNCDECL_SYS (strndup, char *,
607 (char const *__s, size_t __n)
608 _GL_ARG_NONNULL ((1))
609 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
610# endif
611# if defined GNULIB_POSIXCHECK
612# undef strndup
613# if HAVE_RAW_DECL_STRNDUP
566_GL_WARN_ON_USE (strndup, "strndup is unportable - " 614_GL_WARN_ON_USE (strndup, "strndup is unportable - "
567 "use gnulib module strndup for portability"); 615 "use gnulib module strndup for portability");
616# endif
568# endif 617# endif
569#endif 618#endif
570 619
@@ -624,10 +673,11 @@ _GL_CXXALIAS_SYS_CAST2 (strpbrk,
624 char *, (char const *__s, char const *__accept), 673 char *, (char const *__s, char const *__accept),
625 const char *, (char const *__s, char const *__accept)); 674 const char *, (char const *__s, char const *__accept));
626# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 675# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
627 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 676 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
628_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); 677 || defined __clang__)
678_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept) throw ());
629_GL_CXXALIASWARN1 (strpbrk, char const *, 679_GL_CXXALIASWARN1 (strpbrk, char const *,
630 (char const *__s, char const *__accept)); 680 (char const *__s, char const *__accept) throw ());
631# elif __GLIBC__ >= 2 681# elif __GLIBC__ >= 2
632_GL_CXXALIASWARN (strpbrk); 682_GL_CXXALIASWARN (strpbrk);
633# endif 683# endif
@@ -732,10 +782,12 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
732 const char *, (const char *haystack, const char *needle)); 782 const char *, (const char *haystack, const char *needle));
733# endif 783# endif
734# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 784# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
735 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 785 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
736_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); 786 || defined __clang__)
787_GL_CXXALIASWARN1 (strstr, char *,
788 (char *haystack, const char *needle) throw ());
737_GL_CXXALIASWARN1 (strstr, const char *, 789_GL_CXXALIASWARN1 (strstr, const char *,
738 (const char *haystack, const char *needle)); 790 (const char *haystack, const char *needle) throw ());
739# elif __GLIBC__ >= 2 791# elif __GLIBC__ >= 2
740_GL_CXXALIASWARN (strstr); 792_GL_CXXALIASWARN (strstr);
741# endif 793# endif
@@ -781,10 +833,12 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
781 const char *, (const char *haystack, const char *needle)); 833 const char *, (const char *haystack, const char *needle));
782# endif 834# endif
783# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 835# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
784 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 836 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
785_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); 837 || defined __clang__)
838_GL_CXXALIASWARN1 (strcasestr, char *,
839 (char *haystack, const char *needle) throw ());
786_GL_CXXALIASWARN1 (strcasestr, const char *, 840_GL_CXXALIASWARN1 (strcasestr, const char *,
787 (const char *haystack, const char *needle)); 841 (const char *haystack, const char *needle) throw ());
788# else 842# else
789_GL_CXXALIASWARN (strcasestr); 843_GL_CXXALIASWARN (strcasestr);
790# endif 844# endif