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.h643
1 files changed, 541 insertions, 102 deletions
diff --git a/gl/string.in.h b/gl/string.in.h
index e993b2fb..25e6a087 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-2023 Free Software Foundation, Inc. 3 Copyright (C) 1995-1996, 2001-2025 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
@@ -20,7 +20,7 @@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23#if defined _GL_ALREADY_INCLUDING_STRING_H 23#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_STRING_H
24/* Special invocation convention: 24/* Special invocation convention:
25 - On OS X/NetBSD we have a sequence of nested includes 25 - On OS X/NetBSD we have a sequence of nested includes
26 <string.h> -> <strings.h> -> "string.h" 26 <string.h> -> <strings.h> -> "string.h"
@@ -34,19 +34,31 @@
34 34
35#ifndef _@GUARD_PREFIX@_STRING_H 35#ifndef _@GUARD_PREFIX@_STRING_H
36 36
37#define _GL_ALREADY_INCLUDING_STRING_H 37#define _@GUARD_PREFIX@_ALREADY_INCLUDING_STRING_H
38 38
39/* The include_next requires a split double-inclusion guard. */ 39/* The include_next requires a split double-inclusion guard. */
40#@INCLUDE_NEXT@ @NEXT_STRING_H@ 40#@INCLUDE_NEXT@ @NEXT_STRING_H@
41 41
42#undef _GL_ALREADY_INCLUDING_STRING_H 42#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_STRING_H
43 43
44#ifndef _@GUARD_PREFIX@_STRING_H 44#ifndef _@GUARD_PREFIX@_STRING_H
45#define _@GUARD_PREFIX@_STRING_H 45#define _@GUARD_PREFIX@_STRING_H
46 46
47/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
48 _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
49 HAVE_RAW_DECL_*. */
50#if !_GL_CONFIG_H_INCLUDED
51 #error "Please include config.h first."
52#endif
53
47/* NetBSD 5.0 mis-defines NULL. */ 54/* NetBSD 5.0 mis-defines NULL. */
48#include <stddef.h> 55#include <stddef.h>
49 56
57#if @GNULIB_STRERROR_L@
58/* Get locale_t. */
59# include <locale.h>
60#endif
61
50/* MirBSD defines mbslen as a macro. */ 62/* MirBSD defines mbslen as a macro. */
51#if @GNULIB_MBSLEN@ && defined __MirBSD__ 63#if @GNULIB_MBSLEN@ && defined __MirBSD__
52# include <wchar.h> 64# include <wchar.h>
@@ -59,10 +71,11 @@
59# include <unistd.h> 71# include <unistd.h>
60#endif 72#endif
61 73
62/* AIX 7.2 declares ffsl and ffsll in <strings.h>, not in <string.h>. */ 74/* AIX 7.2 and Android 13 declare ffsl and ffsll in <strings.h>, not in
75 <string.h>. */
63/* But in any case avoid namespace pollution on glibc systems. */ 76/* But in any case avoid namespace pollution on glibc systems. */
64#if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \ 77#if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \
65 && defined _AIX) \ 78 && (defined _AIX || defined __ANDROID__)) \
66 && ! defined __GLIBC__ 79 && ! defined __GLIBC__
67# include <strings.h> 80# include <strings.h>
68#endif 81#endif
@@ -71,7 +84,7 @@
71 that can be freed by passing them as the Ith argument to the 84 that can be freed by passing them as the Ith argument to the
72 function F. */ 85 function F. */
73#ifndef _GL_ATTRIBUTE_DEALLOC 86#ifndef _GL_ATTRIBUTE_DEALLOC
74# if __GNUC__ >= 11 87# if __GNUC__ >= 11 && !defined __clang__
75# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) 88# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
76# else 89# else
77# define _GL_ATTRIBUTE_DEALLOC(f, i) 90# define _GL_ATTRIBUTE_DEALLOC(f, i)
@@ -103,6 +116,40 @@
103# endif 116# endif
104#endif 117#endif
105 118
119/* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP
120 (a pointer) must not be NULL if the argument NI (an integer) is != 0. */
121/* Applies to: functions. */
122#ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO
123# if __GNUC__ >= 15 && !defined __clang__
124# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) \
125 __attribute__ ((__nonnull_if_nonzero__ (np, ni)))
126# else
127# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni)
128# endif
129#endif
130
131/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
132 */
133#ifndef _GL_ATTRIBUTE_NOTHROW
134# if defined __cplusplus
135# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
136# if __cplusplus >= 201103L
137# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
138# else
139# define _GL_ATTRIBUTE_NOTHROW throw ()
140# endif
141# else
142# define _GL_ATTRIBUTE_NOTHROW
143# endif
144# else
145# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
146# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
147# else
148# define _GL_ATTRIBUTE_NOTHROW
149# endif
150# endif
151#endif
152
106/* The __attribute__ feature is available in gcc versions 2.5 and later. 153/* The __attribute__ feature is available in gcc versions 2.5 and later.
107 The attribute __pure__ was added in gcc 2.96. */ 154 The attribute __pure__ was added in gcc 2.96. */
108#ifndef _GL_ATTRIBUTE_PURE 155#ifndef _GL_ATTRIBUTE_PURE
@@ -119,13 +166,18 @@
119 166
120/* The definition of _GL_WARN_ON_USE is copied here. */ 167/* The definition of _GL_WARN_ON_USE is copied here. */
121 168
169
122/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have 170/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
123 been included yet. */ 171 been included yet. */
124#if @GNULIB_FREE_POSIX@ 172#if @GNULIB_FREE_POSIX@
125# if (@REPLACE_FREE@ && !defined free \ 173# if (@REPLACE_FREE@ && !defined free \
126 && !(defined __cplusplus && defined GNULIB_NAMESPACE)) 174 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
127/* We can't do '#define free rpl_free' here. */ 175/* We can't do '#define free rpl_free' here. */
176# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
177_GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW;
178# else
128_GL_EXTERN_C void rpl_free (void *); 179_GL_EXTERN_C void rpl_free (void *);
180# endif
129# undef _GL_ATTRIBUTE_DEALLOC_FREE 181# undef _GL_ATTRIBUTE_DEALLOC_FREE
130# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) 182# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
131# else 183# else
@@ -137,7 +189,7 @@ _GL_EXTERN_C
137 void __cdecl free (void *); 189 void __cdecl free (void *);
138# else 190# else
139# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 191# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
140_GL_EXTERN_C void free (void *) throw (); 192_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
141# else 193# else
142_GL_EXTERN_C void free (void *); 194_GL_EXTERN_C void free (void *);
143# endif 195# endif
@@ -152,19 +204,104 @@ _GL_EXTERN_C
152 void __cdecl free (void *); 204 void __cdecl free (void *);
153# else 205# else
154# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 206# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
155_GL_EXTERN_C void free (void *) throw (); 207_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
156# else 208# else
157_GL_EXTERN_C void free (void *); 209_GL_EXTERN_C void free (void *);
158# endif 210# endif
159# endif 211# endif
160#endif 212#endif
161 213
214
215/* Declarations for ISO C N3322. */
216#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
217# ifndef memcpy
218_GL_EXTERN_C void *memcpy (void *__dest, const void *__src, size_t __n)
219# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
220 _GL_ATTRIBUTE_NOTHROW
221# endif
222 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
223 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
224# endif
225# ifndef memccpy
226_GL_EXTERN_C void *memccpy (void *__dest, const void *__src, int __c, size_t __n)
227# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
228 _GL_ATTRIBUTE_NOTHROW
229# endif
230 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 4)
231 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 4);
232# endif
233# ifndef memmove
234_GL_EXTERN_C void *memmove (void *__dest, const void *__src, size_t __n)
235# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
236 _GL_ATTRIBUTE_NOTHROW
237# endif
238 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
239 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
240# endif
241# ifndef strncpy
242_GL_EXTERN_C char *strncpy (char *__dest, const char *__src, size_t __n)
243# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
244 _GL_ATTRIBUTE_NOTHROW
245# endif
246 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
247 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
248# endif
249# ifndef strndup
250_GL_EXTERN_C char *strndup (const char *__s, size_t __n)
251# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
252 _GL_ATTRIBUTE_NOTHROW
253# endif
254 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2);
255# endif
256# ifndef strncat
257_GL_EXTERN_C char *strncat (char *__dest, const char *__src, size_t __n)
258# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
259 _GL_ATTRIBUTE_NOTHROW
260# endif
261 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
262# endif
263# ifndef memcmp
264_GL_EXTERN_C int memcmp (const void *__s1, const void *__s2, size_t __n)
265# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
266 _GL_ATTRIBUTE_NOTHROW
267# endif
268 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
269 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
270# endif
271# ifndef strncmp
272_GL_EXTERN_C int strncmp (const char *__s1, const char *__s2, size_t __n)
273# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
274 _GL_ATTRIBUTE_NOTHROW
275# endif
276 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
277 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
278# endif
279# if !defined memchr && !defined __cplusplus
280_GL_EXTERN_C void *memchr (const void *__s, int __c, size_t __n)
281 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
282_GL_EXTERN_C void *memrchr (const void *__s, int __c, size_t __n)
283 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
284# endif
285# ifndef memset
286_GL_EXTERN_C void *memset (void *__s, int __c, size_t __n)
287# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
288 _GL_ATTRIBUTE_NOTHROW
289# endif
290 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
291# endif
292# ifndef memset_explicit
293_GL_EXTERN_C void *memset_explicit (void *__s, int __c, size_t __n)
294 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
295# endif
296#endif
297
298
162/* Clear a block of memory. The compiler will not delete a call to 299/* 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. */ 300 this function, even if the block is dead after the call. */
164#if @GNULIB_EXPLICIT_BZERO@ 301#if @GNULIB_EXPLICIT_BZERO@
165# if ! @HAVE_EXPLICIT_BZERO@ 302# if ! @HAVE_EXPLICIT_BZERO@
166_GL_FUNCDECL_SYS (explicit_bzero, void, 303_GL_FUNCDECL_SYS (explicit_bzero, void,
167 (void *__dest, size_t __n) _GL_ARG_NONNULL ((1))); 304 (void *__dest, size_t __n), _GL_ARG_NONNULL ((1)));
168# endif 305# endif
169_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n)); 306_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
170_GL_CXXALIASWARN (explicit_bzero); 307_GL_CXXALIASWARN (explicit_bzero);
@@ -176,10 +313,11 @@ _GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
176# endif 313# endif
177#endif 314#endif
178 315
316
179/* Find the index of the least-significant set bit. */ 317/* Find the index of the least-significant set bit. */
180#if @GNULIB_FFSL@ 318#if @GNULIB_FFSL@
181# if !@HAVE_FFSL@ 319# if !@HAVE_FFSL@
182_GL_FUNCDECL_SYS (ffsl, int, (long int i)); 320_GL_FUNCDECL_SYS (ffsl, int, (long int i), );
183# endif 321# endif
184_GL_CXXALIAS_SYS (ffsl, int, (long int i)); 322_GL_CXXALIAS_SYS (ffsl, int, (long int i));
185_GL_CXXALIASWARN (ffsl); 323_GL_CXXALIASWARN (ffsl);
@@ -197,11 +335,11 @@ _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
197# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 335# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
198# define ffsll rpl_ffsll 336# define ffsll rpl_ffsll
199# endif 337# endif
200_GL_FUNCDECL_RPL (ffsll, int, (long long int i)); 338_GL_FUNCDECL_RPL (ffsll, int, (long long int i), );
201_GL_CXXALIAS_RPL (ffsll, int, (long long int i)); 339_GL_CXXALIAS_RPL (ffsll, int, (long long int i));
202# else 340# else
203# if !@HAVE_FFSLL@ 341# if !@HAVE_FFSLL@
204_GL_FUNCDECL_SYS (ffsll, int, (long long int i)); 342_GL_FUNCDECL_SYS (ffsll, int, (long long int i), );
205# endif 343# endif
206_GL_CXXALIAS_SYS (ffsll, int, (long long int i)); 344_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
207# endif 345# endif
@@ -240,9 +378,9 @@ _GL_CXXALIASWARN (memccpy);
240# undef memchr 378# undef memchr
241# define memchr rpl_memchr 379# define memchr rpl_memchr
242# endif 380# endif
243_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) 381_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n),
244 _GL_ATTRIBUTE_PURE 382 _GL_ATTRIBUTE_PURE
245 _GL_ARG_NONNULL ((1))); 383 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
246_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); 384_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
247# else 385# else
248 /* On some systems, this function is defined as an overloaded function: 386 /* On some systems, this function is defined as an overloaded function:
@@ -255,17 +393,22 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
255# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 393# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
256 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 394 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
257 || defined __clang__) 395 || defined __clang__)
258_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n) throw ()); 396_GL_CXXALIASWARN1 (memchr, void *,
397 (void *__s, int __c, size_t __n)
398 _GL_ATTRIBUTE_NOTHROW);
259_GL_CXXALIASWARN1 (memchr, void const *, 399_GL_CXXALIASWARN1 (memchr, void const *,
260 (void const *__s, int __c, size_t __n) throw ()); 400 (void const *__s, int __c, size_t __n)
401 _GL_ATTRIBUTE_NOTHROW);
261# elif __GLIBC__ >= 2 402# elif __GLIBC__ >= 2
262_GL_CXXALIASWARN (memchr); 403_GL_CXXALIASWARN (memchr);
263# endif 404# endif
264#elif defined GNULIB_POSIXCHECK 405#elif defined GNULIB_POSIXCHECK
265# undef memchr 406# undef memchr
266/* Assume memchr is always declared. */ 407/* Assume memchr is always declared. */
267_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " 408_GL_WARN_ON_USE_CXX (memchr,
268 "use gnulib module memchr for portability" ); 409 const void *, void *, (void const *, int, size_t),
410 "memchr has platform-specific bugs - "
411 "use gnulib module memchr for portability" );
269#endif 412#endif
270 413
271/* Return the first occurrence of NEEDLE in HAYSTACK. */ 414/* Return the first occurrence of NEEDLE in HAYSTACK. */
@@ -276,7 +419,7 @@ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
276# endif 419# endif
277_GL_FUNCDECL_RPL (memmem, void *, 420_GL_FUNCDECL_RPL (memmem, void *,
278 (void const *__haystack, size_t __haystack_len, 421 (void const *__haystack, size_t __haystack_len,
279 void const *__needle, size_t __needle_len) 422 void const *__needle, size_t __needle_len),
280 _GL_ATTRIBUTE_PURE 423 _GL_ATTRIBUTE_PURE
281 _GL_ARG_NONNULL ((1, 3))); 424 _GL_ARG_NONNULL ((1, 3)));
282_GL_CXXALIAS_RPL (memmem, void *, 425_GL_CXXALIAS_RPL (memmem, void *,
@@ -286,7 +429,7 @@ _GL_CXXALIAS_RPL (memmem, void *,
286# if ! @HAVE_DECL_MEMMEM@ 429# if ! @HAVE_DECL_MEMMEM@
287_GL_FUNCDECL_SYS (memmem, void *, 430_GL_FUNCDECL_SYS (memmem, void *,
288 (void const *__haystack, size_t __haystack_len, 431 (void const *__haystack, size_t __haystack_len,
289 void const *__needle, size_t __needle_len) 432 void const *__needle, size_t __needle_len),
290 _GL_ATTRIBUTE_PURE 433 _GL_ATTRIBUTE_PURE
291 _GL_ARG_NONNULL ((1, 3))); 434 _GL_ARG_NONNULL ((1, 3)));
292# endif 435# endif
@@ -307,16 +450,32 @@ _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
307/* Copy N bytes of SRC to DEST, return pointer to bytes after the 450/* Copy N bytes of SRC to DEST, return pointer to bytes after the
308 last written byte. */ 451 last written byte. */
309#if @GNULIB_MEMPCPY@ 452#if @GNULIB_MEMPCPY@
310# if ! @HAVE_MEMPCPY@ 453# if @REPLACE_MEMPCPY@
454# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
455# undef mempcpy
456# define mempcpy rpl_mempcpy
457# endif
458_GL_FUNCDECL_RPL (mempcpy, void *,
459 (void *restrict __dest, void const *restrict __src,
460 size_t __n),
461 _GL_ARG_NONNULL ((1, 2)));
462_GL_CXXALIAS_RPL (mempcpy, void *,
463 (void *restrict __dest, void const *restrict __src,
464 size_t __n));
465# else
466# if !@HAVE_MEMPCPY@
311_GL_FUNCDECL_SYS (mempcpy, void *, 467_GL_FUNCDECL_SYS (mempcpy, void *,
312 (void *restrict __dest, void const *restrict __src, 468 (void *restrict __dest, void const *restrict __src,
313 size_t __n) 469 size_t __n),
314 _GL_ARG_NONNULL ((1, 2))); 470 _GL_ARG_NONNULL ((1, 2)));
315# endif 471# endif
316_GL_CXXALIAS_SYS (mempcpy, void *, 472_GL_CXXALIAS_SYS (mempcpy, void *,
317 (void *restrict __dest, void const *restrict __src, 473 (void *restrict __dest, void const *restrict __src,
318 size_t __n)); 474 size_t __n));
475# endif
476# if __GLIBC__ >= 2
319_GL_CXXALIASWARN (mempcpy); 477_GL_CXXALIASWARN (mempcpy);
478# endif
320#elif defined GNULIB_POSIXCHECK 479#elif defined GNULIB_POSIXCHECK
321# undef mempcpy 480# undef mempcpy
322# if HAVE_RAW_DECL_MEMPCPY 481# if HAVE_RAW_DECL_MEMPCPY
@@ -328,9 +487,9 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
328/* Search backwards through a block for a byte (specified as an int). */ 487/* Search backwards through a block for a byte (specified as an int). */
329#if @GNULIB_MEMRCHR@ 488#if @GNULIB_MEMRCHR@
330# if ! @HAVE_DECL_MEMRCHR@ 489# if ! @HAVE_DECL_MEMRCHR@
331_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) 490_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t),
332 _GL_ATTRIBUTE_PURE 491 _GL_ATTRIBUTE_PURE
333 _GL_ARG_NONNULL ((1))); 492 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
334# endif 493# endif
335 /* On some systems, this function is defined as an overloaded function: 494 /* On some systems, this function is defined as an overloaded function:
336 extern "C++" { const void * std::memrchr (const void *, int, size_t); } 495 extern "C++" { const void * std::memrchr (const void *, int, size_t); }
@@ -341,9 +500,13 @@ _GL_CXXALIAS_SYS_CAST2 (memrchr,
341# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 500# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
342 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 501 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
343 || defined __clang__) 502 || defined __clang__)
344_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t) throw ()); 503_GL_CXXALIASWARN1 (memrchr, void *,
345_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t) throw ()); 504 (void *, int, size_t)
346# else 505 _GL_ATTRIBUTE_NOTHROW);
506_GL_CXXALIASWARN1 (memrchr, void const *,
507 (void const *, int, size_t)
508 _GL_ATTRIBUTE_NOTHROW);
509# elif __GLIBC__ >= 2
347_GL_CXXALIASWARN (memrchr); 510_GL_CXXALIASWARN (memrchr);
348# endif 511# endif
349#elif defined GNULIB_POSIXCHECK 512#elif defined GNULIB_POSIXCHECK
@@ -357,12 +520,26 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
357/* Overwrite a block of memory. The compiler will not optimize 520/* Overwrite a block of memory. The compiler will not optimize
358 effects away, even if the block is dead after the call. */ 521 effects away, even if the block is dead after the call. */
359#if @GNULIB_MEMSET_EXPLICIT@ 522#if @GNULIB_MEMSET_EXPLICIT@
360# if ! @HAVE_MEMSET_EXPLICIT@ 523# if @REPLACE_MEMSET_EXPLICIT@
524# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
525# undef memset_explicit
526# define memset_explicit rpl_memset_explicit
527# endif
528_GL_FUNCDECL_RPL (memset_explicit, void *,
529 (void *__dest, int __c, size_t __n),
530 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
531_GL_CXXALIAS_RPL (memset_explicit, void *, (void *__dest, int __c, size_t __n));
532# else
533# if !@HAVE_MEMSET_EXPLICIT@
361_GL_FUNCDECL_SYS (memset_explicit, void *, 534_GL_FUNCDECL_SYS (memset_explicit, void *,
362 (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1))); 535 (void *__dest, int __c, size_t __n),
363# endif 536 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
537# endif
364_GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n)); 538_GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n));
539# endif
540# if __GLIBC__ >= 2
365_GL_CXXALIASWARN (memset_explicit); 541_GL_CXXALIASWARN (memset_explicit);
542# endif
366#elif defined GNULIB_POSIXCHECK 543#elif defined GNULIB_POSIXCHECK
367# undef memset_explicit 544# undef memset_explicit
368# if HAVE_RAW_DECL_MEMSET_EXPLICIT 545# if HAVE_RAW_DECL_MEMSET_EXPLICIT
@@ -376,7 +553,7 @@ _GL_WARN_ON_USE (memset_explicit, "memset_explicit is unportable - "
376 occur within N bytes. */ 553 occur within N bytes. */
377#if @GNULIB_RAWMEMCHR@ 554#if @GNULIB_RAWMEMCHR@
378# if ! @HAVE_RAWMEMCHR@ 555# if ! @HAVE_RAWMEMCHR@
379_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) 556_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in),
380 _GL_ATTRIBUTE_PURE 557 _GL_ATTRIBUTE_PURE
381 _GL_ARG_NONNULL ((1))); 558 _GL_ARG_NONNULL ((1)));
382# endif 559# endif
@@ -389,9 +566,12 @@ _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
389# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 566# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
390 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 567 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
391 || defined __clang__) 568 || defined __clang__)
392_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in) throw ()); 569_GL_CXXALIASWARN1 (rawmemchr, void *,
570 (void *__s, int __c_in)
571 _GL_ATTRIBUTE_NOTHROW);
393_GL_CXXALIASWARN1 (rawmemchr, void const *, 572_GL_CXXALIASWARN1 (rawmemchr, void const *,
394 (void const *__s, int __c_in) throw ()); 573 (void const *__s, int __c_in)
574 _GL_ATTRIBUTE_NOTHROW);
395# else 575# else
396_GL_CXXALIASWARN (rawmemchr); 576_GL_CXXALIASWARN (rawmemchr);
397# endif 577# endif
@@ -405,14 +585,28 @@ _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
405 585
406/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ 586/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
407#if @GNULIB_STPCPY@ 587#if @GNULIB_STPCPY@
408# if ! @HAVE_STPCPY@ 588# if @REPLACE_STPCPY@
589# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
590# undef stpcpy
591# define stpcpy rpl_stpcpy
592# endif
593_GL_FUNCDECL_RPL (stpcpy, char *,
594 (char *restrict __dst, char const *restrict __src),
595 _GL_ARG_NONNULL ((1, 2)));
596_GL_CXXALIAS_RPL (stpcpy, char *,
597 (char *restrict __dst, char const *restrict __src));
598# else
599# if !@HAVE_STPCPY@
409_GL_FUNCDECL_SYS (stpcpy, char *, 600_GL_FUNCDECL_SYS (stpcpy, char *,
410 (char *restrict __dst, char const *restrict __src) 601 (char *restrict __dst, char const *restrict __src),
411 _GL_ARG_NONNULL ((1, 2))); 602 _GL_ARG_NONNULL ((1, 2)));
412# endif 603# endif
413_GL_CXXALIAS_SYS (stpcpy, char *, 604_GL_CXXALIAS_SYS (stpcpy, char *,
414 (char *restrict __dst, char const *restrict __src)); 605 (char *restrict __dst, char const *restrict __src));
606# endif
607# if __GLIBC__ >= 2
415_GL_CXXALIASWARN (stpcpy); 608_GL_CXXALIASWARN (stpcpy);
609# endif
416#elif defined GNULIB_POSIXCHECK 610#elif defined GNULIB_POSIXCHECK
417# undef stpcpy 611# undef stpcpy
418# if HAVE_RAW_DECL_STPCPY 612# if HAVE_RAW_DECL_STPCPY
@@ -431,7 +625,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
431# endif 625# endif
432_GL_FUNCDECL_RPL (stpncpy, char *, 626_GL_FUNCDECL_RPL (stpncpy, char *,
433 (char *restrict __dst, char const *restrict __src, 627 (char *restrict __dst, char const *restrict __src,
434 size_t __n) 628 size_t __n),
435 _GL_ARG_NONNULL ((1, 2))); 629 _GL_ARG_NONNULL ((1, 2)));
436_GL_CXXALIAS_RPL (stpncpy, char *, 630_GL_CXXALIAS_RPL (stpncpy, char *,
437 (char *restrict __dst, char const *restrict __src, 631 (char *restrict __dst, char const *restrict __src,
@@ -440,14 +634,16 @@ _GL_CXXALIAS_RPL (stpncpy, char *,
440# if ! @HAVE_STPNCPY@ 634# if ! @HAVE_STPNCPY@
441_GL_FUNCDECL_SYS (stpncpy, char *, 635_GL_FUNCDECL_SYS (stpncpy, char *,
442 (char *restrict __dst, char const *restrict __src, 636 (char *restrict __dst, char const *restrict __src,
443 size_t __n) 637 size_t __n),
444 _GL_ARG_NONNULL ((1, 2))); 638 _GL_ARG_NONNULL ((1, 2)));
445# endif 639# endif
446_GL_CXXALIAS_SYS (stpncpy, char *, 640_GL_CXXALIAS_SYS (stpncpy, char *,
447 (char *restrict __dst, char const *restrict __src, 641 (char *restrict __dst, char const *restrict __src,
448 size_t __n)); 642 size_t __n));
449# endif 643# endif
644# if __GLIBC__ >= 2
450_GL_CXXALIASWARN (stpncpy); 645_GL_CXXALIASWARN (stpncpy);
646# endif
451#elif defined GNULIB_POSIXCHECK 647#elif defined GNULIB_POSIXCHECK
452# undef stpncpy 648# undef stpncpy
453# if HAVE_RAW_DECL_STPNCPY 649# if HAVE_RAW_DECL_STPNCPY
@@ -474,14 +670,14 @@ _GL_WARN_ON_USE_CXX (strchr,
474# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 670# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
475# define strchrnul rpl_strchrnul 671# define strchrnul rpl_strchrnul
476# endif 672# endif
477_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in) 673_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in),
478 _GL_ATTRIBUTE_PURE 674 _GL_ATTRIBUTE_PURE
479 _GL_ARG_NONNULL ((1))); 675 _GL_ARG_NONNULL ((1)));
480_GL_CXXALIAS_RPL (strchrnul, char *, 676_GL_CXXALIAS_RPL (strchrnul, char *,
481 (const char *str, int ch)); 677 (const char *str, int ch));
482# else 678# else
483# if ! @HAVE_STRCHRNUL@ 679# if ! @HAVE_STRCHRNUL@
484_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) 680_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in),
485 _GL_ATTRIBUTE_PURE 681 _GL_ATTRIBUTE_PURE
486 _GL_ARG_NONNULL ((1))); 682 _GL_ARG_NONNULL ((1)));
487# endif 683# endif
@@ -495,10 +691,13 @@ _GL_CXXALIAS_SYS_CAST2 (strchrnul,
495# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 691# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
496 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 692 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
497 || defined __clang__) 693 || defined __clang__)
498_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in) throw ()); 694_GL_CXXALIASWARN1 (strchrnul, char *,
695 (char *__s, int __c_in)
696 _GL_ATTRIBUTE_NOTHROW);
499_GL_CXXALIASWARN1 (strchrnul, char const *, 697_GL_CXXALIASWARN1 (strchrnul, char const *,
500 (char const *__s, int __c_in) throw ()); 698 (char const *__s, int __c_in)
501# else 699 _GL_ATTRIBUTE_NOTHROW);
700# elif __GLIBC__ >= 2
502_GL_CXXALIASWARN (strchrnul); 701_GL_CXXALIASWARN (strchrnul);
503# endif 702# endif
504#elif defined GNULIB_POSIXCHECK 703#elif defined GNULIB_POSIXCHECK
@@ -517,7 +716,7 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
517# define strdup rpl_strdup 716# define strdup rpl_strdup
518# endif 717# endif
519_GL_FUNCDECL_RPL (strdup, char *, 718_GL_FUNCDECL_RPL (strdup, char *,
520 (char const *__s) 719 (char const *__s),
521 _GL_ARG_NONNULL ((1)) 720 _GL_ARG_NONNULL ((1))
522 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 721 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
523_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); 722_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
@@ -532,22 +731,39 @@ _GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
532 /* strdup exists as a function and as a macro. Get rid of the macro. */ 731 /* strdup exists as a function and as a macro. Get rid of the macro. */
533# undef strdup 732# undef strdup
534# endif 733# endif
535# if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup 734# if (!@HAVE_DECL_STRDUP@ || (__GNUC__ >= 11 && !defined __clang__)) \
735 && !defined strdup
736# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
737_GL_FUNCDECL_SYS (strdup, char *,
738 (char const *__s),
739 _GL_ARG_NONNULL ((1))
740 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
741 _GL_ATTRIBUTE_NOTHROW;
742# else
536_GL_FUNCDECL_SYS (strdup, char *, 743_GL_FUNCDECL_SYS (strdup, char *,
537 (char const *__s) 744 (char const *__s),
538 _GL_ARG_NONNULL ((1)) 745 _GL_ARG_NONNULL ((1))
539 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 746 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
747# endif
540# endif 748# endif
541_GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); 749_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
542# endif 750# endif
543_GL_CXXALIASWARN (strdup); 751_GL_CXXALIASWARN (strdup);
544#else 752#else
545# if __GNUC__ >= 11 && !defined strdup 753# if (__GNUC__ >= 11 && !defined __clang__) && !defined strdup
546/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */ 754/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */
755# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
756_GL_FUNCDECL_SYS (strdup, char *,
757 (char const *__s),
758 _GL_ARG_NONNULL ((1))
759 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
760 _GL_ATTRIBUTE_NOTHROW;
761# else
547_GL_FUNCDECL_SYS (strdup, char *, 762_GL_FUNCDECL_SYS (strdup, char *,
548 (char const *__s) 763 (char const *__s),
549 _GL_ARG_NONNULL ((1)) 764 _GL_ARG_NONNULL ((1))
550 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 765 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
766# endif
551# endif 767# endif
552# if defined GNULIB_POSIXCHECK 768# if defined GNULIB_POSIXCHECK
553# undef strdup 769# undef strdup
@@ -583,8 +799,9 @@ _GL_CXXALIASWARN (strdup);
583# define strncat rpl_strncat 799# define strncat rpl_strncat
584# endif 800# endif
585_GL_FUNCDECL_RPL (strncat, char *, 801_GL_FUNCDECL_RPL (strncat, char *,
586 (char *restrict dest, const char *restrict src, size_t n) 802 (char *restrict dest, const char *restrict src, size_t n),
587 _GL_ARG_NONNULL ((1, 2))); 803 _GL_ARG_NONNULL ((1))
804 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
588_GL_CXXALIAS_RPL (strncat, char *, 805_GL_CXXALIAS_RPL (strncat, char *,
589 (char *restrict dest, const char *restrict src, size_t n)); 806 (char *restrict dest, const char *restrict src, size_t n));
590# else 807# else
@@ -602,6 +819,35 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
602# endif 819# endif
603#endif 820#endif
604 821
822/* Copy no more than N bytes of SRC to DST, returning DST. */
823#if @GNULIB_STRNCPY@
824# if @REPLACE_STRNCPY@
825# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
826# undef strncpy
827# define strncpy rpl_strncpy
828# endif
829_GL_FUNCDECL_RPL (strncpy, char *,
830 (char *restrict __dst, char const *restrict __src,
831 size_t __n),
832 _GL_ARG_NONNULL ((1, 2)));
833_GL_CXXALIAS_RPL (strncpy, char *,
834 (char *restrict __dst, char const *restrict __src,
835 size_t __n));
836# else
837_GL_CXXALIAS_SYS (strncpy, char *,
838 (char *restrict __dst, char const *restrict __src,
839 size_t __n));
840# endif
841# if __GLIBC__ >= 2
842_GL_CXXALIASWARN (strncpy);
843# endif
844#elif defined GNULIB_POSIXCHECK
845# if HAVE_RAW_DECL_STRNCPY
846_GL_WARN_ON_USE (strncpy, "strncpy is unportable - "
847 "use gnulib module strncpy for portability");
848# endif
849#endif
850
605/* Return a newly allocated copy of at most N bytes of STRING. */ 851/* Return a newly allocated copy of at most N bytes of STRING. */
606#if @GNULIB_STRNDUP@ 852#if @GNULIB_STRNDUP@
607# if @REPLACE_STRNDUP@ 853# if @REPLACE_STRNDUP@
@@ -610,27 +856,44 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
610# define strndup rpl_strndup 856# define strndup rpl_strndup
611# endif 857# endif
612_GL_FUNCDECL_RPL (strndup, char *, 858_GL_FUNCDECL_RPL (strndup, char *,
613 (char const *__s, size_t __n) 859 (char const *__s, size_t __n),
614 _GL_ARG_NONNULL ((1)) 860 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
615 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 861 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
616_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); 862_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
617# else 863# else
618# if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup) 864# if !@HAVE_DECL_STRNDUP@ \
865 || ((__GNUC__ >= 11 && !defined __clang__) && !defined strndup)
866# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
619_GL_FUNCDECL_SYS (strndup, char *, 867_GL_FUNCDECL_SYS (strndup, char *,
620 (char const *__s, size_t __n) 868 (char const *__s, size_t __n),
621 _GL_ARG_NONNULL ((1)) 869 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
870 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
871 _GL_ATTRIBUTE_NOTHROW;
872# else
873_GL_FUNCDECL_SYS (strndup, char *,
874 (char const *__s, size_t __n),
875 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
622 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 876 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
877# endif
623# endif 878# endif
624_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n)); 879_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
625# endif 880# endif
626_GL_CXXALIASWARN (strndup); 881_GL_CXXALIASWARN (strndup);
627#else 882#else
628# if __GNUC__ >= 11 && !defined strndup 883# if (__GNUC__ >= 11 && !defined __clang__) && !defined strndup
629/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */ 884/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */
885# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
630_GL_FUNCDECL_SYS (strndup, char *, 886_GL_FUNCDECL_SYS (strndup, char *,
631 (char const *__s, size_t __n) 887 (char const *__s, size_t __n),
632 _GL_ARG_NONNULL ((1)) 888 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
889 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
890 _GL_ATTRIBUTE_NOTHROW;
891# else
892_GL_FUNCDECL_SYS (strndup, char *,
893 (char const *__s, size_t __n),
894 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
633 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 895 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
896# endif
634# endif 897# endif
635# if defined GNULIB_POSIXCHECK 898# if defined GNULIB_POSIXCHECK
636# undef strndup 899# undef strndup
@@ -650,13 +913,13 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
650# undef strnlen 913# undef strnlen
651# define strnlen rpl_strnlen 914# define strnlen rpl_strnlen
652# endif 915# endif
653_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen) 916_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen),
654 _GL_ATTRIBUTE_PURE 917 _GL_ATTRIBUTE_PURE
655 _GL_ARG_NONNULL ((1))); 918 _GL_ARG_NONNULL ((1)));
656_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)); 919_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
657# else 920# else
658# if ! @HAVE_DECL_STRNLEN@ 921# if ! @HAVE_DECL_STRNLEN@
659_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen) 922_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen),
660 _GL_ATTRIBUTE_PURE 923 _GL_ATTRIBUTE_PURE
661 _GL_ARG_NONNULL ((1))); 924 _GL_ARG_NONNULL ((1)));
662# endif 925# endif
@@ -686,7 +949,7 @@ _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
686/* Find the first occurrence in S of any character in ACCEPT. */ 949/* Find the first occurrence in S of any character in ACCEPT. */
687#if @GNULIB_STRPBRK@ 950#if @GNULIB_STRPBRK@
688# if ! @HAVE_STRPBRK@ 951# if ! @HAVE_STRPBRK@
689_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) 952_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept),
690 _GL_ATTRIBUTE_PURE 953 _GL_ATTRIBUTE_PURE
691 _GL_ARG_NONNULL ((1, 2))); 954 _GL_ARG_NONNULL ((1, 2)));
692# endif 955# endif
@@ -699,9 +962,12 @@ _GL_CXXALIAS_SYS_CAST2 (strpbrk,
699# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 962# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
700 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 963 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
701 || defined __clang__) 964 || defined __clang__)
702_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept) throw ()); 965_GL_CXXALIASWARN1 (strpbrk, char *,
966 (char *__s, char const *__accept)
967 _GL_ATTRIBUTE_NOTHROW);
703_GL_CXXALIASWARN1 (strpbrk, char const *, 968_GL_CXXALIASWARN1 (strpbrk, char const *,
704 (char const *__s, char const *__accept) throw ()); 969 (char const *__s, char const *__accept)
970 _GL_ATTRIBUTE_NOTHROW);
705# elif __GLIBC__ >= 2 971# elif __GLIBC__ >= 2
706_GL_CXXALIASWARN (strpbrk); 972_GL_CXXALIASWARN (strpbrk);
707# endif 973# endif
@@ -768,7 +1034,7 @@ _GL_WARN_ON_USE_CXX (strrchr,
768#if @GNULIB_STRSEP@ 1034#if @GNULIB_STRSEP@
769# if ! @HAVE_STRSEP@ 1035# if ! @HAVE_STRSEP@
770_GL_FUNCDECL_SYS (strsep, char *, 1036_GL_FUNCDECL_SYS (strsep, char *,
771 (char **restrict __stringp, char const *restrict __delim) 1037 (char **restrict __stringp, char const *restrict __delim),
772 _GL_ARG_NONNULL ((1, 2))); 1038 _GL_ARG_NONNULL ((1, 2)));
773# endif 1039# endif
774_GL_CXXALIAS_SYS (strsep, char *, 1040_GL_CXXALIAS_SYS (strsep, char *,
@@ -793,7 +1059,7 @@ _GL_WARN_ON_USE (strsep, "strsep is unportable - "
793# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1059# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
794# define strstr rpl_strstr 1060# define strstr rpl_strstr
795# endif 1061# endif
796_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) 1062_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle),
797 _GL_ATTRIBUTE_PURE 1063 _GL_ATTRIBUTE_PURE
798 _GL_ARG_NONNULL ((1, 2))); 1064 _GL_ARG_NONNULL ((1, 2)));
799_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); 1065_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
@@ -809,9 +1075,11 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
809 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 1075 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
810 || defined __clang__) 1076 || defined __clang__)
811_GL_CXXALIASWARN1 (strstr, char *, 1077_GL_CXXALIASWARN1 (strstr, char *,
812 (char *haystack, const char *needle) throw ()); 1078 (char *haystack, const char *needle)
1079 _GL_ATTRIBUTE_NOTHROW);
813_GL_CXXALIASWARN1 (strstr, const char *, 1080_GL_CXXALIASWARN1 (strstr, const char *,
814 (const char *haystack, const char *needle) throw ()); 1081 (const char *haystack, const char *needle)
1082 _GL_ATTRIBUTE_NOTHROW);
815# elif __GLIBC__ >= 2 1083# elif __GLIBC__ >= 2
816_GL_CXXALIASWARN (strstr); 1084_GL_CXXALIASWARN (strstr);
817# endif 1085# endif
@@ -822,11 +1090,13 @@ _GL_CXXALIASWARN (strstr);
822 as a sequence of bytes, not of characters. */ 1090 as a sequence of bytes, not of characters. */
823# undef strstr 1091# undef strstr
824/* Assume strstr is always declared. */ 1092/* Assume strstr is always declared. */
825_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " 1093_GL_WARN_ON_USE_CXX (strstr,
826 "work correctly on character strings in most " 1094 const char *, char *, (const char *, const char *),
827 "multibyte locales - " 1095 "strstr is quadratic on many systems, and cannot "
828 "use mbsstr if you care about internationalization, " 1096 "work correctly on character strings in most "
829 "or use strstr if you care about speed"); 1097 "multibyte locales - "
1098 "use mbsstr if you care about internationalization, "
1099 "or use strstr if you care about speed");
830#endif 1100#endif
831 1101
832/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive 1102/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
@@ -837,7 +1107,7 @@ _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
837# define strcasestr rpl_strcasestr 1107# define strcasestr rpl_strcasestr
838# endif 1108# endif
839_GL_FUNCDECL_RPL (strcasestr, char *, 1109_GL_FUNCDECL_RPL (strcasestr, char *,
840 (const char *haystack, const char *needle) 1110 (const char *haystack, const char *needle),
841 _GL_ATTRIBUTE_PURE 1111 _GL_ATTRIBUTE_PURE
842 _GL_ARG_NONNULL ((1, 2))); 1112 _GL_ARG_NONNULL ((1, 2)));
843_GL_CXXALIAS_RPL (strcasestr, char *, 1113_GL_CXXALIAS_RPL (strcasestr, char *,
@@ -845,7 +1115,7 @@ _GL_CXXALIAS_RPL (strcasestr, char *,
845# else 1115# else
846# if ! @HAVE_STRCASESTR@ 1116# if ! @HAVE_STRCASESTR@
847_GL_FUNCDECL_SYS (strcasestr, char *, 1117_GL_FUNCDECL_SYS (strcasestr, char *,
848 (const char *haystack, const char *needle) 1118 (const char *haystack, const char *needle),
849 _GL_ATTRIBUTE_PURE 1119 _GL_ATTRIBUTE_PURE
850 _GL_ARG_NONNULL ((1, 2))); 1120 _GL_ARG_NONNULL ((1, 2)));
851# endif 1121# endif
@@ -860,10 +1130,12 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
860 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 1130 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
861 || defined __clang__) 1131 || defined __clang__)
862_GL_CXXALIASWARN1 (strcasestr, char *, 1132_GL_CXXALIASWARN1 (strcasestr, char *,
863 (char *haystack, const char *needle) throw ()); 1133 (char *haystack, const char *needle)
1134 _GL_ATTRIBUTE_NOTHROW);
864_GL_CXXALIASWARN1 (strcasestr, const char *, 1135_GL_CXXALIASWARN1 (strcasestr, const char *,
865 (const char *haystack, const char *needle) throw ()); 1136 (const char *haystack, const char *needle)
866# else 1137 _GL_ATTRIBUTE_NOTHROW);
1138# elif __GLIBC__ >= 2
867_GL_CXXALIASWARN (strcasestr); 1139_GL_CXXALIASWARN (strcasestr);
868# endif 1140# endif
869#elif defined GNULIB_POSIXCHECK 1141#elif defined GNULIB_POSIXCHECK
@@ -910,7 +1182,7 @@ _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
910# endif 1182# endif
911_GL_FUNCDECL_RPL (strtok_r, char *, 1183_GL_FUNCDECL_RPL (strtok_r, char *,
912 (char *restrict s, char const *restrict delim, 1184 (char *restrict s, char const *restrict delim,
913 char **restrict save_ptr) 1185 char **restrict save_ptr),
914 _GL_ARG_NONNULL ((2, 3))); 1186 _GL_ARG_NONNULL ((2, 3)));
915_GL_CXXALIAS_RPL (strtok_r, char *, 1187_GL_CXXALIAS_RPL (strtok_r, char *,
916 (char *restrict s, char const *restrict delim, 1188 (char *restrict s, char const *restrict delim,
@@ -922,7 +1194,7 @@ _GL_CXXALIAS_RPL (strtok_r, char *,
922# if ! @HAVE_DECL_STRTOK_R@ 1194# if ! @HAVE_DECL_STRTOK_R@
923_GL_FUNCDECL_SYS (strtok_r, char *, 1195_GL_FUNCDECL_SYS (strtok_r, char *,
924 (char *restrict s, char const *restrict delim, 1196 (char *restrict s, char const *restrict delim,
925 char **restrict save_ptr) 1197 char **restrict save_ptr),
926 _GL_ARG_NONNULL ((2, 3))); 1198 _GL_ARG_NONNULL ((2, 3)));
927# endif 1199# endif
928_GL_CXXALIAS_SYS (strtok_r, char *, 1200_GL_CXXALIAS_SYS (strtok_r, char *,
@@ -947,6 +1219,22 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
947/* The following functions are not specified by POSIX. They are gnulib 1219/* The following functions are not specified by POSIX. They are gnulib
948 extensions. */ 1220 extensions. */
949 1221
1222#if @GNULIB_STR_STARTSWITH@
1223/* Returns true if STRING starts with PREFIX.
1224 Returns false otherwise. */
1225_GL_EXTERN_C bool str_startswith (const char *string, const char *prefix)
1226 _GL_ATTRIBUTE_PURE
1227 _GL_ARG_NONNULL ((1, 2));
1228#endif
1229
1230#if @GNULIB_STR_ENDSWITH@
1231/* Returns true if STRING ends with SUFFIX.
1232 Returns false otherwise. */
1233_GL_EXTERN_C bool str_endswith (const char *string, const char *prefix)
1234 _GL_ATTRIBUTE_PURE
1235 _GL_ARG_NONNULL ((1, 2));
1236#endif
1237
950#if @GNULIB_MBSLEN@ 1238#if @GNULIB_MBSLEN@
951/* Return the number of multibyte characters in the character string STRING. 1239/* Return the number of multibyte characters in the character string STRING.
952 This considers multibyte characters, unlike strlen, which counts bytes. */ 1240 This considers multibyte characters, unlike strlen, which counts bytes. */
@@ -957,12 +1245,12 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
957# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1245# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
958# define mbslen rpl_mbslen 1246# define mbslen rpl_mbslen
959# endif 1247# endif
960_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) 1248_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string),
961 _GL_ATTRIBUTE_PURE 1249 _GL_ATTRIBUTE_PURE
962 _GL_ARG_NONNULL ((1))); 1250 _GL_ARG_NONNULL ((1)));
963_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); 1251_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
964# else 1252# else
965_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) 1253_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string),
966 _GL_ATTRIBUTE_PURE 1254 _GL_ATTRIBUTE_PURE
967 _GL_ARG_NONNULL ((1))); 1255 _GL_ARG_NONNULL ((1)));
968_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); 1256_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
@@ -989,12 +1277,12 @@ _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
989# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1277# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
990# define mbschr rpl_mbschr /* avoid collision with HP-UX function */ 1278# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
991# endif 1279# endif
992_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) 1280_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c),
993 _GL_ATTRIBUTE_PURE 1281 _GL_ATTRIBUTE_PURE
994 _GL_ARG_NONNULL ((1))); 1282 _GL_ARG_NONNULL ((1)));
995_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); 1283_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
996# else 1284# else
997_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) 1285_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c),
998 _GL_ATTRIBUTE_PURE 1286 _GL_ATTRIBUTE_PURE
999 _GL_ARG_NONNULL ((1))); 1287 _GL_ARG_NONNULL ((1)));
1000_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); 1288_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
@@ -1011,12 +1299,12 @@ _GL_CXXALIASWARN (mbschr);
1011# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1299# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1012# define mbsrchr rpl_mbsrchr /* avoid collision with system function */ 1300# define mbsrchr rpl_mbsrchr /* avoid collision with system function */
1013# endif 1301# endif
1014_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) 1302_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c),
1015 _GL_ATTRIBUTE_PURE 1303 _GL_ATTRIBUTE_PURE
1016 _GL_ARG_NONNULL ((1))); 1304 _GL_ARG_NONNULL ((1)));
1017_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); 1305_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
1018# else 1306# else
1019_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) 1307_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c),
1020 _GL_ATTRIBUTE_PURE 1308 _GL_ATTRIBUTE_PURE
1021 _GL_ARG_NONNULL ((1))); 1309 _GL_ARG_NONNULL ((1)));
1022_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); 1310_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
@@ -1032,6 +1320,33 @@ _GL_CXXALIASWARN (mbsrchr);
1032_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) 1320_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
1033 _GL_ATTRIBUTE_PURE 1321 _GL_ATTRIBUTE_PURE
1034 _GL_ARG_NONNULL ((1, 2)); 1322 _GL_ARG_NONNULL ((1, 2));
1323# ifndef _GL_NO_CONST_GENERICS
1324/* Don't silently convert a 'const char *' to a 'char *'. Programmers want
1325 compiler warnings for 'const' related mistakes. */
1326# ifdef __cplusplus
1327extern "C++" { /* needed for AIX */
1328template <typename T>
1329 T * mbsstr_template (T* haystack, const char *needle);
1330template <>
1331 inline char * mbsstr_template (char *haystack, const char *needle)
1332 { return mbsstr (haystack, needle); }
1333template <>
1334 inline const char * mbsstr_template (const char *haystack, const char *needle)
1335 { return mbsstr (haystack, needle); }
1336}
1337# undef mbsstr
1338# define mbsstr mbsstr_template
1339# elif !defined mbsstr
1340# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
1341 || defined __ICC || defined __TINYC__ \
1342 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
1343# define mbsstr(h,n) \
1344 _Generic ((h), \
1345 char const *: (char const *) mbsstr ((h), (n)), \
1346 default : mbsstr ((h), (n)))
1347# endif
1348# endif
1349# endif
1035#endif 1350#endif
1036 1351
1037#if @GNULIB_MBSCASECMP@ 1352#if @GNULIB_MBSCASECMP@
@@ -1073,6 +1388,33 @@ _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
1073_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) 1388_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1074 _GL_ATTRIBUTE_PURE 1389 _GL_ATTRIBUTE_PURE
1075 _GL_ARG_NONNULL ((1, 2)); 1390 _GL_ARG_NONNULL ((1, 2));
1391# ifndef _GL_NO_CONST_GENERICS
1392/* Don't silently convert a 'const char *' to a 'char *'. Programmers want
1393 compiler warnings for 'const' related mistakes. */
1394# ifdef __cplusplus
1395extern "C++" { /* needed for AIX */
1396template <typename T>
1397 T * mbspcasecmp_template (T* string, const char *prefix);
1398template <>
1399 inline char * mbspcasecmp_template (char *string, const char *prefix)
1400 { return mbspcasecmp (string, prefix); }
1401template <>
1402 inline const char * mbspcasecmp_template (const char *string, const char *prefix)
1403 { return mbspcasecmp (string, prefix); }
1404}
1405# undef mbspcasecmp
1406# define mbspcasecmp mbspcasecmp_template
1407# elif !defined mbspcasecmp
1408# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
1409 || defined __ICC || defined __TINYC__ \
1410 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
1411# define mbspcasecmp(s,p) \
1412 _Generic ((s), \
1413 char const *: (char const *) mbspcasecmp ((s), (p)), \
1414 default : mbspcasecmp ((s), (p)))
1415# endif
1416# endif
1417# endif
1076#endif 1418#endif
1077 1419
1078#if @GNULIB_MBSCASESTR@ 1420#if @GNULIB_MBSCASESTR@
@@ -1084,6 +1426,33 @@ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1084_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) 1426_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
1085 _GL_ATTRIBUTE_PURE 1427 _GL_ATTRIBUTE_PURE
1086 _GL_ARG_NONNULL ((1, 2)); 1428 _GL_ARG_NONNULL ((1, 2));
1429# ifndef _GL_NO_CONST_GENERICS
1430/* Don't silently convert a 'const char *' to a 'char *'. Programmers want
1431 compiler warnings for 'const' related mistakes. */
1432# ifdef __cplusplus
1433extern "C++" { /* needed for AIX */
1434template <typename T>
1435 T * mbscasestr_template (T* haystack, const char *needle);
1436template <>
1437 inline char * mbscasestr_template (char *haystack, const char *needle)
1438 { return mbscasestr (haystack, needle); }
1439template <>
1440 inline const char * mbscasestr_template (const char *haystack, const char *needle)
1441 { return mbscasestr (haystack, needle); }
1442}
1443# undef mbscasestr
1444# define mbscasestr mbscasestr_template
1445# elif !defined mbscasestr
1446# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
1447 || defined __ICC || defined __TINYC__ \
1448 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
1449# define mbscasestr(h,n) \
1450 _Generic ((h), \
1451 char const *: (char const *) mbscasestr ((h), (n)), \
1452 default : mbscasestr ((h), (n)))
1453# endif
1454# endif
1455# endif
1087#endif 1456#endif
1088 1457
1089#if @GNULIB_MBSCSPN@ 1458#if @GNULIB_MBSCSPN@
@@ -1106,12 +1475,12 @@ _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
1106# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1475# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1107# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ 1476# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
1108# endif 1477# endif
1109_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) 1478_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept),
1110 _GL_ATTRIBUTE_PURE 1479 _GL_ATTRIBUTE_PURE
1111 _GL_ARG_NONNULL ((1, 2))); 1480 _GL_ARG_NONNULL ((1, 2)));
1112_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); 1481_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
1113# else 1482# else
1114_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) 1483_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept),
1115 _GL_ATTRIBUTE_PURE 1484 _GL_ATTRIBUTE_PURE
1116 _GL_ARG_NONNULL ((1, 2))); 1485 _GL_ARG_NONNULL ((1, 2)));
1117_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); 1486_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
@@ -1171,6 +1540,26 @@ _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
1171 _GL_ARG_NONNULL ((2, 3)); 1540 _GL_ARG_NONNULL ((2, 3));
1172#endif 1541#endif
1173 1542
1543#if @GNULIB_MBS_STARTSWITH@
1544/* Returns true if STRING starts with PREFIX.
1545 Returns false otherwise. */
1546_GL_EXTERN_C bool mbs_startswith (const char *string, const char *prefix)
1547 _GL_ATTRIBUTE_PURE
1548 _GL_ARG_NONNULL ((1, 2));
1549/* No extra code is needed for multibyte locales for this function. */
1550# define mbs_startswith str_startswith
1551#endif
1552
1553#if @GNULIB_MBS_ENDSWITH@
1554/* Returns true if STRING ends with SUFFIX.
1555 Returns false otherwise.
1556 Unlike str_endswith(), this function works correctly in multibyte locales.
1557 */
1558_GL_EXTERN_C bool mbs_endswith (const char *string, const char *suffix)
1559 _GL_ATTRIBUTE_PURE
1560 _GL_ARG_NONNULL ((1, 2));
1561#endif
1562
1174/* Map any int, typically from errno, into an error message. */ 1563/* Map any int, typically from errno, into an error message. */
1175#if @GNULIB_STRERROR@ 1564#if @GNULIB_STRERROR@
1176# if @REPLACE_STRERROR@ 1565# if @REPLACE_STRERROR@
@@ -1178,7 +1567,7 @@ _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
1178# undef strerror 1567# undef strerror
1179# define strerror rpl_strerror 1568# define strerror rpl_strerror
1180# endif 1569# endif
1181_GL_FUNCDECL_RPL (strerror, char *, (int)); 1570_GL_FUNCDECL_RPL (strerror, char *, (int), );
1182_GL_CXXALIAS_RPL (strerror, char *, (int)); 1571_GL_CXXALIAS_RPL (strerror, char *, (int));
1183# else 1572# else
1184_GL_CXXALIAS_SYS (strerror, char *, (int)); 1573_GL_CXXALIAS_SYS (strerror, char *, (int));
@@ -1201,17 +1590,17 @@ _GL_WARN_ON_USE (strerror, "strerror is unportable - "
1201# undef strerror_r 1590# undef strerror_r
1202# define strerror_r rpl_strerror_r 1591# define strerror_r rpl_strerror_r
1203# endif 1592# endif
1204_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) 1593_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen),
1205 _GL_ARG_NONNULL ((2))); 1594 _GL_ARG_NONNULL ((2)));
1206_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); 1595_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
1207# else 1596# else
1208# if !@HAVE_DECL_STRERROR_R@ 1597# if !@HAVE_DECL_STRERROR_R@
1209_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) 1598_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen),
1210 _GL_ARG_NONNULL ((2))); 1599 _GL_ARG_NONNULL ((2)));
1211# endif 1600# endif
1212_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); 1601_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
1213# endif 1602# endif
1214# if @HAVE_DECL_STRERROR_R@ 1603# if __GLIBC__ >= 2 && @HAVE_DECL_STRERROR_R@
1215_GL_CXXALIASWARN (strerror_r); 1604_GL_CXXALIASWARN (strerror_r);
1216# endif 1605# endif
1217#elif defined GNULIB_POSIXCHECK 1606#elif defined GNULIB_POSIXCHECK
@@ -1222,6 +1611,44 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1222# endif 1611# endif
1223#endif 1612#endif
1224 1613
1614/* Map any int, typically from errno, into an error message.
1615 With locale_t argument. */
1616#if @GNULIB_STRERROR_L@
1617# if @REPLACE_STRERROR_L@
1618# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1619# undef strerror_l
1620# define strerror_l rpl_strerror_l
1621# endif
1622_GL_FUNCDECL_RPL (strerror_l, char *, (int errnum, locale_t locale),
1623 _GL_ARG_NONNULL ((2)));
1624_GL_CXXALIAS_RPL (strerror_l, char *, (int errnum, locale_t locale));
1625# else
1626# if !@HAVE_STRERROR_L@
1627_GL_FUNCDECL_SYS (strerror_l, char *, (int errnum, locale_t locale),
1628 _GL_ARG_NONNULL ((2)));
1629# endif
1630_GL_CXXALIAS_SYS (strerror_l, char *, (int errnum, locale_t locale));
1631# endif
1632# if __GLIBC__ >= 2
1633_GL_CXXALIASWARN (strerror_l);
1634# endif
1635#elif defined GNULIB_POSIXCHECK
1636# undef strerror_l
1637# if HAVE_RAW_DECL_STRERROR_L
1638_GL_WARN_ON_USE (strerror_l, "strerror_l is unportable - "
1639 "use gnulib module strerror_l for portability");
1640# endif
1641#endif
1642
1643/* Map any int, typically from errno, into an error message. Multithread-safe,
1644 with locale_t argument.
1645 Not portable! Only provided by gnulib. */
1646#if @GNULIB_STRERROR_L@
1647_GL_FUNCDECL_SYS (strerror_l_r, int,
1648 (int errnum, char *buf, size_t buflen, locale_t locale),
1649 _GL_ARG_NONNULL ((2, 4)));
1650#endif
1651
1225/* Return the name of the system error code ERRNUM. */ 1652/* Return the name of the system error code ERRNUM. */
1226#if @GNULIB_STRERRORNAME_NP@ 1653#if @GNULIB_STRERRORNAME_NP@
1227# if @REPLACE_STRERRORNAME_NP@ 1654# if @REPLACE_STRERRORNAME_NP@
@@ -1229,15 +1656,17 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1229# undef strerrorname_np 1656# undef strerrorname_np
1230# define strerrorname_np rpl_strerrorname_np 1657# define strerrorname_np rpl_strerrorname_np
1231# endif 1658# endif
1232_GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum)); 1659_GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum), );
1233_GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum)); 1660_GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum));
1234# else 1661# else
1235# if !@HAVE_STRERRORNAME_NP@ 1662# if !@HAVE_STRERRORNAME_NP@
1236_GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum)); 1663_GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum), );
1237# endif 1664# endif
1238_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum)); 1665_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum));
1239# endif 1666# endif
1667# if __GLIBC__ >= 2
1240_GL_CXXALIASWARN (strerrorname_np); 1668_GL_CXXALIASWARN (strerrorname_np);
1669# endif
1241#elif defined GNULIB_POSIXCHECK 1670#elif defined GNULIB_POSIXCHECK
1242# undef strerrorname_np 1671# undef strerrorname_np
1243# if HAVE_RAW_DECL_STRERRORNAME_NP 1672# if HAVE_RAW_DECL_STRERRORNAME_NP
@@ -1249,7 +1678,7 @@ _GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - "
1249/* Return an abbreviation string for the signal number SIG. */ 1678/* Return an abbreviation string for the signal number SIG. */
1250#if @GNULIB_SIGABBREV_NP@ 1679#if @GNULIB_SIGABBREV_NP@
1251# if ! @HAVE_SIGABBREV_NP@ 1680# if ! @HAVE_SIGABBREV_NP@
1252_GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig)); 1681_GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig), );
1253# endif 1682# endif
1254_GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig)); 1683_GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig));
1255_GL_CXXALIASWARN (sigabbrev_np); 1684_GL_CXXALIASWARN (sigabbrev_np);
@@ -1264,7 +1693,7 @@ _GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - "
1264/* Return an English description string for the signal number SIG. */ 1693/* Return an English description string for the signal number SIG. */
1265#if @GNULIB_SIGDESCR_NP@ 1694#if @GNULIB_SIGDESCR_NP@
1266# if ! @HAVE_SIGDESCR_NP@ 1695# if ! @HAVE_SIGDESCR_NP@
1267_GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig)); 1696_GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig), );
1268# endif 1697# endif
1269_GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig)); 1698_GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig));
1270_GL_CXXALIASWARN (sigdescr_np); 1699_GL_CXXALIASWARN (sigdescr_np);
@@ -1281,11 +1710,11 @@ _GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - "
1281# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1710# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1282# define strsignal rpl_strsignal 1711# define strsignal rpl_strsignal
1283# endif 1712# endif
1284_GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); 1713_GL_FUNCDECL_RPL (strsignal, char *, (int __sig), );
1285_GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); 1714_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
1286# else 1715# else
1287# if ! @HAVE_DECL_STRSIGNAL@ 1716# if ! @HAVE_DECL_STRSIGNAL@
1288_GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); 1717_GL_FUNCDECL_SYS (strsignal, char *, (int __sig), );
1289# endif 1718# endif
1290/* Need to cast, because on Cygwin 1.5.x systems, the return type is 1719/* Need to cast, because on Cygwin 1.5.x systems, the return type is
1291 'const char *'. */ 1720 'const char *'. */
@@ -1301,12 +1730,22 @@ _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
1301#endif 1730#endif
1302 1731
1303#if @GNULIB_STRVERSCMP@ 1732#if @GNULIB_STRVERSCMP@
1304# if !@HAVE_STRVERSCMP@ 1733# if @REPLACE_STRVERSCMP@
1305_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) 1734# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1735# define strverscmp rpl_strverscmp
1736# endif
1737_GL_FUNCDECL_RPL (strverscmp, int, (const char *, const char *),
1306 _GL_ATTRIBUTE_PURE 1738 _GL_ATTRIBUTE_PURE
1307 _GL_ARG_NONNULL ((1, 2))); 1739 _GL_ARG_NONNULL ((1, 2)));
1308# endif 1740_GL_CXXALIAS_RPL (strverscmp, int, (const char *, const char *));
1741# else
1742# if !@HAVE_STRVERSCMP@
1743_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *),
1744 _GL_ATTRIBUTE_PURE
1745 _GL_ARG_NONNULL ((1, 2)));
1746# endif
1309_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); 1747_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
1748# endif
1310_GL_CXXALIASWARN (strverscmp); 1749_GL_CXXALIASWARN (strverscmp);
1311#elif defined GNULIB_POSIXCHECK 1750#elif defined GNULIB_POSIXCHECK
1312# undef strverscmp 1751# undef strverscmp