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.h441
1 files changed, 354 insertions, 87 deletions
diff --git a/gl/string.in.h b/gl/string.in.h
index d7a6c9c..3996da9 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-2022 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,115 @@
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# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
86#endif
87
88/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
89 allocated memory. */
90/* Applies to: functions. */
91#ifndef _GL_ATTRIBUTE_MALLOC
92# if __GNUC__ >= 3 || defined __clang__
93# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
94# else
95# define _GL_ATTRIBUTE_MALLOC
96# endif
97#endif
98
99/* The __attribute__ feature is available in gcc versions 2.5 and later.
100 The attribute __pure__ was added in gcc 2.96. */
101#ifndef _GL_ATTRIBUTE_PURE
102# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
103# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
104# else
105# define _GL_ATTRIBUTE_PURE /* empty */
106# endif
107#endif
108
54/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 109/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
55 110
56/* The definition of _GL_ARG_NONNULL is copied here. */ 111/* The definition of _GL_ARG_NONNULL is copied here. */
57 112
58/* The definition of _GL_WARN_ON_USE is copied here. */ 113/* The definition of _GL_WARN_ON_USE is copied here. */
59 114
115/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
116 been included yet. */
117#if @GNULIB_FREE_POSIX@
118# if (@REPLACE_FREE@ && !defined free \
119 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
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
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
152# endif
153#endif
154
155/* Clear a block of memory. The compiler will not delete a call to
156 this function, even if the block is dead after the call. */
157#if @GNULIB_EXPLICIT_BZERO@
158# if ! @HAVE_EXPLICIT_BZERO@
159_GL_FUNCDECL_SYS (explicit_bzero, void,
160 (void *__dest, size_t __n) _GL_ARG_NONNULL ((1)));
161# endif
162_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
163_GL_CXXALIASWARN (explicit_bzero);
164#elif defined GNULIB_POSIXCHECK
165# undef explicit_bzero
166# if HAVE_RAW_DECL_EXPLICIT_BZERO
167_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
168 "use gnulib module explicit_bzero for portability");
169# endif
170#endif
60 171
61/* Find the index of the least-significant set bit. */ 172/* Find the index of the least-significant set bit. */
62#if @GNULIB_FFSL@ 173#if @GNULIB_FFSL@
@@ -75,10 +186,18 @@ _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
75 186
76/* Find the index of the least-significant set bit. */ 187/* Find the index of the least-significant set bit. */
77#if @GNULIB_FFSLL@ 188#if @GNULIB_FFSLL@
78# if !@HAVE_FFSLL@ 189# if @REPLACE_FFSLL@
190# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
191# define ffsll rpl_ffsll
192# endif
193_GL_FUNCDECL_RPL (ffsll, int, (long long int i));
194_GL_CXXALIAS_RPL (ffsll, int, (long long int i));
195# else
196# if !@HAVE_FFSLL@
79_GL_FUNCDECL_SYS (ffsll, int, (long long int i)); 197_GL_FUNCDECL_SYS (ffsll, int, (long long int i));
80# endif 198# endif
81_GL_CXXALIAS_SYS (ffsll, int, (long long int i)); 199_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
200# endif
82_GL_CXXALIASWARN (ffsll); 201_GL_CXXALIASWARN (ffsll);
83#elif defined GNULIB_POSIXCHECK 202#elif defined GNULIB_POSIXCHECK
84# undef ffsll 203# undef ffsll
@@ -88,10 +207,30 @@ _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
88#endif 207#endif
89 208
90 209
210#if @GNULIB_MDA_MEMCCPY@
211/* On native Windows, map 'memccpy' to '_memccpy', so that -loldnames is not
212 required. In C++ with GNULIB_NAMESPACE, avoid differences between
213 platforms by defining GNULIB_NAMESPACE::memccpy always. */
214# if defined _WIN32 && !defined __CYGWIN__
215# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
216# undef memccpy
217# define memccpy _memccpy
218# endif
219_GL_CXXALIAS_MDA (memccpy, void *,
220 (void *dest, const void *src, int c, size_t n));
221# else
222_GL_CXXALIAS_SYS (memccpy, void *,
223 (void *dest, const void *src, int c, size_t n));
224# endif
225_GL_CXXALIASWARN (memccpy);
226#endif
227
228
91/* Return the first instance of C within N bytes of S, or NULL. */ 229/* Return the first instance of C within N bytes of S, or NULL. */
92#if @GNULIB_MEMCHR@ 230#if @GNULIB_MEMCHR@
93# if @REPLACE_MEMCHR@ 231# if @REPLACE_MEMCHR@
94# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 232# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
233# undef memchr
95# define memchr rpl_memchr 234# define memchr rpl_memchr
96# endif 235# endif
97_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) 236_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
@@ -99,11 +238,6 @@ _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
99 _GL_ARG_NONNULL ((1))); 238 _GL_ARG_NONNULL ((1)));
100_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); 239_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
101# else 240# 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: 241 /* On some systems, this function is defined as an overloaded function:
108 extern "C" { const void * std::memchr (const void *, int, size_t); } 242 extern "C" { const void * std::memchr (const void *, int, size_t); }
109 extern "C++" { void * std::memchr (void *, int, size_t); } */ 243 extern "C++" { void * std::memchr (void *, int, size_t); } */
@@ -112,11 +246,12 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
112 void const *, (void const *__s, int __c, size_t __n)); 246 void const *, (void const *__s, int __c, size_t __n));
113# endif 247# endif
114# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 248# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
115 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 249 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
116_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 ());
117_GL_CXXALIASWARN1 (memchr, void const *, 252_GL_CXXALIASWARN1 (memchr, void const *,
118 (void const *__s, int __c, size_t __n)); 253 (void const *__s, int __c, size_t __n) throw ());
119# else 254# elif __GLIBC__ >= 2
120_GL_CXXALIASWARN (memchr); 255_GL_CXXALIASWARN (memchr);
121# endif 256# endif
122#elif defined GNULIB_POSIXCHECK 257#elif defined GNULIB_POSIXCHECK
@@ -197,9 +332,10 @@ _GL_CXXALIAS_SYS_CAST2 (memrchr,
197 void *, (void const *, int, size_t), 332 void *, (void const *, int, size_t),
198 void const *, (void const *, int, size_t)); 333 void const *, (void const *, int, size_t));
199# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 334# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
200 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 335 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
201_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); 336 || defined __clang__)
202_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 ());
203# else 339# else
204_GL_CXXALIASWARN (memrchr); 340_GL_CXXALIASWARN (memrchr);
205# endif 341# endif
@@ -227,9 +363,11 @@ _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
227 void *, (void const *__s, int __c_in), 363 void *, (void const *__s, int __c_in),
228 void const *, (void const *__s, int __c_in)); 364 void const *, (void const *__s, int __c_in));
229# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 365# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
230 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 366 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
231_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); 367 || defined __clang__)
232_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 ());
233# else 371# else
234_GL_CXXALIASWARN (rawmemchr); 372_GL_CXXALIASWARN (rawmemchr);
235# endif 373# endif
@@ -299,9 +437,11 @@ _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
299 GB18030 and the character to be searched is a digit. */ 437 GB18030 and the character to be searched is a digit. */
300# undef strchr 438# undef strchr
301/* Assume strchr is always declared. */ 439/* Assume strchr is always declared. */
302_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " 440_GL_WARN_ON_USE_CXX (strchr,
303 "in some multibyte locales - " 441 const char *, char *, (const char *, int),
304 "use mbschr if you care about internationalization"); 442 "strchr cannot work correctly on character strings "
443 "in some multibyte locales - "
444 "use mbschr if you care about internationalization");
305#endif 445#endif
306 446
307/* Find the first occurrence of C in S or the final NUL byte. */ 447/* Find the first occurrence of C in S or the final NUL byte. */
@@ -329,9 +469,11 @@ _GL_CXXALIAS_SYS_CAST2 (strchrnul,
329 char const *, (char const *__s, int __c_in)); 469 char const *, (char const *__s, int __c_in));
330# endif 470# endif
331# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 471# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
332 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 472 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
333_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); 473 || defined __clang__)
334_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 ());
335# else 477# else
336_GL_CXXALIASWARN (strchrnul); 478_GL_CXXALIASWARN (strchrnul);
337# endif 479# endif
@@ -350,24 +492,62 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
350# undef strdup 492# undef strdup
351# define strdup rpl_strdup 493# define strdup rpl_strdup
352# endif 494# endif
353_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); 495_GL_FUNCDECL_RPL (strdup, char *,
496 (char const *__s)
497 _GL_ARG_NONNULL ((1))
498 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
354_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); 499_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
500# elif defined _WIN32 && !defined __CYGWIN__
501# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
502# undef strdup
503# define strdup _strdup
504# endif
505_GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
355# else 506# else
356# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup 507# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
357 /* strdup exists as a function and as a macro. Get rid of the macro. */ 508 /* strdup exists as a function and as a macro. Get rid of the macro. */
358# undef strdup 509# undef strdup
359# endif 510# endif
360# if !(@HAVE_DECL_STRDUP@ || defined strdup) 511# if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup
361_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); 512_GL_FUNCDECL_SYS (strdup, char *,
513 (char const *__s)
514 _GL_ARG_NONNULL ((1))
515 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
362# endif 516# endif
363_GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); 517_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
364# endif 518# endif
365_GL_CXXALIASWARN (strdup); 519_GL_CXXALIASWARN (strdup);
366#elif defined GNULIB_POSIXCHECK 520#else
367# undef strdup 521# if __GNUC__ >= 11 && !defined strdup
368# if HAVE_RAW_DECL_STRDUP 522/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */
523_GL_FUNCDECL_SYS (strdup, char *,
524 (char const *__s)
525 _GL_ARG_NONNULL ((1))
526 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
527# endif
528# if defined GNULIB_POSIXCHECK
529# undef strdup
530# if HAVE_RAW_DECL_STRDUP
369_GL_WARN_ON_USE (strdup, "strdup is unportable - " 531_GL_WARN_ON_USE (strdup, "strdup is unportable - "
370 "use gnulib module strdup for portability"); 532 "use gnulib module strdup for portability");
533# endif
534# elif @GNULIB_MDA_STRDUP@
535/* On native Windows, map 'creat' to '_creat', so that -loldnames is not
536 required. In C++ with GNULIB_NAMESPACE, avoid differences between
537 platforms by defining GNULIB_NAMESPACE::strdup always. */
538# if defined _WIN32 && !defined __CYGWIN__
539# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
540# undef strdup
541# define strdup _strdup
542# endif
543_GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
544# else
545# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
546# undef strdup
547# endif
548_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
549# endif
550_GL_CXXALIASWARN (strdup);
371# endif 551# endif
372#endif 552#endif
373 553
@@ -378,13 +558,18 @@ _GL_WARN_ON_USE (strdup, "strdup is unportable - "
378# undef strncat 558# undef strncat
379# define strncat rpl_strncat 559# define strncat rpl_strncat
380# endif 560# endif
381_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) 561_GL_FUNCDECL_RPL (strncat, char *,
382 _GL_ARG_NONNULL ((1, 2))); 562 (char *restrict dest, const char *restrict src, size_t n)
383_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); 563 _GL_ARG_NONNULL ((1, 2)));
564_GL_CXXALIAS_RPL (strncat, char *,
565 (char *restrict dest, const char *restrict src, size_t n));
384# else 566# else
385_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); 567_GL_CXXALIAS_SYS (strncat, char *,
568 (char *restrict dest, const char *restrict src, size_t n));
386# endif 569# endif
570# if __GLIBC__ >= 2
387_GL_CXXALIASWARN (strncat); 571_GL_CXXALIASWARN (strncat);
572# endif
388#elif defined GNULIB_POSIXCHECK 573#elif defined GNULIB_POSIXCHECK
389# undef strncat 574# undef strncat
390# if HAVE_RAW_DECL_STRNCAT 575# if HAVE_RAW_DECL_STRNCAT
@@ -400,22 +585,35 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
400# undef strndup 585# undef strndup
401# define strndup rpl_strndup 586# define strndup rpl_strndup
402# endif 587# endif
403_GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n) 588_GL_FUNCDECL_RPL (strndup, char *,
404 _GL_ARG_NONNULL ((1))); 589 (char const *__s, size_t __n)
405_GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n)); 590 _GL_ARG_NONNULL ((1))
591 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
592_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
406# else 593# else
407# if ! @HAVE_DECL_STRNDUP@ 594# if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup)
408_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n) 595_GL_FUNCDECL_SYS (strndup, char *,
409 _GL_ARG_NONNULL ((1))); 596 (char const *__s, size_t __n)
597 _GL_ARG_NONNULL ((1))
598 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
410# endif 599# endif
411_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n)); 600_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
412# endif 601# endif
413_GL_CXXALIASWARN (strndup); 602_GL_CXXALIASWARN (strndup);
414#elif defined GNULIB_POSIXCHECK 603#else
415# undef strndup 604# if __GNUC__ >= 11 && !defined strndup
416# 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
417_GL_WARN_ON_USE (strndup, "strndup is unportable - " 614_GL_WARN_ON_USE (strndup, "strndup is unportable - "
418 "use gnulib module strndup for portability"); 615 "use gnulib module strndup for portability");
616# endif
419# endif 617# endif
420#endif 618#endif
421 619
@@ -428,17 +626,17 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
428# undef strnlen 626# undef strnlen
429# define strnlen rpl_strnlen 627# define strnlen rpl_strnlen
430# endif 628# endif
431_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) 629_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)
432 _GL_ATTRIBUTE_PURE 630 _GL_ATTRIBUTE_PURE
433 _GL_ARG_NONNULL ((1))); 631 _GL_ARG_NONNULL ((1)));
434_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); 632_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
435# else 633# else
436# if ! @HAVE_DECL_STRNLEN@ 634# if ! @HAVE_DECL_STRNLEN@
437_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) 635_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)
438 _GL_ATTRIBUTE_PURE 636 _GL_ATTRIBUTE_PURE
439 _GL_ARG_NONNULL ((1))); 637 _GL_ARG_NONNULL ((1)));
440# endif 638# endif
441_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); 639_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
442# endif 640# endif
443_GL_CXXALIASWARN (strnlen); 641_GL_CXXALIASWARN (strnlen);
444#elif defined GNULIB_POSIXCHECK 642#elif defined GNULIB_POSIXCHECK
@@ -475,11 +673,12 @@ _GL_CXXALIAS_SYS_CAST2 (strpbrk,
475 char *, (char const *__s, char const *__accept), 673 char *, (char const *__s, char const *__accept),
476 const char *, (char const *__s, char const *__accept)); 674 const char *, (char const *__s, char const *__accept));
477# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 675# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
478 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 676 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
479_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); 677 || defined __clang__)
678_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept) throw ());
480_GL_CXXALIASWARN1 (strpbrk, char const *, 679_GL_CXXALIASWARN1 (strpbrk, char const *,
481 (char const *__s, char const *__accept)); 680 (char const *__s, char const *__accept) throw ());
482# else 681# elif __GLIBC__ >= 2
483_GL_CXXALIASWARN (strpbrk); 682_GL_CXXALIASWARN (strpbrk);
484# endif 683# endif
485# if defined GNULIB_POSIXCHECK 684# if defined GNULIB_POSIXCHECK
@@ -488,15 +687,19 @@ _GL_CXXALIASWARN (strpbrk);
488 locale encoding is GB18030 and one of the characters to be searched is a 687 locale encoding is GB18030 and one of the characters to be searched is a
489 digit. */ 688 digit. */
490# undef strpbrk 689# undef strpbrk
491_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " 690_GL_WARN_ON_USE_CXX (strpbrk,
492 "in multibyte locales - " 691 const char *, char *, (const char *, const char *),
493 "use mbspbrk if you care about internationalization"); 692 "strpbrk cannot work correctly on character strings "
693 "in multibyte locales - "
694 "use mbspbrk if you care about internationalization");
494# endif 695# endif
495#elif defined GNULIB_POSIXCHECK 696#elif defined GNULIB_POSIXCHECK
496# undef strpbrk 697# undef strpbrk
497# if HAVE_RAW_DECL_STRPBRK 698# if HAVE_RAW_DECL_STRPBRK
498_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " 699_GL_WARN_ON_USE_CXX (strpbrk,
499 "use gnulib module strpbrk for portability"); 700 const char *, char *, (const char *, const char *),
701 "strpbrk is unportable - "
702 "use gnulib module strpbrk for portability");
500# endif 703# endif
501#endif 704#endif
502 705
@@ -515,9 +718,11 @@ _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
515 GB18030 and the character to be searched is a digit. */ 718 GB18030 and the character to be searched is a digit. */
516# undef strrchr 719# undef strrchr
517/* Assume strrchr is always declared. */ 720/* Assume strrchr is always declared. */
518_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " 721_GL_WARN_ON_USE_CXX (strrchr,
519 "in some multibyte locales - " 722 const char *, char *, (const char *, int),
520 "use mbsrchr if you care about internationalization"); 723 "strrchr cannot work correctly on character strings "
724 "in some multibyte locales - "
725 "use mbsrchr if you care about internationalization");
521#endif 726#endif
522 727
523/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. 728/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
@@ -577,11 +782,13 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
577 const char *, (const char *haystack, const char *needle)); 782 const char *, (const char *haystack, const char *needle));
578# endif 783# endif
579# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 784# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
580 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 785 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
581_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); 786 || defined __clang__)
787_GL_CXXALIASWARN1 (strstr, char *,
788 (char *haystack, const char *needle) throw ());
582_GL_CXXALIASWARN1 (strstr, const char *, 789_GL_CXXALIASWARN1 (strstr, const char *,
583 (const char *haystack, const char *needle)); 790 (const char *haystack, const char *needle) throw ());
584# else 791# elif __GLIBC__ >= 2
585_GL_CXXALIASWARN (strstr); 792_GL_CXXALIASWARN (strstr);
586# endif 793# endif
587#elif defined GNULIB_POSIXCHECK 794#elif defined GNULIB_POSIXCHECK
@@ -626,10 +833,12 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
626 const char *, (const char *haystack, const char *needle)); 833 const char *, (const char *haystack, const char *needle));
627# endif 834# endif
628# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 835# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
629 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 836 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
630_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); 837 || defined __clang__)
838_GL_CXXALIASWARN1 (strcasestr, char *,
839 (char *haystack, const char *needle) throw ());
631_GL_CXXALIASWARN1 (strcasestr, const char *, 840_GL_CXXALIASWARN1 (strcasestr, const char *,
632 (const char *haystack, const char *needle)); 841 (const char *haystack, const char *needle) throw ());
633# else 842# else
634_GL_CXXALIASWARN (strcasestr); 843_GL_CXXALIASWARN (strcasestr);
635# endif 844# endif
@@ -660,7 +869,7 @@ _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
660 This is a variant of strtok() that is multithread-safe. 869 This is a variant of strtok() that is multithread-safe.
661 870
662 For the POSIX documentation for this function, see: 871 For the POSIX documentation for this function, see:
663 http://www.opengroup.org/susv3xsh/strtok.html 872 https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html
664 873
665 Caveat: It modifies the original string. 874 Caveat: It modifies the original string.
666 Caveat: These functions cannot be used on constant strings. 875 Caveat: These functions cannot be used on constant strings.
@@ -931,7 +1140,8 @@ _GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
931 Caveat: The identity of the delimiting character is lost. 1140 Caveat: The identity of the delimiting character is lost.
932 1141
933 See also mbssep(). */ 1142 See also mbssep(). */
934_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr) 1143_GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
1144 char **save_ptr)
935 _GL_ARG_NONNULL ((2, 3)); 1145 _GL_ARG_NONNULL ((2, 3));
936#endif 1146#endif
937 1147
@@ -947,7 +1157,9 @@ _GL_CXXALIAS_RPL (strerror, char *, (int));
947# else 1157# else
948_GL_CXXALIAS_SYS (strerror, char *, (int)); 1158_GL_CXXALIAS_SYS (strerror, char *, (int));
949# endif 1159# endif
1160# if __GLIBC__ >= 2
950_GL_CXXALIASWARN (strerror); 1161_GL_CXXALIASWARN (strerror);
1162# endif
951#elif defined GNULIB_POSIXCHECK 1163#elif defined GNULIB_POSIXCHECK
952# undef strerror 1164# undef strerror
953/* Assume strerror is always declared. */ 1165/* Assume strerror is always declared. */
@@ -984,6 +1196,60 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
984# endif 1196# endif
985#endif 1197#endif
986 1198
1199/* Return the name of the system error code ERRNUM. */
1200#if @GNULIB_STRERRORNAME_NP@
1201# if @REPLACE_STRERRORNAME_NP@
1202# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1203# undef strerrorname_np
1204# define strerrorname_np rpl_strerrorname_np
1205# endif
1206_GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum));
1207_GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum));
1208# else
1209# if !@HAVE_STRERRORNAME_NP@
1210_GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum));
1211# endif
1212_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum));
1213# endif
1214_GL_CXXALIASWARN (strerrorname_np);
1215#elif defined GNULIB_POSIXCHECK
1216# undef strerrorname_np
1217# if HAVE_RAW_DECL_STRERRORNAME_NP
1218_GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - "
1219 "use gnulib module strerrorname_np for portability");
1220# endif
1221#endif
1222
1223/* Return an abbreviation string for the signal number SIG. */
1224#if @GNULIB_SIGABBREV_NP@
1225# if ! @HAVE_SIGABBREV_NP@
1226_GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig));
1227# endif
1228_GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig));
1229_GL_CXXALIASWARN (sigabbrev_np);
1230#elif defined GNULIB_POSIXCHECK
1231# undef sigabbrev_np
1232# if HAVE_RAW_DECL_SIGABBREV_NP
1233_GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - "
1234 "use gnulib module sigabbrev_np for portability");
1235# endif
1236#endif
1237
1238/* Return an English description string for the signal number SIG. */
1239#if @GNULIB_SIGDESCR_NP@
1240# if ! @HAVE_SIGDESCR_NP@
1241_GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig));
1242# endif
1243_GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig));
1244_GL_CXXALIASWARN (sigdescr_np);
1245#elif defined GNULIB_POSIXCHECK
1246# undef sigdescr_np
1247# if HAVE_RAW_DECL_SIGDESCR_NP
1248_GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - "
1249 "use gnulib module sigdescr_np for portability");
1250# endif
1251#endif
1252
987#if @GNULIB_STRSIGNAL@ 1253#if @GNULIB_STRSIGNAL@
988# if @REPLACE_STRSIGNAL@ 1254# if @REPLACE_STRSIGNAL@
989# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1255# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1027,3 +1293,4 @@ _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1027 1293
1028#endif /* _@GUARD_PREFIX@_STRING_H */ 1294#endif /* _@GUARD_PREFIX@_STRING_H */
1029#endif /* _@GUARD_PREFIX@_STRING_H */ 1295#endif /* _@GUARD_PREFIX@_STRING_H */
1296#endif