summaryrefslogtreecommitdiffstats
path: root/gl/string.in.h
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-09-18 20:59:46 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-09-18 20:59:46 (GMT)
commit0e70e81133c25274fe2dd2309556b41357dd759b (patch)
tree9a680b36788ee1ad4e7ecc5ccfeb4494db9fdc72 /gl/string.in.h
parentce355c80cf6054bfa5e1dcf81f9e2183ef963ee1 (diff)
parent2ddc75e69db5a3dd379c896d8420c9af20ec1cee (diff)
downloadmonitoring-plugins-0e70e81133c25274fe2dd2309556b41357dd759b.tar.gz
Merge branch 'master' into mysql_detect_mysqldumprefs/pull/1718/head
Diffstat (limited to 'gl/string.in.h')
-rw-r--r--gl/string.in.h467
1 files changed, 380 insertions, 87 deletions
diff --git a/gl/string.in.h b/gl/string.in.h
index d7a6c9c..e993b2f 100644
--- a/gl/string.in.h
+++ b/gl/string.in.h
@@ -1,30 +1,46 @@
1/* A GNU-like <string.h>. 1/* A GNU-like <string.h>.
2 2
3 Copyright (C) 1995-1996, 2001-2013 Free Software Foundation, Inc. 3 Copyright (C) 1995-1996, 2001-2023 Free Software Foundation, Inc.
4 4
5 This program 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 General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _@GUARD_PREFIX@_STRING_H
19 17
20#if __GNUC__ >= 3 18#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
22#endif 20#endif
23@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
24 22
23#if defined _GL_ALREADY_INCLUDING_STRING_H
24/* Special invocation convention:
25 - On OS X/NetBSD we have a sequence of nested includes
26 <string.h> -> <strings.h> -> "string.h"
27 In this situation system _chk variants due to -D_FORTIFY_SOURCE
28 might be used after any replacements defined here. */
29
30#@INCLUDE_NEXT@ @NEXT_STRING_H@
31
32#else
33/* Normal invocation convention. */
34
35#ifndef _@GUARD_PREFIX@_STRING_H
36
37#define _GL_ALREADY_INCLUDING_STRING_H
38
25/* The include_next requires a split double-inclusion guard. */ 39/* The include_next requires a split double-inclusion guard. */
26#@INCLUDE_NEXT@ @NEXT_STRING_H@ 40#@INCLUDE_NEXT@ @NEXT_STRING_H@
27 41
42#undef _GL_ALREADY_INCLUDING_STRING_H
43
28#ifndef _@GUARD_PREFIX@_STRING_H 44#ifndef _@GUARD_PREFIX@_STRING_H
29#define _@GUARD_PREFIX@_STRING_H 45#define _@GUARD_PREFIX@_STRING_H
30 46
@@ -36,14 +52,6 @@
36# include <wchar.h> 52# include <wchar.h>
37#endif 53#endif
38 54
39/* The __attribute__ feature is available in gcc versions 2.5 and later.
40 The attribute __pure__ was added in gcc 2.96. */
41#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
42# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
43#else
44# define _GL_ATTRIBUTE_PURE /* empty */
45#endif
46
47/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ 55/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */
48/* But in any case avoid namespace pollution on glibc systems. */ 56/* But in any case avoid namespace pollution on glibc systems. */
49#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ 57#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
@@ -51,12 +59,122 @@
51# include <unistd.h> 59# include <unistd.h>
52#endif 60#endif
53 61
62/* AIX 7.2 declares ffsl and ffsll in <strings.h>, not in <string.h>. */
63/* But in any case avoid namespace pollution on glibc systems. */
64#if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \
65 && defined _AIX) \
66 && ! defined __GLIBC__
67# include <strings.h>
68#endif
69
70/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
71 that can be freed by passing them as the Ith argument to the
72 function F. */
73#ifndef _GL_ATTRIBUTE_DEALLOC
74# if __GNUC__ >= 11
75# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
76# else
77# define _GL_ATTRIBUTE_DEALLOC(f, i)
78# endif
79#endif
80
81/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
82 can be freed via 'free'; it can be used only after declaring 'free'. */
83/* Applies to: functions. Cannot be used on inline functions. */
84#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
85# if defined __cplusplus && defined __GNUC__ && !defined __clang__
86/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
87# define _GL_ATTRIBUTE_DEALLOC_FREE \
88 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
89# else
90# define _GL_ATTRIBUTE_DEALLOC_FREE \
91 _GL_ATTRIBUTE_DEALLOC (free, 1)
92# endif
93#endif
94
95/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
96 allocated memory. */
97/* Applies to: functions. */
98#ifndef _GL_ATTRIBUTE_MALLOC
99# if __GNUC__ >= 3 || defined __clang__
100# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
101# else
102# define _GL_ATTRIBUTE_MALLOC
103# endif
104#endif
105
106/* The __attribute__ feature is available in gcc versions 2.5 and later.
107 The attribute __pure__ was added in gcc 2.96. */
108#ifndef _GL_ATTRIBUTE_PURE
109# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
110# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
111# else
112# define _GL_ATTRIBUTE_PURE /* empty */
113# endif
114#endif
115
54/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 116/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
55 117
56/* The definition of _GL_ARG_NONNULL is copied here. */ 118/* The definition of _GL_ARG_NONNULL is copied here. */
57 119
58/* The definition of _GL_WARN_ON_USE is copied here. */ 120/* The definition of _GL_WARN_ON_USE is copied here. */
59 121
122/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
123 been included yet. */
124#if @GNULIB_FREE_POSIX@
125# if (@REPLACE_FREE@ && !defined free \
126 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
127/* We can't do '#define free rpl_free' here. */
128_GL_EXTERN_C void rpl_free (void *);
129# undef _GL_ATTRIBUTE_DEALLOC_FREE
130# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
131# else
132# if defined _MSC_VER && !defined free
133_GL_EXTERN_C
134# if defined _DLL
135 __declspec (dllimport)
136# endif
137 void __cdecl free (void *);
138# else
139# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
140_GL_EXTERN_C void free (void *) throw ();
141# else
142_GL_EXTERN_C void free (void *);
143# endif
144# endif
145# endif
146#else
147# if defined _MSC_VER && !defined free
148_GL_EXTERN_C
149# if defined _DLL
150 __declspec (dllimport)
151# endif
152 void __cdecl free (void *);
153# else
154# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
155_GL_EXTERN_C void free (void *) throw ();
156# else
157_GL_EXTERN_C void free (void *);
158# endif
159# endif
160#endif
161
162/* Clear a block of memory. The compiler will not delete a call to
163 this function, even if the block is dead after the call. */
164#if @GNULIB_EXPLICIT_BZERO@
165# if ! @HAVE_EXPLICIT_BZERO@
166_GL_FUNCDECL_SYS (explicit_bzero, void,
167 (void *__dest, size_t __n) _GL_ARG_NONNULL ((1)));
168# endif
169_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
170_GL_CXXALIASWARN (explicit_bzero);
171#elif defined GNULIB_POSIXCHECK
172# undef explicit_bzero
173# if HAVE_RAW_DECL_EXPLICIT_BZERO
174_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
175 "use gnulib module explicit_bzero for portability");
176# endif
177#endif
60 178
61/* Find the index of the least-significant set bit. */ 179/* Find the index of the least-significant set bit. */
62#if @GNULIB_FFSL@ 180#if @GNULIB_FFSL@
@@ -75,10 +193,18 @@ _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
75 193
76/* Find the index of the least-significant set bit. */ 194/* Find the index of the least-significant set bit. */
77#if @GNULIB_FFSLL@ 195#if @GNULIB_FFSLL@
78# if !@HAVE_FFSLL@ 196# if @REPLACE_FFSLL@
197# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
198# define ffsll rpl_ffsll
199# endif
200_GL_FUNCDECL_RPL (ffsll, int, (long long int i));
201_GL_CXXALIAS_RPL (ffsll, int, (long long int i));
202# else
203# if !@HAVE_FFSLL@
79_GL_FUNCDECL_SYS (ffsll, int, (long long int i)); 204_GL_FUNCDECL_SYS (ffsll, int, (long long int i));
80# endif 205# endif
81_GL_CXXALIAS_SYS (ffsll, int, (long long int i)); 206_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
207# endif
82_GL_CXXALIASWARN (ffsll); 208_GL_CXXALIASWARN (ffsll);
83#elif defined GNULIB_POSIXCHECK 209#elif defined GNULIB_POSIXCHECK
84# undef ffsll 210# undef ffsll
@@ -88,10 +214,30 @@ _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
88#endif 214#endif
89 215
90 216
217#if @GNULIB_MDA_MEMCCPY@
218/* On native Windows, map 'memccpy' to '_memccpy', so that -loldnames is not
219 required. In C++ with GNULIB_NAMESPACE, avoid differences between
220 platforms by defining GNULIB_NAMESPACE::memccpy always. */
221# if defined _WIN32 && !defined __CYGWIN__
222# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
223# undef memccpy
224# define memccpy _memccpy
225# endif
226_GL_CXXALIAS_MDA (memccpy, void *,
227 (void *dest, const void *src, int c, size_t n));
228# else
229_GL_CXXALIAS_SYS (memccpy, void *,
230 (void *dest, const void *src, int c, size_t n));
231# endif
232_GL_CXXALIASWARN (memccpy);
233#endif
234
235
91/* Return the first instance of C within N bytes of S, or NULL. */ 236/* Return the first instance of C within N bytes of S, or NULL. */
92#if @GNULIB_MEMCHR@ 237#if @GNULIB_MEMCHR@
93# if @REPLACE_MEMCHR@ 238# if @REPLACE_MEMCHR@
94# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 239# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
240# undef memchr
95# define memchr rpl_memchr 241# define memchr rpl_memchr
96# endif 242# endif
97_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) 243_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
@@ -99,11 +245,6 @@ _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
99 _GL_ARG_NONNULL ((1))); 245 _GL_ARG_NONNULL ((1)));
100_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); 246_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
101# else 247# else
102# if ! @HAVE_MEMCHR@
103_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
104 _GL_ATTRIBUTE_PURE
105 _GL_ARG_NONNULL ((1)));
106# endif
107 /* On some systems, this function is defined as an overloaded function: 248 /* On some systems, this function is defined as an overloaded function:
108 extern "C" { const void * std::memchr (const void *, int, size_t); } 249 extern "C" { const void * std::memchr (const void *, int, size_t); }
109 extern "C++" { void * std::memchr (void *, int, size_t); } */ 250 extern "C++" { void * std::memchr (void *, int, size_t); } */
@@ -112,11 +253,12 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
112 void const *, (void const *__s, int __c, size_t __n)); 253 void const *, (void const *__s, int __c, size_t __n));
113# endif 254# endif
114# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 255# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
115 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 256 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
116_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); 257 || defined __clang__)
258_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n) throw ());
117_GL_CXXALIASWARN1 (memchr, void const *, 259_GL_CXXALIASWARN1 (memchr, void const *,
118 (void const *__s, int __c, size_t __n)); 260 (void const *__s, int __c, size_t __n) throw ());
119# else 261# elif __GLIBC__ >= 2
120_GL_CXXALIASWARN (memchr); 262_GL_CXXALIASWARN (memchr);
121# endif 263# endif
122#elif defined GNULIB_POSIXCHECK 264#elif defined GNULIB_POSIXCHECK
@@ -197,9 +339,10 @@ _GL_CXXALIAS_SYS_CAST2 (memrchr,
197 void *, (void const *, int, size_t), 339 void *, (void const *, int, size_t),
198 void const *, (void const *, int, size_t)); 340 void const *, (void const *, int, size_t));
199# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 341# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
200 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 342 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
201_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); 343 || defined __clang__)
202_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); 344_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t) throw ());
345_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t) throw ());
203# else 346# else
204_GL_CXXALIASWARN (memrchr); 347_GL_CXXALIASWARN (memrchr);
205# endif 348# endif
@@ -211,6 +354,23 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
211# endif 354# endif
212#endif 355#endif
213 356
357/* Overwrite a block of memory. The compiler will not optimize
358 effects away, even if the block is dead after the call. */
359#if @GNULIB_MEMSET_EXPLICIT@
360# if ! @HAVE_MEMSET_EXPLICIT@
361_GL_FUNCDECL_SYS (memset_explicit, void *,
362 (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1)));
363# endif
364_GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n));
365_GL_CXXALIASWARN (memset_explicit);
366#elif defined GNULIB_POSIXCHECK
367# undef memset_explicit
368# if HAVE_RAW_DECL_MEMSET_EXPLICIT
369_GL_WARN_ON_USE (memset_explicit, "memset_explicit is unportable - "
370 "use gnulib module memset_explicit for portability");
371# endif
372#endif
373
214/* Find the first occurrence of C in S. More efficient than 374/* Find the first occurrence of C in S. More efficient than
215 memchr(S,C,N), at the expense of undefined behavior if C does not 375 memchr(S,C,N), at the expense of undefined behavior if C does not
216 occur within N bytes. */ 376 occur within N bytes. */
@@ -227,9 +387,11 @@ _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
227 void *, (void const *__s, int __c_in), 387 void *, (void const *__s, int __c_in),
228 void const *, (void const *__s, int __c_in)); 388 void const *, (void const *__s, int __c_in));
229# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 389# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
230 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 390 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
231_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); 391 || defined __clang__)
232_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); 392_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in) throw ());
393_GL_CXXALIASWARN1 (rawmemchr, void const *,
394 (void const *__s, int __c_in) throw ());
233# else 395# else
234_GL_CXXALIASWARN (rawmemchr); 396_GL_CXXALIASWARN (rawmemchr);
235# endif 397# endif
@@ -299,9 +461,11 @@ _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
299 GB18030 and the character to be searched is a digit. */ 461 GB18030 and the character to be searched is a digit. */
300# undef strchr 462# undef strchr
301/* Assume strchr is always declared. */ 463/* Assume strchr is always declared. */
302_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " 464_GL_WARN_ON_USE_CXX (strchr,
303 "in some multibyte locales - " 465 const char *, char *, (const char *, int),
304 "use mbschr if you care about internationalization"); 466 "strchr cannot work correctly on character strings "
467 "in some multibyte locales - "
468 "use mbschr if you care about internationalization");
305#endif 469#endif
306 470
307/* Find the first occurrence of C in S or the final NUL byte. */ 471/* Find the first occurrence of C in S or the final NUL byte. */
@@ -329,9 +493,11 @@ _GL_CXXALIAS_SYS_CAST2 (strchrnul,
329 char const *, (char const *__s, int __c_in)); 493 char const *, (char const *__s, int __c_in));
330# endif 494# endif
331# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 495# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
332 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 496 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
333_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); 497 || defined __clang__)
334_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); 498_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in) throw ());
499_GL_CXXALIASWARN1 (strchrnul, char const *,
500 (char const *__s, int __c_in) throw ());
335# else 501# else
336_GL_CXXALIASWARN (strchrnul); 502_GL_CXXALIASWARN (strchrnul);
337# endif 503# endif
@@ -350,24 +516,62 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
350# undef strdup 516# undef strdup
351# define strdup rpl_strdup 517# define strdup rpl_strdup
352# endif 518# endif
353_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); 519_GL_FUNCDECL_RPL (strdup, char *,
520 (char const *__s)
521 _GL_ARG_NONNULL ((1))
522 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
354_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); 523_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
524# elif defined _WIN32 && !defined __CYGWIN__
525# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
526# undef strdup
527# define strdup _strdup
528# endif
529_GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
355# else 530# else
356# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup 531# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
357 /* strdup exists as a function and as a macro. Get rid of the macro. */ 532 /* strdup exists as a function and as a macro. Get rid of the macro. */
358# undef strdup 533# undef strdup
359# endif 534# endif
360# if !(@HAVE_DECL_STRDUP@ || defined strdup) 535# if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup
361_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); 536_GL_FUNCDECL_SYS (strdup, char *,
537 (char const *__s)
538 _GL_ARG_NONNULL ((1))
539 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
362# endif 540# endif
363_GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); 541_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
364# endif 542# endif
365_GL_CXXALIASWARN (strdup); 543_GL_CXXALIASWARN (strdup);
366#elif defined GNULIB_POSIXCHECK 544#else
367# undef strdup 545# if __GNUC__ >= 11 && !defined strdup
368# if HAVE_RAW_DECL_STRDUP 546/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */
547_GL_FUNCDECL_SYS (strdup, char *,
548 (char const *__s)
549 _GL_ARG_NONNULL ((1))
550 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
551# endif
552# if defined GNULIB_POSIXCHECK
553# undef strdup
554# if HAVE_RAW_DECL_STRDUP
369_GL_WARN_ON_USE (strdup, "strdup is unportable - " 555_GL_WARN_ON_USE (strdup, "strdup is unportable - "
370 "use gnulib module strdup for portability"); 556 "use gnulib module strdup for portability");
557# endif
558# elif @GNULIB_MDA_STRDUP@
559/* On native Windows, map 'creat' to '_creat', so that -loldnames is not
560 required. In C++ with GNULIB_NAMESPACE, avoid differences between
561 platforms by defining GNULIB_NAMESPACE::strdup always. */
562# if defined _WIN32 && !defined __CYGWIN__
563# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
564# undef strdup
565# define strdup _strdup
566# endif
567_GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
568# else
569# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
570# undef strdup
571# endif
572_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
573# endif
574_GL_CXXALIASWARN (strdup);
371# endif 575# endif
372#endif 576#endif
373 577
@@ -378,13 +582,18 @@ _GL_WARN_ON_USE (strdup, "strdup is unportable - "
378# undef strncat 582# undef strncat
379# define strncat rpl_strncat 583# define strncat rpl_strncat
380# endif 584# endif
381_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) 585_GL_FUNCDECL_RPL (strncat, char *,
382 _GL_ARG_NONNULL ((1, 2))); 586 (char *restrict dest, const char *restrict src, size_t n)
383_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); 587 _GL_ARG_NONNULL ((1, 2)));
588_GL_CXXALIAS_RPL (strncat, char *,
589 (char *restrict dest, const char *restrict src, size_t n));
384# else 590# else
385_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); 591_GL_CXXALIAS_SYS (strncat, char *,
592 (char *restrict dest, const char *restrict src, size_t n));
386# endif 593# endif
594# if __GLIBC__ >= 2
387_GL_CXXALIASWARN (strncat); 595_GL_CXXALIASWARN (strncat);
596# endif
388#elif defined GNULIB_POSIXCHECK 597#elif defined GNULIB_POSIXCHECK
389# undef strncat 598# undef strncat
390# if HAVE_RAW_DECL_STRNCAT 599# if HAVE_RAW_DECL_STRNCAT
@@ -400,22 +609,35 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
400# undef strndup 609# undef strndup
401# define strndup rpl_strndup 610# define strndup rpl_strndup
402# endif 611# endif
403_GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n) 612_GL_FUNCDECL_RPL (strndup, char *,
404 _GL_ARG_NONNULL ((1))); 613 (char const *__s, size_t __n)
405_GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n)); 614 _GL_ARG_NONNULL ((1))
615 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
616_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
406# else 617# else
407# if ! @HAVE_DECL_STRNDUP@ 618# if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup)
408_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n) 619_GL_FUNCDECL_SYS (strndup, char *,
409 _GL_ARG_NONNULL ((1))); 620 (char const *__s, size_t __n)
621 _GL_ARG_NONNULL ((1))
622 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
410# endif 623# endif
411_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n)); 624_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
412# endif 625# endif
413_GL_CXXALIASWARN (strndup); 626_GL_CXXALIASWARN (strndup);
414#elif defined GNULIB_POSIXCHECK 627#else
415# undef strndup 628# if __GNUC__ >= 11 && !defined strndup
416# if HAVE_RAW_DECL_STRNDUP 629/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */
630_GL_FUNCDECL_SYS (strndup, char *,
631 (char const *__s, size_t __n)
632 _GL_ARG_NONNULL ((1))
633 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
634# endif
635# if defined GNULIB_POSIXCHECK
636# undef strndup
637# if HAVE_RAW_DECL_STRNDUP
417_GL_WARN_ON_USE (strndup, "strndup is unportable - " 638_GL_WARN_ON_USE (strndup, "strndup is unportable - "
418 "use gnulib module strndup for portability"); 639 "use gnulib module strndup for portability");
640# endif
419# endif 641# endif
420#endif 642#endif
421 643
@@ -428,17 +650,17 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
428# undef strnlen 650# undef strnlen
429# define strnlen rpl_strnlen 651# define strnlen rpl_strnlen
430# endif 652# endif
431_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) 653_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)
432 _GL_ATTRIBUTE_PURE 654 _GL_ATTRIBUTE_PURE
433 _GL_ARG_NONNULL ((1))); 655 _GL_ARG_NONNULL ((1)));
434_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); 656_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
435# else 657# else
436# if ! @HAVE_DECL_STRNLEN@ 658# if ! @HAVE_DECL_STRNLEN@
437_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) 659_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)
438 _GL_ATTRIBUTE_PURE 660 _GL_ATTRIBUTE_PURE
439 _GL_ARG_NONNULL ((1))); 661 _GL_ARG_NONNULL ((1)));
440# endif 662# endif
441_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); 663_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
442# endif 664# endif
443_GL_CXXALIASWARN (strnlen); 665_GL_CXXALIASWARN (strnlen);
444#elif defined GNULIB_POSIXCHECK 666#elif defined GNULIB_POSIXCHECK
@@ -475,11 +697,12 @@ _GL_CXXALIAS_SYS_CAST2 (strpbrk,
475 char *, (char const *__s, char const *__accept), 697 char *, (char const *__s, char const *__accept),
476 const char *, (char const *__s, char const *__accept)); 698 const char *, (char const *__s, char const *__accept));
477# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 699# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
478 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 700 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
479_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); 701 || defined __clang__)
702_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept) throw ());
480_GL_CXXALIASWARN1 (strpbrk, char const *, 703_GL_CXXALIASWARN1 (strpbrk, char const *,
481 (char const *__s, char const *__accept)); 704 (char const *__s, char const *__accept) throw ());
482# else 705# elif __GLIBC__ >= 2
483_GL_CXXALIASWARN (strpbrk); 706_GL_CXXALIASWARN (strpbrk);
484# endif 707# endif
485# if defined GNULIB_POSIXCHECK 708# if defined GNULIB_POSIXCHECK
@@ -488,15 +711,19 @@ _GL_CXXALIASWARN (strpbrk);
488 locale encoding is GB18030 and one of the characters to be searched is a 711 locale encoding is GB18030 and one of the characters to be searched is a
489 digit. */ 712 digit. */
490# undef strpbrk 713# undef strpbrk
491_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " 714_GL_WARN_ON_USE_CXX (strpbrk,
492 "in multibyte locales - " 715 const char *, char *, (const char *, const char *),
493 "use mbspbrk if you care about internationalization"); 716 "strpbrk cannot work correctly on character strings "
717 "in multibyte locales - "
718 "use mbspbrk if you care about internationalization");
494# endif 719# endif
495#elif defined GNULIB_POSIXCHECK 720#elif defined GNULIB_POSIXCHECK
496# undef strpbrk 721# undef strpbrk
497# if HAVE_RAW_DECL_STRPBRK 722# if HAVE_RAW_DECL_STRPBRK
498_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " 723_GL_WARN_ON_USE_CXX (strpbrk,
499 "use gnulib module strpbrk for portability"); 724 const char *, char *, (const char *, const char *),
725 "strpbrk is unportable - "
726 "use gnulib module strpbrk for portability");
500# endif 727# endif
501#endif 728#endif
502 729
@@ -515,9 +742,11 @@ _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
515 GB18030 and the character to be searched is a digit. */ 742 GB18030 and the character to be searched is a digit. */
516# undef strrchr 743# undef strrchr
517/* Assume strrchr is always declared. */ 744/* Assume strrchr is always declared. */
518_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " 745_GL_WARN_ON_USE_CXX (strrchr,
519 "in some multibyte locales - " 746 const char *, char *, (const char *, int),
520 "use mbsrchr if you care about internationalization"); 747 "strrchr cannot work correctly on character strings "
748 "in some multibyte locales - "
749 "use mbsrchr if you care about internationalization");
521#endif 750#endif
522 751
523/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. 752/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
@@ -577,11 +806,13 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
577 const char *, (const char *haystack, const char *needle)); 806 const char *, (const char *haystack, const char *needle));
578# endif 807# endif
579# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 808# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
580 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 809 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
581_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); 810 || defined __clang__)
811_GL_CXXALIASWARN1 (strstr, char *,
812 (char *haystack, const char *needle) throw ());
582_GL_CXXALIASWARN1 (strstr, const char *, 813_GL_CXXALIASWARN1 (strstr, const char *,
583 (const char *haystack, const char *needle)); 814 (const char *haystack, const char *needle) throw ());
584# else 815# elif __GLIBC__ >= 2
585_GL_CXXALIASWARN (strstr); 816_GL_CXXALIASWARN (strstr);
586# endif 817# endif
587#elif defined GNULIB_POSIXCHECK 818#elif defined GNULIB_POSIXCHECK
@@ -626,10 +857,12 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
626 const char *, (const char *haystack, const char *needle)); 857 const char *, (const char *haystack, const char *needle));
627# endif 858# endif
628# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 859# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
629 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 860 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
630_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); 861 || defined __clang__)
862_GL_CXXALIASWARN1 (strcasestr, char *,
863 (char *haystack, const char *needle) throw ());
631_GL_CXXALIASWARN1 (strcasestr, const char *, 864_GL_CXXALIASWARN1 (strcasestr, const char *,
632 (const char *haystack, const char *needle)); 865 (const char *haystack, const char *needle) throw ());
633# else 866# else
634_GL_CXXALIASWARN (strcasestr); 867_GL_CXXALIASWARN (strcasestr);
635# endif 868# endif
@@ -660,7 +893,7 @@ _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
660 This is a variant of strtok() that is multithread-safe. 893 This is a variant of strtok() that is multithread-safe.
661 894
662 For the POSIX documentation for this function, see: 895 For the POSIX documentation for this function, see:
663 http://www.opengroup.org/susv3xsh/strtok.html 896 https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html
664 897
665 Caveat: It modifies the original string. 898 Caveat: It modifies the original string.
666 Caveat: These functions cannot be used on constant strings. 899 Caveat: These functions cannot be used on constant strings.
@@ -734,7 +967,9 @@ _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
734 _GL_ARG_NONNULL ((1))); 967 _GL_ARG_NONNULL ((1)));
735_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); 968_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
736# endif 969# endif
970# if __GLIBC__ >= 2
737_GL_CXXALIASWARN (mbslen); 971_GL_CXXALIASWARN (mbslen);
972# endif
738#endif 973#endif
739 974
740#if @GNULIB_MBSNLEN@ 975#if @GNULIB_MBSNLEN@
@@ -931,7 +1166,8 @@ _GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
931 Caveat: The identity of the delimiting character is lost. 1166 Caveat: The identity of the delimiting character is lost.
932 1167
933 See also mbssep(). */ 1168 See also mbssep(). */
934_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr) 1169_GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
1170 char **save_ptr)
935 _GL_ARG_NONNULL ((2, 3)); 1171 _GL_ARG_NONNULL ((2, 3));
936#endif 1172#endif
937 1173
@@ -947,7 +1183,9 @@ _GL_CXXALIAS_RPL (strerror, char *, (int));
947# else 1183# else
948_GL_CXXALIAS_SYS (strerror, char *, (int)); 1184_GL_CXXALIAS_SYS (strerror, char *, (int));
949# endif 1185# endif
1186# if __GLIBC__ >= 2
950_GL_CXXALIASWARN (strerror); 1187_GL_CXXALIASWARN (strerror);
1188# endif
951#elif defined GNULIB_POSIXCHECK 1189#elif defined GNULIB_POSIXCHECK
952# undef strerror 1190# undef strerror
953/* Assume strerror is always declared. */ 1191/* Assume strerror is always declared. */
@@ -984,6 +1222,60 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
984# endif 1222# endif
985#endif 1223#endif
986 1224
1225/* Return the name of the system error code ERRNUM. */
1226#if @GNULIB_STRERRORNAME_NP@
1227# if @REPLACE_STRERRORNAME_NP@
1228# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1229# undef strerrorname_np
1230# define strerrorname_np rpl_strerrorname_np
1231# endif
1232_GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum));
1233_GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum));
1234# else
1235# if !@HAVE_STRERRORNAME_NP@
1236_GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum));
1237# endif
1238_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum));
1239# endif
1240_GL_CXXALIASWARN (strerrorname_np);
1241#elif defined GNULIB_POSIXCHECK
1242# undef strerrorname_np
1243# if HAVE_RAW_DECL_STRERRORNAME_NP
1244_GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - "
1245 "use gnulib module strerrorname_np for portability");
1246# endif
1247#endif
1248
1249/* Return an abbreviation string for the signal number SIG. */
1250#if @GNULIB_SIGABBREV_NP@
1251# if ! @HAVE_SIGABBREV_NP@
1252_GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig));
1253# endif
1254_GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig));
1255_GL_CXXALIASWARN (sigabbrev_np);
1256#elif defined GNULIB_POSIXCHECK
1257# undef sigabbrev_np
1258# if HAVE_RAW_DECL_SIGABBREV_NP
1259_GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - "
1260 "use gnulib module sigabbrev_np for portability");
1261# endif
1262#endif
1263
1264/* Return an English description string for the signal number SIG. */
1265#if @GNULIB_SIGDESCR_NP@
1266# if ! @HAVE_SIGDESCR_NP@
1267_GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig));
1268# endif
1269_GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig));
1270_GL_CXXALIASWARN (sigdescr_np);
1271#elif defined GNULIB_POSIXCHECK
1272# undef sigdescr_np
1273# if HAVE_RAW_DECL_SIGDESCR_NP
1274_GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - "
1275 "use gnulib module sigdescr_np for portability");
1276# endif
1277#endif
1278
987#if @GNULIB_STRSIGNAL@ 1279#if @GNULIB_STRSIGNAL@
988# if @REPLACE_STRSIGNAL@ 1280# if @REPLACE_STRSIGNAL@
989# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1281# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1027,3 +1319,4 @@ _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1027 1319
1028#endif /* _@GUARD_PREFIX@_STRING_H */ 1320#endif /* _@GUARD_PREFIX@_STRING_H */
1029#endif /* _@GUARD_PREFIX@_STRING_H */ 1321#endif /* _@GUARD_PREFIX@_STRING_H */
1322#endif