diff options
Diffstat (limited to 'gl/string.in.h')
-rw-r--r-- | gl/string.in.h | 333 |
1 files changed, 273 insertions, 60 deletions
diff --git a/gl/string.in.h b/gl/string.in.h index d7a6c9c9..afe73508 100644 --- a/gl/string.in.h +++ b/gl/string.in.h | |||
@@ -1,30 +1,46 @@ | |||
1 | /* A GNU-like <string.h>. | 1 | /* A GNU-like <string.h>. |
2 | 2 | ||
3 | Copyright (C) 1995-1996, 2001-2013 Free Software Foundation, Inc. | 3 | Copyright (C) 1995-1996, 2001-2021 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This file is free software: you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU Lesser General Public License as |
7 | the Free Software Foundation; either version 3, or (at your option) | 7 | published by the Free Software Foundation; either version 2.1 of the |
8 | any later version. | 8 | License, or (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This file is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU Lesser General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Lesser General Public License |
16 | along with this program; if not, see <http://www.gnu.org/licenses/>. */ | 16 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
17 | |||
18 | #ifndef _@GUARD_PREFIX@_STRING_H | ||
19 | 17 | ||
20 | #if __GNUC__ >= 3 | 18 | #if __GNUC__ >= 3 |
21 | @PRAGMA_SYSTEM_HEADER@ | 19 | @PRAGMA_SYSTEM_HEADER@ |
22 | #endif | 20 | #endif |
23 | @PRAGMA_COLUMNS@ | 21 | @PRAGMA_COLUMNS@ |
24 | 22 | ||
23 | #if defined _GL_ALREADY_INCLUDING_STRING_H | ||
24 | /* Special invocation convention: | ||
25 | - On OS X/NetBSD we have a sequence of nested includes | ||
26 | <string.h> -> <strings.h> -> "string.h" | ||
27 | In this situation system _chk variants due to -D_FORTIFY_SOURCE | ||
28 | might be used after any replacements defined here. */ | ||
29 | |||
30 | #@INCLUDE_NEXT@ @NEXT_STRING_H@ | ||
31 | |||
32 | #else | ||
33 | /* Normal invocation convention. */ | ||
34 | |||
35 | #ifndef _@GUARD_PREFIX@_STRING_H | ||
36 | |||
37 | #define _GL_ALREADY_INCLUDING_STRING_H | ||
38 | |||
25 | /* The include_next requires a split double-inclusion guard. */ | 39 | /* The include_next requires a split double-inclusion guard. */ |
26 | #@INCLUDE_NEXT@ @NEXT_STRING_H@ | 40 | #@INCLUDE_NEXT@ @NEXT_STRING_H@ |
27 | 41 | ||
42 | #undef _GL_ALREADY_INCLUDING_STRING_H | ||
43 | |||
28 | #ifndef _@GUARD_PREFIX@_STRING_H | 44 | #ifndef _@GUARD_PREFIX@_STRING_H |
29 | #define _@GUARD_PREFIX@_STRING_H | 45 | #define _@GUARD_PREFIX@_STRING_H |
30 | 46 | ||
@@ -36,14 +52,6 @@ | |||
36 | # include <wchar.h> | 52 | # include <wchar.h> |
37 | #endif | 53 | #endif |
38 | 54 | ||
39 | /* The __attribute__ feature is available in gcc versions 2.5 and later. | ||
40 | The attribute __pure__ was added in gcc 2.96. */ | ||
41 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) | ||
42 | # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) | ||
43 | #else | ||
44 | # define _GL_ATTRIBUTE_PURE /* empty */ | ||
45 | #endif | ||
46 | |||
47 | /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ | 55 | /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ |
48 | /* But in any case avoid namespace pollution on glibc systems. */ | 56 | /* But in any case avoid namespace pollution on glibc systems. */ |
49 | #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ | 57 | #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ |
@@ -51,12 +59,85 @@ | |||
51 | # include <unistd.h> | 59 | # include <unistd.h> |
52 | #endif | 60 | #endif |
53 | 61 | ||
62 | /* AIX 7.2 declares ffsl and ffsll in <strings.h>, not in <string.h>. */ | ||
63 | /* But in any case avoid namespace pollution on glibc systems. */ | ||
64 | #if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \ | ||
65 | && defined _AIX) \ | ||
66 | && ! defined __GLIBC__ | ||
67 | # include <strings.h> | ||
68 | #endif | ||
69 | |||
70 | /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers | ||
71 | that can be freed by passing them as the Ith argument to the | ||
72 | function F. */ | ||
73 | #ifndef _GL_ATTRIBUTE_DEALLOC | ||
74 | # if __GNUC__ >= 11 | ||
75 | # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) | ||
76 | # else | ||
77 | # define _GL_ATTRIBUTE_DEALLOC(f, i) | ||
78 | # endif | ||
79 | #endif | ||
80 | |||
81 | /* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that | ||
82 | can be freed via 'free'; it can be used only after declaring 'free'. */ | ||
83 | /* Applies to: functions. Cannot be used on inline functions. */ | ||
84 | #ifndef _GL_ATTRIBUTE_DEALLOC_FREE | ||
85 | # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) | ||
86 | #endif | ||
87 | |||
88 | /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly | ||
89 | allocated memory. */ | ||
90 | /* Applies to: functions. */ | ||
91 | #ifndef _GL_ATTRIBUTE_MALLOC | ||
92 | # if __GNUC__ >= 3 || defined __clang__ | ||
93 | # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) | ||
94 | # else | ||
95 | # define _GL_ATTRIBUTE_MALLOC | ||
96 | # endif | ||
97 | #endif | ||
98 | |||
99 | /* The __attribute__ feature is available in gcc versions 2.5 and later. | ||
100 | The attribute __pure__ was added in gcc 2.96. */ | ||
101 | #ifndef _GL_ATTRIBUTE_PURE | ||
102 | # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ | ||
103 | # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) | ||
104 | # else | ||
105 | # define _GL_ATTRIBUTE_PURE /* empty */ | ||
106 | # endif | ||
107 | #endif | ||
108 | |||
54 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | 109 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
55 | 110 | ||
56 | /* The definition of _GL_ARG_NONNULL is copied here. */ | 111 | /* The definition of _GL_ARG_NONNULL is copied here. */ |
57 | 112 | ||
58 | /* The definition of _GL_WARN_ON_USE is copied here. */ | 113 | /* The definition of _GL_WARN_ON_USE is copied here. */ |
59 | 114 | ||
115 | /* Declare 'free' if needed for _GL_ATTRIBUTE_DEALLOC_FREE. */ | ||
116 | _GL_EXTERN_C void free (void *); | ||
117 | #if @GNULIB_FREE_POSIX@ | ||
118 | # if (@REPLACE_FREE@ && !defined free \ | ||
119 | && !(defined __cplusplus && defined GNULIB_NAMESPACE)) | ||
120 | # define free rpl_free | ||
121 | _GL_EXTERN_C void free (void *); | ||
122 | # endif | ||
123 | #endif | ||
124 | |||
125 | /* Clear a block of memory. The compiler will not delete a call to | ||
126 | this function, even if the block is dead after the call. */ | ||
127 | #if @GNULIB_EXPLICIT_BZERO@ | ||
128 | # if ! @HAVE_EXPLICIT_BZERO@ | ||
129 | _GL_FUNCDECL_SYS (explicit_bzero, void, | ||
130 | (void *__dest, size_t __n) _GL_ARG_NONNULL ((1))); | ||
131 | # endif | ||
132 | _GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n)); | ||
133 | _GL_CXXALIASWARN (explicit_bzero); | ||
134 | #elif defined GNULIB_POSIXCHECK | ||
135 | # undef explicit_bzero | ||
136 | # if HAVE_RAW_DECL_EXPLICIT_BZERO | ||
137 | _GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - " | ||
138 | "use gnulib module explicit_bzero for portability"); | ||
139 | # endif | ||
140 | #endif | ||
60 | 141 | ||
61 | /* Find the index of the least-significant set bit. */ | 142 | /* Find the index of the least-significant set bit. */ |
62 | #if @GNULIB_FFSL@ | 143 | #if @GNULIB_FFSL@ |
@@ -75,10 +156,18 @@ _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module"); | |||
75 | 156 | ||
76 | /* Find the index of the least-significant set bit. */ | 157 | /* Find the index of the least-significant set bit. */ |
77 | #if @GNULIB_FFSLL@ | 158 | #if @GNULIB_FFSLL@ |
78 | # if !@HAVE_FFSLL@ | 159 | # if @REPLACE_FFSLL@ |
160 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
161 | # define ffsll rpl_ffsll | ||
162 | # endif | ||
163 | _GL_FUNCDECL_RPL (ffsll, int, (long long int i)); | ||
164 | _GL_CXXALIAS_RPL (ffsll, int, (long long int i)); | ||
165 | # else | ||
166 | # if !@HAVE_FFSLL@ | ||
79 | _GL_FUNCDECL_SYS (ffsll, int, (long long int i)); | 167 | _GL_FUNCDECL_SYS (ffsll, int, (long long int i)); |
80 | # endif | 168 | # endif |
81 | _GL_CXXALIAS_SYS (ffsll, int, (long long int i)); | 169 | _GL_CXXALIAS_SYS (ffsll, int, (long long int i)); |
170 | # endif | ||
82 | _GL_CXXALIASWARN (ffsll); | 171 | _GL_CXXALIASWARN (ffsll); |
83 | #elif defined GNULIB_POSIXCHECK | 172 | #elif defined GNULIB_POSIXCHECK |
84 | # undef ffsll | 173 | # undef ffsll |
@@ -88,10 +177,30 @@ _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module"); | |||
88 | #endif | 177 | #endif |
89 | 178 | ||
90 | 179 | ||
180 | #if @GNULIB_MDA_MEMCCPY@ | ||
181 | /* On native Windows, map 'memccpy' to '_memccpy', so that -loldnames is not | ||
182 | required. In C++ with GNULIB_NAMESPACE, avoid differences between | ||
183 | platforms by defining GNULIB_NAMESPACE::memccpy always. */ | ||
184 | # if defined _WIN32 && !defined __CYGWIN__ | ||
185 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
186 | # undef memccpy | ||
187 | # define memccpy _memccpy | ||
188 | # endif | ||
189 | _GL_CXXALIAS_MDA (memccpy, void *, | ||
190 | (void *dest, const void *src, int c, size_t n)); | ||
191 | # else | ||
192 | _GL_CXXALIAS_SYS (memccpy, void *, | ||
193 | (void *dest, const void *src, int c, size_t n)); | ||
194 | # endif | ||
195 | _GL_CXXALIASWARN (memccpy); | ||
196 | #endif | ||
197 | |||
198 | |||
91 | /* Return the first instance of C within N bytes of S, or NULL. */ | 199 | /* Return the first instance of C within N bytes of S, or NULL. */ |
92 | #if @GNULIB_MEMCHR@ | 200 | #if @GNULIB_MEMCHR@ |
93 | # if @REPLACE_MEMCHR@ | 201 | # if @REPLACE_MEMCHR@ |
94 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 202 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
203 | # undef memchr | ||
95 | # define memchr rpl_memchr | 204 | # define memchr rpl_memchr |
96 | # endif | 205 | # endif |
97 | _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) | 206 | _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) |
@@ -99,11 +208,6 @@ _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) | |||
99 | _GL_ARG_NONNULL ((1))); | 208 | _GL_ARG_NONNULL ((1))); |
100 | _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); | 209 | _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); |
101 | # else | 210 | # else |
102 | # if ! @HAVE_MEMCHR@ | ||
103 | _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) | ||
104 | _GL_ATTRIBUTE_PURE | ||
105 | _GL_ARG_NONNULL ((1))); | ||
106 | # endif | ||
107 | /* On some systems, this function is defined as an overloaded function: | 211 | /* On some systems, this function is defined as an overloaded function: |
108 | extern "C" { const void * std::memchr (const void *, int, size_t); } | 212 | extern "C" { const void * std::memchr (const void *, int, size_t); } |
109 | extern "C++" { void * std::memchr (void *, int, size_t); } */ | 213 | extern "C++" { void * std::memchr (void *, int, size_t); } */ |
@@ -116,7 +220,7 @@ _GL_CXXALIAS_SYS_CAST2 (memchr, | |||
116 | _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); | 220 | _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); |
117 | _GL_CXXALIASWARN1 (memchr, void const *, | 221 | _GL_CXXALIASWARN1 (memchr, void const *, |
118 | (void const *__s, int __c, size_t __n)); | 222 | (void const *__s, int __c, size_t __n)); |
119 | # else | 223 | # elif __GLIBC__ >= 2 |
120 | _GL_CXXALIASWARN (memchr); | 224 | _GL_CXXALIASWARN (memchr); |
121 | # endif | 225 | # endif |
122 | #elif defined GNULIB_POSIXCHECK | 226 | #elif defined GNULIB_POSIXCHECK |
@@ -299,9 +403,11 @@ _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " | |||
299 | GB18030 and the character to be searched is a digit. */ | 403 | GB18030 and the character to be searched is a digit. */ |
300 | # undef strchr | 404 | # undef strchr |
301 | /* Assume strchr is always declared. */ | 405 | /* Assume strchr is always declared. */ |
302 | _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " | 406 | _GL_WARN_ON_USE_CXX (strchr, |
303 | "in some multibyte locales - " | 407 | const char *, char *, (const char *, int), |
304 | "use mbschr if you care about internationalization"); | 408 | "strchr cannot work correctly on character strings " |
409 | "in some multibyte locales - " | ||
410 | "use mbschr if you care about internationalization"); | ||
305 | #endif | 411 | #endif |
306 | 412 | ||
307 | /* Find the first occurrence of C in S or the final NUL byte. */ | 413 | /* Find the first occurrence of C in S or the final NUL byte. */ |
@@ -350,24 +456,62 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " | |||
350 | # undef strdup | 456 | # undef strdup |
351 | # define strdup rpl_strdup | 457 | # define strdup rpl_strdup |
352 | # endif | 458 | # endif |
353 | _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); | 459 | _GL_FUNCDECL_RPL (strdup, char *, |
460 | (char const *__s) | ||
461 | _GL_ARG_NONNULL ((1)) | ||
462 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | ||
354 | _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); | 463 | _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); |
464 | # elif defined _WIN32 && !defined __CYGWIN__ | ||
465 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
466 | # undef strdup | ||
467 | # define strdup _strdup | ||
468 | # endif | ||
469 | _GL_CXXALIAS_MDA (strdup, char *, (char const *__s)); | ||
355 | # else | 470 | # else |
356 | # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup | 471 | # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup |
357 | /* strdup exists as a function and as a macro. Get rid of the macro. */ | 472 | /* strdup exists as a function and as a macro. Get rid of the macro. */ |
358 | # undef strdup | 473 | # undef strdup |
359 | # endif | 474 | # endif |
360 | # if !(@HAVE_DECL_STRDUP@ || defined strdup) | 475 | # if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup |
361 | _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); | 476 | _GL_FUNCDECL_SYS (strdup, char *, |
477 | (char const *__s) | ||
478 | _GL_ARG_NONNULL ((1)) | ||
479 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | ||
362 | # endif | 480 | # endif |
363 | _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); | 481 | _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); |
364 | # endif | 482 | # endif |
365 | _GL_CXXALIASWARN (strdup); | 483 | _GL_CXXALIASWARN (strdup); |
366 | #elif defined GNULIB_POSIXCHECK | 484 | #else |
367 | # undef strdup | 485 | # if __GNUC__ >= 11 && !defined strdup |
368 | # if HAVE_RAW_DECL_STRDUP | 486 | /* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */ |
487 | _GL_FUNCDECL_SYS (strdup, char *, | ||
488 | (char const *__s) | ||
489 | _GL_ARG_NONNULL ((1)) | ||
490 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | ||
491 | # endif | ||
492 | # if defined GNULIB_POSIXCHECK | ||
493 | # undef strdup | ||
494 | # if HAVE_RAW_DECL_STRDUP | ||
369 | _GL_WARN_ON_USE (strdup, "strdup is unportable - " | 495 | _GL_WARN_ON_USE (strdup, "strdup is unportable - " |
370 | "use gnulib module strdup for portability"); | 496 | "use gnulib module strdup for portability"); |
497 | # endif | ||
498 | # elif @GNULIB_MDA_STRDUP@ | ||
499 | /* On native Windows, map 'creat' to '_creat', so that -loldnames is not | ||
500 | required. In C++ with GNULIB_NAMESPACE, avoid differences between | ||
501 | platforms by defining GNULIB_NAMESPACE::strdup always. */ | ||
502 | # if defined _WIN32 && !defined __CYGWIN__ | ||
503 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
504 | # undef strdup | ||
505 | # define strdup _strdup | ||
506 | # endif | ||
507 | _GL_CXXALIAS_MDA (strdup, char *, (char const *__s)); | ||
508 | # else | ||
509 | # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup | ||
510 | # undef strdup | ||
511 | # endif | ||
512 | _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); | ||
513 | # endif | ||
514 | _GL_CXXALIASWARN (strdup); | ||
371 | # endif | 515 | # endif |
372 | #endif | 516 | #endif |
373 | 517 | ||
@@ -378,13 +522,18 @@ _GL_WARN_ON_USE (strdup, "strdup is unportable - " | |||
378 | # undef strncat | 522 | # undef strncat |
379 | # define strncat rpl_strncat | 523 | # define strncat rpl_strncat |
380 | # endif | 524 | # endif |
381 | _GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) | 525 | _GL_FUNCDECL_RPL (strncat, char *, |
382 | _GL_ARG_NONNULL ((1, 2))); | 526 | (char *restrict dest, const char *restrict src, size_t n) |
383 | _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); | 527 | _GL_ARG_NONNULL ((1, 2))); |
528 | _GL_CXXALIAS_RPL (strncat, char *, | ||
529 | (char *restrict dest, const char *restrict src, size_t n)); | ||
384 | # else | 530 | # else |
385 | _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); | 531 | _GL_CXXALIAS_SYS (strncat, char *, |
532 | (char *restrict dest, const char *restrict src, size_t n)); | ||
386 | # endif | 533 | # endif |
534 | # if __GLIBC__ >= 2 | ||
387 | _GL_CXXALIASWARN (strncat); | 535 | _GL_CXXALIASWARN (strncat); |
536 | # endif | ||
388 | #elif defined GNULIB_POSIXCHECK | 537 | #elif defined GNULIB_POSIXCHECK |
389 | # undef strncat | 538 | # undef strncat |
390 | # if HAVE_RAW_DECL_STRNCAT | 539 | # if HAVE_RAW_DECL_STRNCAT |
@@ -400,15 +549,15 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - " | |||
400 | # undef strndup | 549 | # undef strndup |
401 | # define strndup rpl_strndup | 550 | # define strndup rpl_strndup |
402 | # endif | 551 | # endif |
403 | _GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n) | 552 | _GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n) |
404 | _GL_ARG_NONNULL ((1))); | 553 | _GL_ARG_NONNULL ((1))); |
405 | _GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n)); | 554 | _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); |
406 | # else | 555 | # else |
407 | # if ! @HAVE_DECL_STRNDUP@ | 556 | # if ! @HAVE_DECL_STRNDUP@ |
408 | _GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n) | 557 | _GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n) |
409 | _GL_ARG_NONNULL ((1))); | 558 | _GL_ARG_NONNULL ((1))); |
410 | # endif | 559 | # endif |
411 | _GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n)); | 560 | _GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n)); |
412 | # endif | 561 | # endif |
413 | _GL_CXXALIASWARN (strndup); | 562 | _GL_CXXALIASWARN (strndup); |
414 | #elif defined GNULIB_POSIXCHECK | 563 | #elif defined GNULIB_POSIXCHECK |
@@ -428,17 +577,17 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - " | |||
428 | # undef strnlen | 577 | # undef strnlen |
429 | # define strnlen rpl_strnlen | 578 | # define strnlen rpl_strnlen |
430 | # endif | 579 | # endif |
431 | _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) | 580 | _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen) |
432 | _GL_ATTRIBUTE_PURE | 581 | _GL_ATTRIBUTE_PURE |
433 | _GL_ARG_NONNULL ((1))); | 582 | _GL_ARG_NONNULL ((1))); |
434 | _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); | 583 | _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)); |
435 | # else | 584 | # else |
436 | # if ! @HAVE_DECL_STRNLEN@ | 585 | # if ! @HAVE_DECL_STRNLEN@ |
437 | _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) | 586 | _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen) |
438 | _GL_ATTRIBUTE_PURE | 587 | _GL_ATTRIBUTE_PURE |
439 | _GL_ARG_NONNULL ((1))); | 588 | _GL_ARG_NONNULL ((1))); |
440 | # endif | 589 | # endif |
441 | _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); | 590 | _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)); |
442 | # endif | 591 | # endif |
443 | _GL_CXXALIASWARN (strnlen); | 592 | _GL_CXXALIASWARN (strnlen); |
444 | #elif defined GNULIB_POSIXCHECK | 593 | #elif defined GNULIB_POSIXCHECK |
@@ -479,7 +628,7 @@ _GL_CXXALIAS_SYS_CAST2 (strpbrk, | |||
479 | _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); | 628 | _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); |
480 | _GL_CXXALIASWARN1 (strpbrk, char const *, | 629 | _GL_CXXALIASWARN1 (strpbrk, char const *, |
481 | (char const *__s, char const *__accept)); | 630 | (char const *__s, char const *__accept)); |
482 | # else | 631 | # elif __GLIBC__ >= 2 |
483 | _GL_CXXALIASWARN (strpbrk); | 632 | _GL_CXXALIASWARN (strpbrk); |
484 | # endif | 633 | # endif |
485 | # if defined GNULIB_POSIXCHECK | 634 | # if defined GNULIB_POSIXCHECK |
@@ -488,15 +637,19 @@ _GL_CXXALIASWARN (strpbrk); | |||
488 | locale encoding is GB18030 and one of the characters to be searched is a | 637 | locale encoding is GB18030 and one of the characters to be searched is a |
489 | digit. */ | 638 | digit. */ |
490 | # undef strpbrk | 639 | # undef strpbrk |
491 | _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " | 640 | _GL_WARN_ON_USE_CXX (strpbrk, |
492 | "in multibyte locales - " | 641 | const char *, char *, (const char *, const char *), |
493 | "use mbspbrk if you care about internationalization"); | 642 | "strpbrk cannot work correctly on character strings " |
643 | "in multibyte locales - " | ||
644 | "use mbspbrk if you care about internationalization"); | ||
494 | # endif | 645 | # endif |
495 | #elif defined GNULIB_POSIXCHECK | 646 | #elif defined GNULIB_POSIXCHECK |
496 | # undef strpbrk | 647 | # undef strpbrk |
497 | # if HAVE_RAW_DECL_STRPBRK | 648 | # if HAVE_RAW_DECL_STRPBRK |
498 | _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " | 649 | _GL_WARN_ON_USE_CXX (strpbrk, |
499 | "use gnulib module strpbrk for portability"); | 650 | const char *, char *, (const char *, const char *), |
651 | "strpbrk is unportable - " | ||
652 | "use gnulib module strpbrk for portability"); | ||
500 | # endif | 653 | # endif |
501 | #endif | 654 | #endif |
502 | 655 | ||
@@ -515,9 +668,11 @@ _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " | |||
515 | GB18030 and the character to be searched is a digit. */ | 668 | GB18030 and the character to be searched is a digit. */ |
516 | # undef strrchr | 669 | # undef strrchr |
517 | /* Assume strrchr is always declared. */ | 670 | /* Assume strrchr is always declared. */ |
518 | _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " | 671 | _GL_WARN_ON_USE_CXX (strrchr, |
519 | "in some multibyte locales - " | 672 | const char *, char *, (const char *, int), |
520 | "use mbsrchr if you care about internationalization"); | 673 | "strrchr cannot work correctly on character strings " |
674 | "in some multibyte locales - " | ||
675 | "use mbsrchr if you care about internationalization"); | ||
521 | #endif | 676 | #endif |
522 | 677 | ||
523 | /* Search the next delimiter (char listed in DELIM) starting at *STRINGP. | 678 | /* Search the next delimiter (char listed in DELIM) starting at *STRINGP. |
@@ -581,7 +736,7 @@ _GL_CXXALIAS_SYS_CAST2 (strstr, | |||
581 | _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); | 736 | _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); |
582 | _GL_CXXALIASWARN1 (strstr, const char *, | 737 | _GL_CXXALIASWARN1 (strstr, const char *, |
583 | (const char *haystack, const char *needle)); | 738 | (const char *haystack, const char *needle)); |
584 | # else | 739 | # elif __GLIBC__ >= 2 |
585 | _GL_CXXALIASWARN (strstr); | 740 | _GL_CXXALIASWARN (strstr); |
586 | # endif | 741 | # endif |
587 | #elif defined GNULIB_POSIXCHECK | 742 | #elif defined GNULIB_POSIXCHECK |
@@ -660,7 +815,7 @@ _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " | |||
660 | This is a variant of strtok() that is multithread-safe. | 815 | This is a variant of strtok() that is multithread-safe. |
661 | 816 | ||
662 | For the POSIX documentation for this function, see: | 817 | For the POSIX documentation for this function, see: |
663 | http://www.opengroup.org/susv3xsh/strtok.html | 818 | https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html |
664 | 819 | ||
665 | Caveat: It modifies the original string. | 820 | Caveat: It modifies the original string. |
666 | Caveat: These functions cannot be used on constant strings. | 821 | Caveat: These functions cannot be used on constant strings. |
@@ -931,7 +1086,8 @@ _GL_EXTERN_C char * mbssep (char **stringp, const char *delim) | |||
931 | Caveat: The identity of the delimiting character is lost. | 1086 | Caveat: The identity of the delimiting character is lost. |
932 | 1087 | ||
933 | See also mbssep(). */ | 1088 | See also mbssep(). */ |
934 | _GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr) | 1089 | _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim, |
1090 | char **save_ptr) | ||
935 | _GL_ARG_NONNULL ((2, 3)); | 1091 | _GL_ARG_NONNULL ((2, 3)); |
936 | #endif | 1092 | #endif |
937 | 1093 | ||
@@ -947,7 +1103,9 @@ _GL_CXXALIAS_RPL (strerror, char *, (int)); | |||
947 | # else | 1103 | # else |
948 | _GL_CXXALIAS_SYS (strerror, char *, (int)); | 1104 | _GL_CXXALIAS_SYS (strerror, char *, (int)); |
949 | # endif | 1105 | # endif |
1106 | # if __GLIBC__ >= 2 | ||
950 | _GL_CXXALIASWARN (strerror); | 1107 | _GL_CXXALIASWARN (strerror); |
1108 | # endif | ||
951 | #elif defined GNULIB_POSIXCHECK | 1109 | #elif defined GNULIB_POSIXCHECK |
952 | # undef strerror | 1110 | # undef strerror |
953 | /* Assume strerror is always declared. */ | 1111 | /* Assume strerror is always declared. */ |
@@ -984,6 +1142,60 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " | |||
984 | # endif | 1142 | # endif |
985 | #endif | 1143 | #endif |
986 | 1144 | ||
1145 | /* Return the name of the system error code ERRNUM. */ | ||
1146 | #if @GNULIB_STRERRORNAME_NP@ | ||
1147 | # if @REPLACE_STRERRORNAME_NP@ | ||
1148 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
1149 | # undef strerrorname_np | ||
1150 | # define strerrorname_np rpl_strerrorname_np | ||
1151 | # endif | ||
1152 | _GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum)); | ||
1153 | _GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum)); | ||
1154 | # else | ||
1155 | # if !@HAVE_STRERRORNAME_NP@ | ||
1156 | _GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum)); | ||
1157 | # endif | ||
1158 | _GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum)); | ||
1159 | # endif | ||
1160 | _GL_CXXALIASWARN (strerrorname_np); | ||
1161 | #elif defined GNULIB_POSIXCHECK | ||
1162 | # undef strerrorname_np | ||
1163 | # if HAVE_RAW_DECL_STRERRORNAME_NP | ||
1164 | _GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - " | ||
1165 | "use gnulib module strerrorname_np for portability"); | ||
1166 | # endif | ||
1167 | #endif | ||
1168 | |||
1169 | /* Return an abbreviation string for the signal number SIG. */ | ||
1170 | #if @GNULIB_SIGABBREV_NP@ | ||
1171 | # if ! @HAVE_SIGABBREV_NP@ | ||
1172 | _GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig)); | ||
1173 | # endif | ||
1174 | _GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig)); | ||
1175 | _GL_CXXALIASWARN (sigabbrev_np); | ||
1176 | #elif defined GNULIB_POSIXCHECK | ||
1177 | # undef sigabbrev_np | ||
1178 | # if HAVE_RAW_DECL_SIGABBREV_NP | ||
1179 | _GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - " | ||
1180 | "use gnulib module sigabbrev_np for portability"); | ||
1181 | # endif | ||
1182 | #endif | ||
1183 | |||
1184 | /* Return an English description string for the signal number SIG. */ | ||
1185 | #if @GNULIB_SIGDESCR_NP@ | ||
1186 | # if ! @HAVE_SIGDESCR_NP@ | ||
1187 | _GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig)); | ||
1188 | # endif | ||
1189 | _GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig)); | ||
1190 | _GL_CXXALIASWARN (sigdescr_np); | ||
1191 | #elif defined GNULIB_POSIXCHECK | ||
1192 | # undef sigdescr_np | ||
1193 | # if HAVE_RAW_DECL_SIGDESCR_NP | ||
1194 | _GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - " | ||
1195 | "use gnulib module sigdescr_np for portability"); | ||
1196 | # endif | ||
1197 | #endif | ||
1198 | |||
987 | #if @GNULIB_STRSIGNAL@ | 1199 | #if @GNULIB_STRSIGNAL@ |
988 | # if @REPLACE_STRSIGNAL@ | 1200 | # if @REPLACE_STRSIGNAL@ |
989 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1201 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
@@ -1027,3 +1239,4 @@ _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " | |||
1027 | 1239 | ||
1028 | #endif /* _@GUARD_PREFIX@_STRING_H */ | 1240 | #endif /* _@GUARD_PREFIX@_STRING_H */ |
1029 | #endif /* _@GUARD_PREFIX@_STRING_H */ | 1241 | #endif /* _@GUARD_PREFIX@_STRING_H */ |
1242 | #endif | ||