diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-12-28 12:13:40 +0100 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-12-28 12:13:40 +0100 |
| commit | b0afb8fe0ff1d87165af9df61501197a06240dda (patch) | |
| tree | 274ac6a96c53ef4c19ab4974ce24a06a233128c5 /gl/string.in.h | |
| parent | 68fc05381ee5fa0aee1413118fbb3d81ca888b09 (diff) | |
| download | monitoring-plugins-b0afb8fe0ff1d87165af9df61501197a06240dda.tar.gz | |
Sync with Gnulib stable-202507 code (a8ac9f9ce5)
Diffstat (limited to 'gl/string.in.h')
| -rw-r--r-- | gl/string.in.h | 483 |
1 files changed, 392 insertions, 91 deletions
diff --git a/gl/string.in.h b/gl/string.in.h index 44ec2e7e..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-2024 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,12 +34,12 @@ | |||
| 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 |
| @@ -54,6 +54,11 @@ | |||
| 54 | /* NetBSD 5.0 mis-defines NULL. */ | 54 | /* NetBSD 5.0 mis-defines NULL. */ |
| 55 | #include <stddef.h> | 55 | #include <stddef.h> |
| 56 | 56 | ||
| 57 | #if @GNULIB_STRERROR_L@ | ||
| 58 | /* Get locale_t. */ | ||
| 59 | # include <locale.h> | ||
| 60 | #endif | ||
| 61 | |||
| 57 | /* MirBSD defines mbslen as a macro. */ | 62 | /* MirBSD defines mbslen as a macro. */ |
| 58 | #if @GNULIB_MBSLEN@ && defined __MirBSD__ | 63 | #if @GNULIB_MBSLEN@ && defined __MirBSD__ |
| 59 | # include <wchar.h> | 64 | # include <wchar.h> |
| @@ -79,7 +84,7 @@ | |||
| 79 | 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 |
| 80 | function F. */ | 85 | function F. */ |
| 81 | #ifndef _GL_ATTRIBUTE_DEALLOC | 86 | #ifndef _GL_ATTRIBUTE_DEALLOC |
| 82 | # if __GNUC__ >= 11 | 87 | # if __GNUC__ >= 11 && !defined __clang__ |
| 83 | # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) | 88 | # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) |
| 84 | # else | 89 | # else |
| 85 | # define _GL_ATTRIBUTE_DEALLOC(f, i) | 90 | # define _GL_ATTRIBUTE_DEALLOC(f, i) |
| @@ -111,11 +116,23 @@ | |||
| 111 | # endif | 116 | # endif |
| 112 | #endif | 117 | #endif |
| 113 | 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 | |||
| 114 | /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. | 131 | /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. |
| 115 | */ | 132 | */ |
| 116 | #ifndef _GL_ATTRIBUTE_NOTHROW | 133 | #ifndef _GL_ATTRIBUTE_NOTHROW |
| 117 | # if defined __cplusplus | 134 | # if defined __cplusplus |
| 118 | # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 | 135 | # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4 |
| 119 | # if __cplusplus >= 201103L | 136 | # if __cplusplus >= 201103L |
| 120 | # define _GL_ATTRIBUTE_NOTHROW noexcept (true) | 137 | # define _GL_ATTRIBUTE_NOTHROW noexcept (true) |
| 121 | # else | 138 | # else |
| @@ -149,6 +166,7 @@ | |||
| 149 | 166 | ||
| 150 | /* The definition of _GL_WARN_ON_USE is copied here. */ | 167 | /* The definition of _GL_WARN_ON_USE is copied here. */ |
| 151 | 168 | ||
| 169 | |||
| 152 | /* 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 |
| 153 | been included yet. */ | 171 | been included yet. */ |
| 154 | #if @GNULIB_FREE_POSIX@ | 172 | #if @GNULIB_FREE_POSIX@ |
| @@ -193,12 +211,97 @@ _GL_EXTERN_C void free (void *); | |||
| 193 | # endif | 211 | # endif |
| 194 | #endif | 212 | #endif |
| 195 | 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 | |||
| 196 | /* 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 |
| 197 | this function, even if the block is dead after the call. */ | 300 | this function, even if the block is dead after the call. */ |
| 198 | #if @GNULIB_EXPLICIT_BZERO@ | 301 | #if @GNULIB_EXPLICIT_BZERO@ |
| 199 | # if ! @HAVE_EXPLICIT_BZERO@ | 302 | # if ! @HAVE_EXPLICIT_BZERO@ |
| 200 | _GL_FUNCDECL_SYS (explicit_bzero, void, | 303 | _GL_FUNCDECL_SYS (explicit_bzero, void, |
| 201 | (void *__dest, size_t __n) _GL_ARG_NONNULL ((1))); | 304 | (void *__dest, size_t __n), _GL_ARG_NONNULL ((1))); |
| 202 | # endif | 305 | # endif |
| 203 | _GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n)); | 306 | _GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n)); |
| 204 | _GL_CXXALIASWARN (explicit_bzero); | 307 | _GL_CXXALIASWARN (explicit_bzero); |
| @@ -210,10 +313,11 @@ _GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - " | |||
| 210 | # endif | 313 | # endif |
| 211 | #endif | 314 | #endif |
| 212 | 315 | ||
| 316 | |||
| 213 | /* Find the index of the least-significant set bit. */ | 317 | /* Find the index of the least-significant set bit. */ |
| 214 | #if @GNULIB_FFSL@ | 318 | #if @GNULIB_FFSL@ |
| 215 | # if !@HAVE_FFSL@ | 319 | # if !@HAVE_FFSL@ |
| 216 | _GL_FUNCDECL_SYS (ffsl, int, (long int i)); | 320 | _GL_FUNCDECL_SYS (ffsl, int, (long int i), ); |
| 217 | # endif | 321 | # endif |
| 218 | _GL_CXXALIAS_SYS (ffsl, int, (long int i)); | 322 | _GL_CXXALIAS_SYS (ffsl, int, (long int i)); |
| 219 | _GL_CXXALIASWARN (ffsl); | 323 | _GL_CXXALIASWARN (ffsl); |
| @@ -231,11 +335,11 @@ _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module"); | |||
| 231 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 335 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 232 | # define ffsll rpl_ffsll | 336 | # define ffsll rpl_ffsll |
| 233 | # endif | 337 | # endif |
| 234 | _GL_FUNCDECL_RPL (ffsll, int, (long long int i)); | 338 | _GL_FUNCDECL_RPL (ffsll, int, (long long int i), ); |
| 235 | _GL_CXXALIAS_RPL (ffsll, int, (long long int i)); | 339 | _GL_CXXALIAS_RPL (ffsll, int, (long long int i)); |
| 236 | # else | 340 | # else |
| 237 | # if !@HAVE_FFSLL@ | 341 | # if !@HAVE_FFSLL@ |
| 238 | _GL_FUNCDECL_SYS (ffsll, int, (long long int i)); | 342 | _GL_FUNCDECL_SYS (ffsll, int, (long long int i), ); |
| 239 | # endif | 343 | # endif |
| 240 | _GL_CXXALIAS_SYS (ffsll, int, (long long int i)); | 344 | _GL_CXXALIAS_SYS (ffsll, int, (long long int i)); |
| 241 | # endif | 345 | # endif |
| @@ -274,9 +378,9 @@ _GL_CXXALIASWARN (memccpy); | |||
| 274 | # undef memchr | 378 | # undef memchr |
| 275 | # define memchr rpl_memchr | 379 | # define memchr rpl_memchr |
| 276 | # endif | 380 | # endif |
| 277 | _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), |
| 278 | _GL_ATTRIBUTE_PURE | 382 | _GL_ATTRIBUTE_PURE |
| 279 | _GL_ARG_NONNULL ((1))); | 383 | _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)); |
| 280 | _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)); |
| 281 | # else | 385 | # else |
| 282 | /* On some systems, this function is defined as an overloaded function: | 386 | /* On some systems, this function is defined as an overloaded function: |
| @@ -301,8 +405,10 @@ _GL_CXXALIASWARN (memchr); | |||
| 301 | #elif defined GNULIB_POSIXCHECK | 405 | #elif defined GNULIB_POSIXCHECK |
| 302 | # undef memchr | 406 | # undef memchr |
| 303 | /* Assume memchr is always declared. */ | 407 | /* Assume memchr is always declared. */ |
| 304 | _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " | 408 | _GL_WARN_ON_USE_CXX (memchr, |
| 305 | "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" ); | ||
| 306 | #endif | 412 | #endif |
| 307 | 413 | ||
| 308 | /* Return the first occurrence of NEEDLE in HAYSTACK. */ | 414 | /* Return the first occurrence of NEEDLE in HAYSTACK. */ |
| @@ -313,7 +419,7 @@ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " | |||
| 313 | # endif | 419 | # endif |
| 314 | _GL_FUNCDECL_RPL (memmem, void *, | 420 | _GL_FUNCDECL_RPL (memmem, void *, |
| 315 | (void const *__haystack, size_t __haystack_len, | 421 | (void const *__haystack, size_t __haystack_len, |
| 316 | void const *__needle, size_t __needle_len) | 422 | void const *__needle, size_t __needle_len), |
| 317 | _GL_ATTRIBUTE_PURE | 423 | _GL_ATTRIBUTE_PURE |
| 318 | _GL_ARG_NONNULL ((1, 3))); | 424 | _GL_ARG_NONNULL ((1, 3))); |
| 319 | _GL_CXXALIAS_RPL (memmem, void *, | 425 | _GL_CXXALIAS_RPL (memmem, void *, |
| @@ -323,7 +429,7 @@ _GL_CXXALIAS_RPL (memmem, void *, | |||
| 323 | # if ! @HAVE_DECL_MEMMEM@ | 429 | # if ! @HAVE_DECL_MEMMEM@ |
| 324 | _GL_FUNCDECL_SYS (memmem, void *, | 430 | _GL_FUNCDECL_SYS (memmem, void *, |
| 325 | (void const *__haystack, size_t __haystack_len, | 431 | (void const *__haystack, size_t __haystack_len, |
| 326 | void const *__needle, size_t __needle_len) | 432 | void const *__needle, size_t __needle_len), |
| 327 | _GL_ATTRIBUTE_PURE | 433 | _GL_ATTRIBUTE_PURE |
| 328 | _GL_ARG_NONNULL ((1, 3))); | 434 | _GL_ARG_NONNULL ((1, 3))); |
| 329 | # endif | 435 | # endif |
| @@ -351,7 +457,7 @@ _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " | |||
| 351 | # endif | 457 | # endif |
| 352 | _GL_FUNCDECL_RPL (mempcpy, void *, | 458 | _GL_FUNCDECL_RPL (mempcpy, void *, |
| 353 | (void *restrict __dest, void const *restrict __src, | 459 | (void *restrict __dest, void const *restrict __src, |
| 354 | size_t __n) | 460 | size_t __n), |
| 355 | _GL_ARG_NONNULL ((1, 2))); | 461 | _GL_ARG_NONNULL ((1, 2))); |
| 356 | _GL_CXXALIAS_RPL (mempcpy, void *, | 462 | _GL_CXXALIAS_RPL (mempcpy, void *, |
| 357 | (void *restrict __dest, void const *restrict __src, | 463 | (void *restrict __dest, void const *restrict __src, |
| @@ -360,7 +466,7 @@ _GL_CXXALIAS_RPL (mempcpy, void *, | |||
| 360 | # if !@HAVE_MEMPCPY@ | 466 | # if !@HAVE_MEMPCPY@ |
| 361 | _GL_FUNCDECL_SYS (mempcpy, void *, | 467 | _GL_FUNCDECL_SYS (mempcpy, void *, |
| 362 | (void *restrict __dest, void const *restrict __src, | 468 | (void *restrict __dest, void const *restrict __src, |
| 363 | size_t __n) | 469 | size_t __n), |
| 364 | _GL_ARG_NONNULL ((1, 2))); | 470 | _GL_ARG_NONNULL ((1, 2))); |
| 365 | # endif | 471 | # endif |
| 366 | _GL_CXXALIAS_SYS (mempcpy, void *, | 472 | _GL_CXXALIAS_SYS (mempcpy, void *, |
| @@ -381,9 +487,9 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " | |||
| 381 | /* 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). */ |
| 382 | #if @GNULIB_MEMRCHR@ | 488 | #if @GNULIB_MEMRCHR@ |
| 383 | # if ! @HAVE_DECL_MEMRCHR@ | 489 | # if ! @HAVE_DECL_MEMRCHR@ |
| 384 | _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) | 490 | _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t), |
| 385 | _GL_ATTRIBUTE_PURE | 491 | _GL_ATTRIBUTE_PURE |
| 386 | _GL_ARG_NONNULL ((1))); | 492 | _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)); |
| 387 | # endif | 493 | # endif |
| 388 | /* On some systems, this function is defined as an overloaded function: | 494 | /* On some systems, this function is defined as an overloaded function: |
| 389 | extern "C++" { const void * std::memrchr (const void *, int, size_t); } | 495 | extern "C++" { const void * std::memrchr (const void *, int, size_t); } |
| @@ -420,16 +526,20 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " | |||
| 420 | # define memset_explicit rpl_memset_explicit | 526 | # define memset_explicit rpl_memset_explicit |
| 421 | # endif | 527 | # endif |
| 422 | _GL_FUNCDECL_RPL (memset_explicit, void *, | 528 | _GL_FUNCDECL_RPL (memset_explicit, void *, |
| 423 | (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1))); | 529 | (void *__dest, int __c, size_t __n), |
| 530 | _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)); | ||
| 424 | _GL_CXXALIAS_RPL (memset_explicit, void *, (void *__dest, int __c, size_t __n)); | 531 | _GL_CXXALIAS_RPL (memset_explicit, void *, (void *__dest, int __c, size_t __n)); |
| 425 | # else | 532 | # else |
| 426 | # if !@HAVE_MEMSET_EXPLICIT@ | 533 | # if !@HAVE_MEMSET_EXPLICIT@ |
| 427 | _GL_FUNCDECL_SYS (memset_explicit, void *, | 534 | _GL_FUNCDECL_SYS (memset_explicit, void *, |
| 428 | (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1))); | 535 | (void *__dest, int __c, size_t __n), |
| 536 | _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)); | ||
| 429 | # endif | 537 | # endif |
| 430 | _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)); |
| 431 | # endif | 539 | # endif |
| 540 | # if __GLIBC__ >= 2 | ||
| 432 | _GL_CXXALIASWARN (memset_explicit); | 541 | _GL_CXXALIASWARN (memset_explicit); |
| 542 | # endif | ||
| 433 | #elif defined GNULIB_POSIXCHECK | 543 | #elif defined GNULIB_POSIXCHECK |
| 434 | # undef memset_explicit | 544 | # undef memset_explicit |
| 435 | # if HAVE_RAW_DECL_MEMSET_EXPLICIT | 545 | # if HAVE_RAW_DECL_MEMSET_EXPLICIT |
| @@ -443,7 +553,7 @@ _GL_WARN_ON_USE (memset_explicit, "memset_explicit is unportable - " | |||
| 443 | occur within N bytes. */ | 553 | occur within N bytes. */ |
| 444 | #if @GNULIB_RAWMEMCHR@ | 554 | #if @GNULIB_RAWMEMCHR@ |
| 445 | # if ! @HAVE_RAWMEMCHR@ | 555 | # if ! @HAVE_RAWMEMCHR@ |
| 446 | _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) | 556 | _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in), |
| 447 | _GL_ATTRIBUTE_PURE | 557 | _GL_ATTRIBUTE_PURE |
| 448 | _GL_ARG_NONNULL ((1))); | 558 | _GL_ARG_NONNULL ((1))); |
| 449 | # endif | 559 | # endif |
| @@ -481,14 +591,14 @@ _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " | |||
| 481 | # define stpcpy rpl_stpcpy | 591 | # define stpcpy rpl_stpcpy |
| 482 | # endif | 592 | # endif |
| 483 | _GL_FUNCDECL_RPL (stpcpy, char *, | 593 | _GL_FUNCDECL_RPL (stpcpy, char *, |
| 484 | (char *restrict __dst, char const *restrict __src) | 594 | (char *restrict __dst, char const *restrict __src), |
| 485 | _GL_ARG_NONNULL ((1, 2))); | 595 | _GL_ARG_NONNULL ((1, 2))); |
| 486 | _GL_CXXALIAS_RPL (stpcpy, char *, | 596 | _GL_CXXALIAS_RPL (stpcpy, char *, |
| 487 | (char *restrict __dst, char const *restrict __src)); | 597 | (char *restrict __dst, char const *restrict __src)); |
| 488 | # else | 598 | # else |
| 489 | # if !@HAVE_STPCPY@ | 599 | # if !@HAVE_STPCPY@ |
| 490 | _GL_FUNCDECL_SYS (stpcpy, char *, | 600 | _GL_FUNCDECL_SYS (stpcpy, char *, |
| 491 | (char *restrict __dst, char const *restrict __src) | 601 | (char *restrict __dst, char const *restrict __src), |
| 492 | _GL_ARG_NONNULL ((1, 2))); | 602 | _GL_ARG_NONNULL ((1, 2))); |
| 493 | # endif | 603 | # endif |
| 494 | _GL_CXXALIAS_SYS (stpcpy, char *, | 604 | _GL_CXXALIAS_SYS (stpcpy, char *, |
| @@ -515,7 +625,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " | |||
| 515 | # endif | 625 | # endif |
| 516 | _GL_FUNCDECL_RPL (stpncpy, char *, | 626 | _GL_FUNCDECL_RPL (stpncpy, char *, |
| 517 | (char *restrict __dst, char const *restrict __src, | 627 | (char *restrict __dst, char const *restrict __src, |
| 518 | size_t __n) | 628 | size_t __n), |
| 519 | _GL_ARG_NONNULL ((1, 2))); | 629 | _GL_ARG_NONNULL ((1, 2))); |
| 520 | _GL_CXXALIAS_RPL (stpncpy, char *, | 630 | _GL_CXXALIAS_RPL (stpncpy, char *, |
| 521 | (char *restrict __dst, char const *restrict __src, | 631 | (char *restrict __dst, char const *restrict __src, |
| @@ -524,7 +634,7 @@ _GL_CXXALIAS_RPL (stpncpy, char *, | |||
| 524 | # if ! @HAVE_STPNCPY@ | 634 | # if ! @HAVE_STPNCPY@ |
| 525 | _GL_FUNCDECL_SYS (stpncpy, char *, | 635 | _GL_FUNCDECL_SYS (stpncpy, char *, |
| 526 | (char *restrict __dst, char const *restrict __src, | 636 | (char *restrict __dst, char const *restrict __src, |
| 527 | size_t __n) | 637 | size_t __n), |
| 528 | _GL_ARG_NONNULL ((1, 2))); | 638 | _GL_ARG_NONNULL ((1, 2))); |
| 529 | # endif | 639 | # endif |
| 530 | _GL_CXXALIAS_SYS (stpncpy, char *, | 640 | _GL_CXXALIAS_SYS (stpncpy, char *, |
| @@ -560,14 +670,14 @@ _GL_WARN_ON_USE_CXX (strchr, | |||
| 560 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 670 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 561 | # define strchrnul rpl_strchrnul | 671 | # define strchrnul rpl_strchrnul |
| 562 | # endif | 672 | # endif |
| 563 | _GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in) | 673 | _GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in), |
| 564 | _GL_ATTRIBUTE_PURE | 674 | _GL_ATTRIBUTE_PURE |
| 565 | _GL_ARG_NONNULL ((1))); | 675 | _GL_ARG_NONNULL ((1))); |
| 566 | _GL_CXXALIAS_RPL (strchrnul, char *, | 676 | _GL_CXXALIAS_RPL (strchrnul, char *, |
| 567 | (const char *str, int ch)); | 677 | (const char *str, int ch)); |
| 568 | # else | 678 | # else |
| 569 | # if ! @HAVE_STRCHRNUL@ | 679 | # if ! @HAVE_STRCHRNUL@ |
| 570 | _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) | 680 | _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in), |
| 571 | _GL_ATTRIBUTE_PURE | 681 | _GL_ATTRIBUTE_PURE |
| 572 | _GL_ARG_NONNULL ((1))); | 682 | _GL_ARG_NONNULL ((1))); |
| 573 | # endif | 683 | # endif |
| @@ -606,7 +716,7 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " | |||
| 606 | # define strdup rpl_strdup | 716 | # define strdup rpl_strdup |
| 607 | # endif | 717 | # endif |
| 608 | _GL_FUNCDECL_RPL (strdup, char *, | 718 | _GL_FUNCDECL_RPL (strdup, char *, |
| 609 | (char const *__s) | 719 | (char const *__s), |
| 610 | _GL_ARG_NONNULL ((1)) | 720 | _GL_ARG_NONNULL ((1)) |
| 611 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 721 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); |
| 612 | _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); | 722 | _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); |
| @@ -621,16 +731,17 @@ _GL_CXXALIAS_MDA (strdup, char *, (char const *__s)); | |||
| 621 | /* 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. */ |
| 622 | # undef strdup | 732 | # undef strdup |
| 623 | # endif | 733 | # endif |
| 624 | # if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup | 734 | # if (!@HAVE_DECL_STRDUP@ || (__GNUC__ >= 11 && !defined __clang__)) \ |
| 735 | && !defined strdup | ||
| 625 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 | 736 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 |
| 626 | _GL_FUNCDECL_SYS (strdup, char *, | 737 | _GL_FUNCDECL_SYS (strdup, char *, |
| 627 | (char const *__s) | 738 | (char const *__s), |
| 628 | _GL_ATTRIBUTE_NOTHROW | ||
| 629 | _GL_ARG_NONNULL ((1)) | 739 | _GL_ARG_NONNULL ((1)) |
| 630 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 740 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) |
| 741 | _GL_ATTRIBUTE_NOTHROW; | ||
| 631 | # else | 742 | # else |
| 632 | _GL_FUNCDECL_SYS (strdup, char *, | 743 | _GL_FUNCDECL_SYS (strdup, char *, |
| 633 | (char const *__s) | 744 | (char const *__s), |
| 634 | _GL_ARG_NONNULL ((1)) | 745 | _GL_ARG_NONNULL ((1)) |
| 635 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 746 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); |
| 636 | # endif | 747 | # endif |
| @@ -639,17 +750,17 @@ _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); | |||
| 639 | # endif | 750 | # endif |
| 640 | _GL_CXXALIASWARN (strdup); | 751 | _GL_CXXALIASWARN (strdup); |
| 641 | #else | 752 | #else |
| 642 | # if __GNUC__ >= 11 && !defined strdup | 753 | # if (__GNUC__ >= 11 && !defined __clang__) && !defined strdup |
| 643 | /* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */ | 754 | /* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */ |
| 644 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 | 755 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 |
| 645 | _GL_FUNCDECL_SYS (strdup, char *, | 756 | _GL_FUNCDECL_SYS (strdup, char *, |
| 646 | (char const *__s) | 757 | (char const *__s), |
| 647 | _GL_ATTRIBUTE_NOTHROW | ||
| 648 | _GL_ARG_NONNULL ((1)) | 758 | _GL_ARG_NONNULL ((1)) |
| 649 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 759 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) |
| 760 | _GL_ATTRIBUTE_NOTHROW; | ||
| 650 | # else | 761 | # else |
| 651 | _GL_FUNCDECL_SYS (strdup, char *, | 762 | _GL_FUNCDECL_SYS (strdup, char *, |
| 652 | (char const *__s) | 763 | (char const *__s), |
| 653 | _GL_ARG_NONNULL ((1)) | 764 | _GL_ARG_NONNULL ((1)) |
| 654 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 765 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); |
| 655 | # endif | 766 | # endif |
| @@ -688,8 +799,9 @@ _GL_CXXALIASWARN (strdup); | |||
| 688 | # define strncat rpl_strncat | 799 | # define strncat rpl_strncat |
| 689 | # endif | 800 | # endif |
| 690 | _GL_FUNCDECL_RPL (strncat, char *, | 801 | _GL_FUNCDECL_RPL (strncat, char *, |
| 691 | (char *restrict dest, const char *restrict src, size_t n) | 802 | (char *restrict dest, const char *restrict src, size_t n), |
| 692 | _GL_ARG_NONNULL ((1, 2))); | 803 | _GL_ARG_NONNULL ((1)) |
| 804 | _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3)); | ||
| 693 | _GL_CXXALIAS_RPL (strncat, char *, | 805 | _GL_CXXALIAS_RPL (strncat, char *, |
| 694 | (char *restrict dest, const char *restrict src, size_t n)); | 806 | (char *restrict dest, const char *restrict src, size_t n)); |
| 695 | # else | 807 | # else |
| @@ -707,6 +819,35 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - " | |||
| 707 | # endif | 819 | # endif |
| 708 | #endif | 820 | #endif |
| 709 | 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 | |||
| 710 | /* 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. */ |
| 711 | #if @GNULIB_STRNDUP@ | 852 | #if @GNULIB_STRNDUP@ |
| 712 | # if @REPLACE_STRNDUP@ | 853 | # if @REPLACE_STRNDUP@ |
| @@ -715,22 +856,23 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - " | |||
| 715 | # define strndup rpl_strndup | 856 | # define strndup rpl_strndup |
| 716 | # endif | 857 | # endif |
| 717 | _GL_FUNCDECL_RPL (strndup, char *, | 858 | _GL_FUNCDECL_RPL (strndup, char *, |
| 718 | (char const *__s, size_t __n) | 859 | (char const *__s, size_t __n), |
| 719 | _GL_ARG_NONNULL ((1)) | 860 | _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) |
| 720 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 861 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); |
| 721 | _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); | 862 | _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); |
| 722 | # else | 863 | # else |
| 723 | # if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup) | 864 | # if !@HAVE_DECL_STRNDUP@ \ |
| 865 | || ((__GNUC__ >= 11 && !defined __clang__) && !defined strndup) | ||
| 724 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 | 866 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 |
| 725 | _GL_FUNCDECL_SYS (strndup, char *, | 867 | _GL_FUNCDECL_SYS (strndup, char *, |
| 726 | (char const *__s, size_t __n) | 868 | (char const *__s, size_t __n), |
| 727 | _GL_ATTRIBUTE_NOTHROW | 869 | _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) |
| 728 | _GL_ARG_NONNULL ((1)) | 870 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) |
| 729 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 871 | _GL_ATTRIBUTE_NOTHROW; |
| 730 | # else | 872 | # else |
| 731 | _GL_FUNCDECL_SYS (strndup, char *, | 873 | _GL_FUNCDECL_SYS (strndup, char *, |
| 732 | (char const *__s, size_t __n) | 874 | (char const *__s, size_t __n), |
| 733 | _GL_ARG_NONNULL ((1)) | 875 | _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) |
| 734 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 876 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); |
| 735 | # endif | 877 | # endif |
| 736 | # endif | 878 | # endif |
| @@ -738,18 +880,18 @@ _GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n)); | |||
| 738 | # endif | 880 | # endif |
| 739 | _GL_CXXALIASWARN (strndup); | 881 | _GL_CXXALIASWARN (strndup); |
| 740 | #else | 882 | #else |
| 741 | # if __GNUC__ >= 11 && !defined strndup | 883 | # if (__GNUC__ >= 11 && !defined __clang__) && !defined strndup |
| 742 | /* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */ | 884 | /* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */ |
| 743 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 | 885 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 |
| 744 | _GL_FUNCDECL_SYS (strndup, char *, | 886 | _GL_FUNCDECL_SYS (strndup, char *, |
| 745 | (char const *__s, size_t __n) | 887 | (char const *__s, size_t __n), |
| 746 | _GL_ATTRIBUTE_NOTHROW | 888 | _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) |
| 747 | _GL_ARG_NONNULL ((1)) | 889 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) |
| 748 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 890 | _GL_ATTRIBUTE_NOTHROW; |
| 749 | # else | 891 | # else |
| 750 | _GL_FUNCDECL_SYS (strndup, char *, | 892 | _GL_FUNCDECL_SYS (strndup, char *, |
| 751 | (char const *__s, size_t __n) | 893 | (char const *__s, size_t __n), |
| 752 | _GL_ARG_NONNULL ((1)) | 894 | _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) |
| 753 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 895 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); |
| 754 | # endif | 896 | # endif |
| 755 | # endif | 897 | # endif |
| @@ -771,13 +913,13 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - " | |||
| 771 | # undef strnlen | 913 | # undef strnlen |
| 772 | # define strnlen rpl_strnlen | 914 | # define strnlen rpl_strnlen |
| 773 | # endif | 915 | # endif |
| 774 | _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), |
| 775 | _GL_ATTRIBUTE_PURE | 917 | _GL_ATTRIBUTE_PURE |
| 776 | _GL_ARG_NONNULL ((1))); | 918 | _GL_ARG_NONNULL ((1))); |
| 777 | _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)); |
| 778 | # else | 920 | # else |
| 779 | # if ! @HAVE_DECL_STRNLEN@ | 921 | # if ! @HAVE_DECL_STRNLEN@ |
| 780 | _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), |
| 781 | _GL_ATTRIBUTE_PURE | 923 | _GL_ATTRIBUTE_PURE |
| 782 | _GL_ARG_NONNULL ((1))); | 924 | _GL_ARG_NONNULL ((1))); |
| 783 | # endif | 925 | # endif |
| @@ -807,7 +949,7 @@ _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " | |||
| 807 | /* Find the first occurrence in S of any character in ACCEPT. */ | 949 | /* Find the first occurrence in S of any character in ACCEPT. */ |
| 808 | #if @GNULIB_STRPBRK@ | 950 | #if @GNULIB_STRPBRK@ |
| 809 | # if ! @HAVE_STRPBRK@ | 951 | # if ! @HAVE_STRPBRK@ |
| 810 | _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) | 952 | _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept), |
| 811 | _GL_ATTRIBUTE_PURE | 953 | _GL_ATTRIBUTE_PURE |
| 812 | _GL_ARG_NONNULL ((1, 2))); | 954 | _GL_ARG_NONNULL ((1, 2))); |
| 813 | # endif | 955 | # endif |
| @@ -892,7 +1034,7 @@ _GL_WARN_ON_USE_CXX (strrchr, | |||
| 892 | #if @GNULIB_STRSEP@ | 1034 | #if @GNULIB_STRSEP@ |
| 893 | # if ! @HAVE_STRSEP@ | 1035 | # if ! @HAVE_STRSEP@ |
| 894 | _GL_FUNCDECL_SYS (strsep, char *, | 1036 | _GL_FUNCDECL_SYS (strsep, char *, |
| 895 | (char **restrict __stringp, char const *restrict __delim) | 1037 | (char **restrict __stringp, char const *restrict __delim), |
| 896 | _GL_ARG_NONNULL ((1, 2))); | 1038 | _GL_ARG_NONNULL ((1, 2))); |
| 897 | # endif | 1039 | # endif |
| 898 | _GL_CXXALIAS_SYS (strsep, char *, | 1040 | _GL_CXXALIAS_SYS (strsep, char *, |
| @@ -917,7 +1059,7 @@ _GL_WARN_ON_USE (strsep, "strsep is unportable - " | |||
| 917 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1059 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 918 | # define strstr rpl_strstr | 1060 | # define strstr rpl_strstr |
| 919 | # endif | 1061 | # endif |
| 920 | _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) | 1062 | _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle), |
| 921 | _GL_ATTRIBUTE_PURE | 1063 | _GL_ATTRIBUTE_PURE |
| 922 | _GL_ARG_NONNULL ((1, 2))); | 1064 | _GL_ARG_NONNULL ((1, 2))); |
| 923 | _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); | 1065 | _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); |
| @@ -948,11 +1090,13 @@ _GL_CXXALIASWARN (strstr); | |||
| 948 | as a sequence of bytes, not of characters. */ | 1090 | as a sequence of bytes, not of characters. */ |
| 949 | # undef strstr | 1091 | # undef strstr |
| 950 | /* Assume strstr is always declared. */ | 1092 | /* Assume strstr is always declared. */ |
| 951 | _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " | 1093 | _GL_WARN_ON_USE_CXX (strstr, |
| 952 | "work correctly on character strings in most " | 1094 | const char *, char *, (const char *, const char *), |
| 953 | "multibyte locales - " | 1095 | "strstr is quadratic on many systems, and cannot " |
| 954 | "use mbsstr if you care about internationalization, " | 1096 | "work correctly on character strings in most " |
| 955 | "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"); | ||
| 956 | #endif | 1100 | #endif |
| 957 | 1101 | ||
| 958 | /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive | 1102 | /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive |
| @@ -963,7 +1107,7 @@ _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " | |||
| 963 | # define strcasestr rpl_strcasestr | 1107 | # define strcasestr rpl_strcasestr |
| 964 | # endif | 1108 | # endif |
| 965 | _GL_FUNCDECL_RPL (strcasestr, char *, | 1109 | _GL_FUNCDECL_RPL (strcasestr, char *, |
| 966 | (const char *haystack, const char *needle) | 1110 | (const char *haystack, const char *needle), |
| 967 | _GL_ATTRIBUTE_PURE | 1111 | _GL_ATTRIBUTE_PURE |
| 968 | _GL_ARG_NONNULL ((1, 2))); | 1112 | _GL_ARG_NONNULL ((1, 2))); |
| 969 | _GL_CXXALIAS_RPL (strcasestr, char *, | 1113 | _GL_CXXALIAS_RPL (strcasestr, char *, |
| @@ -971,7 +1115,7 @@ _GL_CXXALIAS_RPL (strcasestr, char *, | |||
| 971 | # else | 1115 | # else |
| 972 | # if ! @HAVE_STRCASESTR@ | 1116 | # if ! @HAVE_STRCASESTR@ |
| 973 | _GL_FUNCDECL_SYS (strcasestr, char *, | 1117 | _GL_FUNCDECL_SYS (strcasestr, char *, |
| 974 | (const char *haystack, const char *needle) | 1118 | (const char *haystack, const char *needle), |
| 975 | _GL_ATTRIBUTE_PURE | 1119 | _GL_ATTRIBUTE_PURE |
| 976 | _GL_ARG_NONNULL ((1, 2))); | 1120 | _GL_ARG_NONNULL ((1, 2))); |
| 977 | # endif | 1121 | # endif |
| @@ -1038,7 +1182,7 @@ _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " | |||
| 1038 | # endif | 1182 | # endif |
| 1039 | _GL_FUNCDECL_RPL (strtok_r, char *, | 1183 | _GL_FUNCDECL_RPL (strtok_r, char *, |
| 1040 | (char *restrict s, char const *restrict delim, | 1184 | (char *restrict s, char const *restrict delim, |
| 1041 | char **restrict save_ptr) | 1185 | char **restrict save_ptr), |
| 1042 | _GL_ARG_NONNULL ((2, 3))); | 1186 | _GL_ARG_NONNULL ((2, 3))); |
| 1043 | _GL_CXXALIAS_RPL (strtok_r, char *, | 1187 | _GL_CXXALIAS_RPL (strtok_r, char *, |
| 1044 | (char *restrict s, char const *restrict delim, | 1188 | (char *restrict s, char const *restrict delim, |
| @@ -1050,7 +1194,7 @@ _GL_CXXALIAS_RPL (strtok_r, char *, | |||
| 1050 | # if ! @HAVE_DECL_STRTOK_R@ | 1194 | # if ! @HAVE_DECL_STRTOK_R@ |
| 1051 | _GL_FUNCDECL_SYS (strtok_r, char *, | 1195 | _GL_FUNCDECL_SYS (strtok_r, char *, |
| 1052 | (char *restrict s, char const *restrict delim, | 1196 | (char *restrict s, char const *restrict delim, |
| 1053 | char **restrict save_ptr) | 1197 | char **restrict save_ptr), |
| 1054 | _GL_ARG_NONNULL ((2, 3))); | 1198 | _GL_ARG_NONNULL ((2, 3))); |
| 1055 | # endif | 1199 | # endif |
| 1056 | _GL_CXXALIAS_SYS (strtok_r, char *, | 1200 | _GL_CXXALIAS_SYS (strtok_r, char *, |
| @@ -1075,6 +1219,22 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " | |||
| 1075 | /* The following functions are not specified by POSIX. They are gnulib | 1219 | /* The following functions are not specified by POSIX. They are gnulib |
| 1076 | extensions. */ | 1220 | extensions. */ |
| 1077 | 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 | |||
| 1078 | #if @GNULIB_MBSLEN@ | 1238 | #if @GNULIB_MBSLEN@ |
| 1079 | /* Return the number of multibyte characters in the character string STRING. | 1239 | /* Return the number of multibyte characters in the character string STRING. |
| 1080 | This considers multibyte characters, unlike strlen, which counts bytes. */ | 1240 | This considers multibyte characters, unlike strlen, which counts bytes. */ |
| @@ -1085,12 +1245,12 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " | |||
| 1085 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1245 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1086 | # define mbslen rpl_mbslen | 1246 | # define mbslen rpl_mbslen |
| 1087 | # endif | 1247 | # endif |
| 1088 | _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) | 1248 | _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string), |
| 1089 | _GL_ATTRIBUTE_PURE | 1249 | _GL_ATTRIBUTE_PURE |
| 1090 | _GL_ARG_NONNULL ((1))); | 1250 | _GL_ARG_NONNULL ((1))); |
| 1091 | _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); | 1251 | _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); |
| 1092 | # else | 1252 | # else |
| 1093 | _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) | 1253 | _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string), |
| 1094 | _GL_ATTRIBUTE_PURE | 1254 | _GL_ATTRIBUTE_PURE |
| 1095 | _GL_ARG_NONNULL ((1))); | 1255 | _GL_ARG_NONNULL ((1))); |
| 1096 | _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); | 1256 | _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); |
| @@ -1117,12 +1277,12 @@ _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) | |||
| 1117 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1277 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1118 | # define mbschr rpl_mbschr /* avoid collision with HP-UX function */ | 1278 | # define mbschr rpl_mbschr /* avoid collision with HP-UX function */ |
| 1119 | # endif | 1279 | # endif |
| 1120 | _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) | 1280 | _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c), |
| 1121 | _GL_ATTRIBUTE_PURE | 1281 | _GL_ATTRIBUTE_PURE |
| 1122 | _GL_ARG_NONNULL ((1))); | 1282 | _GL_ARG_NONNULL ((1))); |
| 1123 | _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); | 1283 | _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); |
| 1124 | # else | 1284 | # else |
| 1125 | _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) | 1285 | _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c), |
| 1126 | _GL_ATTRIBUTE_PURE | 1286 | _GL_ATTRIBUTE_PURE |
| 1127 | _GL_ARG_NONNULL ((1))); | 1287 | _GL_ARG_NONNULL ((1))); |
| 1128 | _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); | 1288 | _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); |
| @@ -1139,12 +1299,12 @@ _GL_CXXALIASWARN (mbschr); | |||
| 1139 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1299 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1140 | # define mbsrchr rpl_mbsrchr /* avoid collision with system function */ | 1300 | # define mbsrchr rpl_mbsrchr /* avoid collision with system function */ |
| 1141 | # endif | 1301 | # endif |
| 1142 | _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) | 1302 | _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c), |
| 1143 | _GL_ATTRIBUTE_PURE | 1303 | _GL_ATTRIBUTE_PURE |
| 1144 | _GL_ARG_NONNULL ((1))); | 1304 | _GL_ARG_NONNULL ((1))); |
| 1145 | _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); | 1305 | _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); |
| 1146 | # else | 1306 | # else |
| 1147 | _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) | 1307 | _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c), |
| 1148 | _GL_ATTRIBUTE_PURE | 1308 | _GL_ATTRIBUTE_PURE |
| 1149 | _GL_ARG_NONNULL ((1))); | 1309 | _GL_ARG_NONNULL ((1))); |
| 1150 | _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); | 1310 | _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); |
| @@ -1160,6 +1320,33 @@ _GL_CXXALIASWARN (mbsrchr); | |||
| 1160 | _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) | 1320 | _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) |
| 1161 | _GL_ATTRIBUTE_PURE | 1321 | _GL_ATTRIBUTE_PURE |
| 1162 | _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 | ||
| 1327 | extern "C++" { /* needed for AIX */ | ||
| 1328 | template <typename T> | ||
| 1329 | T * mbsstr_template (T* haystack, const char *needle); | ||
| 1330 | template <> | ||
| 1331 | inline char * mbsstr_template (char *haystack, const char *needle) | ||
| 1332 | { return mbsstr (haystack, needle); } | ||
| 1333 | template <> | ||
| 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 | ||
| 1163 | #endif | 1350 | #endif |
| 1164 | 1351 | ||
| 1165 | #if @GNULIB_MBSCASECMP@ | 1352 | #if @GNULIB_MBSCASECMP@ |
| @@ -1201,6 +1388,33 @@ _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) | |||
| 1201 | _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) | 1388 | _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) |
| 1202 | _GL_ATTRIBUTE_PURE | 1389 | _GL_ATTRIBUTE_PURE |
| 1203 | _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 | ||
| 1395 | extern "C++" { /* needed for AIX */ | ||
| 1396 | template <typename T> | ||
| 1397 | T * mbspcasecmp_template (T* string, const char *prefix); | ||
| 1398 | template <> | ||
| 1399 | inline char * mbspcasecmp_template (char *string, const char *prefix) | ||
| 1400 | { return mbspcasecmp (string, prefix); } | ||
| 1401 | template <> | ||
| 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 | ||
| 1204 | #endif | 1418 | #endif |
| 1205 | 1419 | ||
| 1206 | #if @GNULIB_MBSCASESTR@ | 1420 | #if @GNULIB_MBSCASESTR@ |
| @@ -1212,6 +1426,33 @@ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) | |||
| 1212 | _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) | 1426 | _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) |
| 1213 | _GL_ATTRIBUTE_PURE | 1427 | _GL_ATTRIBUTE_PURE |
| 1214 | _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 | ||
| 1433 | extern "C++" { /* needed for AIX */ | ||
| 1434 | template <typename T> | ||
| 1435 | T * mbscasestr_template (T* haystack, const char *needle); | ||
| 1436 | template <> | ||
| 1437 | inline char * mbscasestr_template (char *haystack, const char *needle) | ||
| 1438 | { return mbscasestr (haystack, needle); } | ||
| 1439 | template <> | ||
| 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 | ||
| 1215 | #endif | 1456 | #endif |
| 1216 | 1457 | ||
| 1217 | #if @GNULIB_MBSCSPN@ | 1458 | #if @GNULIB_MBSCSPN@ |
| @@ -1234,12 +1475,12 @@ _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) | |||
| 1234 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1475 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1235 | # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ | 1476 | # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ |
| 1236 | # endif | 1477 | # endif |
| 1237 | _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) | 1478 | _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept), |
| 1238 | _GL_ATTRIBUTE_PURE | 1479 | _GL_ATTRIBUTE_PURE |
| 1239 | _GL_ARG_NONNULL ((1, 2))); | 1480 | _GL_ARG_NONNULL ((1, 2))); |
| 1240 | _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); | 1481 | _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); |
| 1241 | # else | 1482 | # else |
| 1242 | _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) | 1483 | _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept), |
| 1243 | _GL_ATTRIBUTE_PURE | 1484 | _GL_ATTRIBUTE_PURE |
| 1244 | _GL_ARG_NONNULL ((1, 2))); | 1485 | _GL_ARG_NONNULL ((1, 2))); |
| 1245 | _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); | 1486 | _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); |
| @@ -1299,6 +1540,26 @@ _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim, | |||
| 1299 | _GL_ARG_NONNULL ((2, 3)); | 1540 | _GL_ARG_NONNULL ((2, 3)); |
| 1300 | #endif | 1541 | #endif |
| 1301 | 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 | |||
| 1302 | /* Map any int, typically from errno, into an error message. */ | 1563 | /* Map any int, typically from errno, into an error message. */ |
| 1303 | #if @GNULIB_STRERROR@ | 1564 | #if @GNULIB_STRERROR@ |
| 1304 | # if @REPLACE_STRERROR@ | 1565 | # if @REPLACE_STRERROR@ |
| @@ -1306,7 +1567,7 @@ _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim, | |||
| 1306 | # undef strerror | 1567 | # undef strerror |
| 1307 | # define strerror rpl_strerror | 1568 | # define strerror rpl_strerror |
| 1308 | # endif | 1569 | # endif |
| 1309 | _GL_FUNCDECL_RPL (strerror, char *, (int)); | 1570 | _GL_FUNCDECL_RPL (strerror, char *, (int), ); |
| 1310 | _GL_CXXALIAS_RPL (strerror, char *, (int)); | 1571 | _GL_CXXALIAS_RPL (strerror, char *, (int)); |
| 1311 | # else | 1572 | # else |
| 1312 | _GL_CXXALIAS_SYS (strerror, char *, (int)); | 1573 | _GL_CXXALIAS_SYS (strerror, char *, (int)); |
| @@ -1329,12 +1590,12 @@ _GL_WARN_ON_USE (strerror, "strerror is unportable - " | |||
| 1329 | # undef strerror_r | 1590 | # undef strerror_r |
| 1330 | # define strerror_r rpl_strerror_r | 1591 | # define strerror_r rpl_strerror_r |
| 1331 | # endif | 1592 | # endif |
| 1332 | _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), |
| 1333 | _GL_ARG_NONNULL ((2))); | 1594 | _GL_ARG_NONNULL ((2))); |
| 1334 | _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)); |
| 1335 | # else | 1596 | # else |
| 1336 | # if !@HAVE_DECL_STRERROR_R@ | 1597 | # if !@HAVE_DECL_STRERROR_R@ |
| 1337 | _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), |
| 1338 | _GL_ARG_NONNULL ((2))); | 1599 | _GL_ARG_NONNULL ((2))); |
| 1339 | # endif | 1600 | # endif |
| 1340 | _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)); |
| @@ -1350,6 +1611,44 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " | |||
| 1350 | # endif | 1611 | # endif |
| 1351 | #endif | 1612 | #endif |
| 1352 | 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 | |||
| 1353 | /* Return the name of the system error code ERRNUM. */ | 1652 | /* Return the name of the system error code ERRNUM. */ |
| 1354 | #if @GNULIB_STRERRORNAME_NP@ | 1653 | #if @GNULIB_STRERRORNAME_NP@ |
| 1355 | # if @REPLACE_STRERRORNAME_NP@ | 1654 | # if @REPLACE_STRERRORNAME_NP@ |
| @@ -1357,15 +1656,17 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " | |||
| 1357 | # undef strerrorname_np | 1656 | # undef strerrorname_np |
| 1358 | # define strerrorname_np rpl_strerrorname_np | 1657 | # define strerrorname_np rpl_strerrorname_np |
| 1359 | # endif | 1658 | # endif |
| 1360 | _GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum)); | 1659 | _GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum), ); |
| 1361 | _GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum)); | 1660 | _GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum)); |
| 1362 | # else | 1661 | # else |
| 1363 | # if !@HAVE_STRERRORNAME_NP@ | 1662 | # if !@HAVE_STRERRORNAME_NP@ |
| 1364 | _GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum)); | 1663 | _GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum), ); |
| 1365 | # endif | 1664 | # endif |
| 1366 | _GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum)); | 1665 | _GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum)); |
| 1367 | # endif | 1666 | # endif |
| 1667 | # if __GLIBC__ >= 2 | ||
| 1368 | _GL_CXXALIASWARN (strerrorname_np); | 1668 | _GL_CXXALIASWARN (strerrorname_np); |
| 1669 | # endif | ||
| 1369 | #elif defined GNULIB_POSIXCHECK | 1670 | #elif defined GNULIB_POSIXCHECK |
| 1370 | # undef strerrorname_np | 1671 | # undef strerrorname_np |
| 1371 | # if HAVE_RAW_DECL_STRERRORNAME_NP | 1672 | # if HAVE_RAW_DECL_STRERRORNAME_NP |
| @@ -1377,7 +1678,7 @@ _GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - " | |||
| 1377 | /* Return an abbreviation string for the signal number SIG. */ | 1678 | /* Return an abbreviation string for the signal number SIG. */ |
| 1378 | #if @GNULIB_SIGABBREV_NP@ | 1679 | #if @GNULIB_SIGABBREV_NP@ |
| 1379 | # if ! @HAVE_SIGABBREV_NP@ | 1680 | # if ! @HAVE_SIGABBREV_NP@ |
| 1380 | _GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig)); | 1681 | _GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig), ); |
| 1381 | # endif | 1682 | # endif |
| 1382 | _GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig)); | 1683 | _GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig)); |
| 1383 | _GL_CXXALIASWARN (sigabbrev_np); | 1684 | _GL_CXXALIASWARN (sigabbrev_np); |
| @@ -1392,7 +1693,7 @@ _GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - " | |||
| 1392 | /* Return an English description string for the signal number SIG. */ | 1693 | /* Return an English description string for the signal number SIG. */ |
| 1393 | #if @GNULIB_SIGDESCR_NP@ | 1694 | #if @GNULIB_SIGDESCR_NP@ |
| 1394 | # if ! @HAVE_SIGDESCR_NP@ | 1695 | # if ! @HAVE_SIGDESCR_NP@ |
| 1395 | _GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig)); | 1696 | _GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig), ); |
| 1396 | # endif | 1697 | # endif |
| 1397 | _GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig)); | 1698 | _GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig)); |
| 1398 | _GL_CXXALIASWARN (sigdescr_np); | 1699 | _GL_CXXALIASWARN (sigdescr_np); |
| @@ -1409,11 +1710,11 @@ _GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - " | |||
| 1409 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1710 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1410 | # define strsignal rpl_strsignal | 1711 | # define strsignal rpl_strsignal |
| 1411 | # endif | 1712 | # endif |
| 1412 | _GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); | 1713 | _GL_FUNCDECL_RPL (strsignal, char *, (int __sig), ); |
| 1413 | _GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); | 1714 | _GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); |
| 1414 | # else | 1715 | # else |
| 1415 | # if ! @HAVE_DECL_STRSIGNAL@ | 1716 | # if ! @HAVE_DECL_STRSIGNAL@ |
| 1416 | _GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); | 1717 | _GL_FUNCDECL_SYS (strsignal, char *, (int __sig), ); |
| 1417 | # endif | 1718 | # endif |
| 1418 | /* 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 |
| 1419 | 'const char *'. */ | 1720 | 'const char *'. */ |
| @@ -1433,13 +1734,13 @@ _GL_WARN_ON_USE (strsignal, "strsignal is unportable - " | |||
| 1433 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1734 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1434 | # define strverscmp rpl_strverscmp | 1735 | # define strverscmp rpl_strverscmp |
| 1435 | # endif | 1736 | # endif |
| 1436 | _GL_FUNCDECL_RPL (strverscmp, int, (const char *, const char *) | 1737 | _GL_FUNCDECL_RPL (strverscmp, int, (const char *, const char *), |
| 1437 | _GL_ATTRIBUTE_PURE | 1738 | _GL_ATTRIBUTE_PURE |
| 1438 | _GL_ARG_NONNULL ((1, 2))); | 1739 | _GL_ARG_NONNULL ((1, 2))); |
| 1439 | _GL_CXXALIAS_RPL (strverscmp, int, (const char *, const char *)); | 1740 | _GL_CXXALIAS_RPL (strverscmp, int, (const char *, const char *)); |
| 1440 | # else | 1741 | # else |
| 1441 | # if !@HAVE_STRVERSCMP@ | 1742 | # if !@HAVE_STRVERSCMP@ |
| 1442 | _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) | 1743 | _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *), |
| 1443 | _GL_ATTRIBUTE_PURE | 1744 | _GL_ATTRIBUTE_PURE |
| 1444 | _GL_ARG_NONNULL ((1, 2))); | 1745 | _GL_ARG_NONNULL ((1, 2))); |
| 1445 | # endif | 1746 | # endif |
