OLD | NEW |
1 /* A GNU-like <string.h>. | 1 /* A GNU-like <string.h>. |
2 | 2 |
3 Copyright (C) 1995-1996, 2001-2011 Free Software Foundation, Inc. | 3 Copyright (C) 1995-1996, 2001-2012 Free Software Foundation, Inc. |
4 | 4 |
5 This program is free software; you can redistribute it and/or modify | 5 This program 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 General Public License as published by |
7 the Free Software Foundation; either version 3, or (at your option) | 7 the Free Software Foundation; either version 3, or (at your option) |
8 any later version. | 8 any later version. |
9 | 9 |
10 This program is distributed in the hope that it will be useful, | 10 This program 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 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 General Public License |
16 along with this program; if not, write to the Free Software Foundation, | 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ |
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | |
18 | 17 |
19 #ifndef _GL_STRING_H | 18 #ifndef _@GUARD_PREFIX@_STRING_H |
20 | 19 |
21 #if __GNUC__ >= 3 | 20 #if __GNUC__ >= 3 |
22 @PRAGMA_SYSTEM_HEADER@ | 21 @PRAGMA_SYSTEM_HEADER@ |
23 #endif | 22 #endif |
| 23 @PRAGMA_COLUMNS@ |
24 | 24 |
25 /* The include_next requires a split double-inclusion guard. */ | 25 /* The include_next requires a split double-inclusion guard. */ |
26 #@INCLUDE_NEXT@ @NEXT_STRING_H@ | 26 #@INCLUDE_NEXT@ @NEXT_STRING_H@ |
27 | 27 |
28 #ifndef _GL_STRING_H | 28 #ifndef _@GUARD_PREFIX@_STRING_H |
29 #define _GL_STRING_H | 29 #define _@GUARD_PREFIX@_STRING_H |
30 | 30 |
31 /* NetBSD 5.0 mis-defines NULL. */ | 31 /* NetBSD 5.0 mis-defines NULL. */ |
32 #include <stddef.h> | 32 #include <stddef.h> |
33 | 33 |
34 /* MirBSD defines mbslen as a macro. */ | 34 /* MirBSD defines mbslen as a macro. */ |
35 #if @GNULIB_MBSLEN@ && defined __MirBSD__ | 35 #if @GNULIB_MBSLEN@ && defined __MirBSD__ |
36 # include <wchar.h> | 36 # include <wchar.h> |
37 #endif | 37 #endif |
38 | 38 |
39 #ifndef __attribute__ | 39 /* The __attribute__ feature is available in gcc versions 2.5 and later. |
40 /* This 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__ < 5) | 41 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) |
42 # define __attribute__(Spec) /* empty */ | 42 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) |
43 # endif | 43 #else |
44 /* The attribute __pure__ was added in gcc 2.96. */ | 44 # define _GL_ATTRIBUTE_PURE /* empty */ |
45 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) | |
46 # define __pure__ /* empty */ | |
47 # endif | |
48 #endif | 45 #endif |
49 | 46 |
| 47 /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ |
| 48 /* But in any case avoid namespace pollution on glibc systems. */ |
| 49 #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ |
| 50 && ! defined __GLIBC__ |
| 51 # include <unistd.h> |
| 52 #endif |
50 | 53 |
51 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | 54 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
52 | 55 |
53 /* The definition of _GL_ARG_NONNULL is copied here. */ | 56 /* The definition of _GL_ARG_NONNULL is copied here. */ |
54 | 57 |
55 /* The definition of _GL_WARN_ON_USE is copied here. */ | 58 /* The definition of _GL_WARN_ON_USE is copied here. */ |
56 | 59 |
57 | 60 |
| 61 /* Find the index of the least-significant set bit. */ |
| 62 #if @GNULIB_FFSL@ |
| 63 # if !@HAVE_FFSL@ |
| 64 _GL_FUNCDECL_SYS (ffsl, int, (long int i)); |
| 65 # endif |
| 66 _GL_CXXALIAS_SYS (ffsl, int, (long int i)); |
| 67 _GL_CXXALIASWARN (ffsl); |
| 68 #elif defined GNULIB_POSIXCHECK |
| 69 # undef ffsl |
| 70 # if HAVE_RAW_DECL_FFSL |
| 71 _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module"); |
| 72 # endif |
| 73 #endif |
| 74 |
| 75 |
| 76 /* Find the index of the least-significant set bit. */ |
| 77 #if @GNULIB_FFSLL@ |
| 78 # if !@HAVE_FFSLL@ |
| 79 _GL_FUNCDECL_SYS (ffsll, int, (long long int i)); |
| 80 # endif |
| 81 _GL_CXXALIAS_SYS (ffsll, int, (long long int i)); |
| 82 _GL_CXXALIASWARN (ffsll); |
| 83 #elif defined GNULIB_POSIXCHECK |
| 84 # undef ffsll |
| 85 # if HAVE_RAW_DECL_FFSLL |
| 86 _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module"); |
| 87 # endif |
| 88 #endif |
| 89 |
| 90 |
58 /* Return the first instance of C within N bytes of S, or NULL. */ | 91 /* Return the first instance of C within N bytes of S, or NULL. */ |
59 #if @GNULIB_MEMCHR@ | 92 #if @GNULIB_MEMCHR@ |
60 # if @REPLACE_MEMCHR@ | 93 # if @REPLACE_MEMCHR@ |
61 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 94 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
62 # define memchr rpl_memchr | 95 # define memchr rpl_memchr |
63 # endif | 96 # endif |
64 _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) | 97 _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) |
65 __attribute__ ((__pure__)) | 98 _GL_ATTRIBUTE_PURE |
66 _GL_ARG_NONNULL ((1))); | 99 _GL_ARG_NONNULL ((1))); |
67 _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); | 100 _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); |
68 # else | 101 # else |
69 # if ! @HAVE_MEMCHR@ | 102 # if ! @HAVE_MEMCHR@ |
70 _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) | 103 _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) |
71 __attribute__ ((__pure__)) | 104 _GL_ATTRIBUTE_PURE |
72 _GL_ARG_NONNULL ((1))); | 105 _GL_ARG_NONNULL ((1))); |
73 # endif | 106 # endif |
74 /* On some systems, this function is defined as an overloaded function: | 107 /* On some systems, this function is defined as an overloaded function: |
75 extern "C" { const void * std::memchr (const void *, int, size_t); } | 108 extern "C" { const void * std::memchr (const void *, int, size_t); } |
76 extern "C++" { void * std::memchr (void *, int, size_t); } */ | 109 extern "C++" { void * std::memchr (void *, int, size_t); } */ |
77 _GL_CXXALIAS_SYS_CAST2 (memchr, | 110 _GL_CXXALIAS_SYS_CAST2 (memchr, |
78 void *, (void const *__s, int __c, size_t __n), | 111 void *, (void const *__s, int __c, size_t __n), |
79 void const *, (void const *__s, int __c, size_t __n)); | 112 void const *, (void const *__s, int __c, size_t __n)); |
80 # endif | 113 # endif |
81 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | 114 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
82 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | 115 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
83 _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); | 116 _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); |
84 _GL_CXXALIASWARN1 (memchr, void const *, | 117 _GL_CXXALIASWARN1 (memchr, void const *, |
85 (void const *__s, int __c, size_t __n)); | 118 (void const *__s, int __c, size_t __n)); |
86 # else | 119 # else |
87 _GL_CXXALIASWARN (memchr); | 120 _GL_CXXALIASWARN (memchr); |
88 # endif | 121 # endif |
89 #elif defined GNULIB_POSIXCHECK | 122 #elif defined GNULIB_POSIXCHECK |
90 # undef memchr | 123 # undef memchr |
91 /* Assume memchr is always declared. */ | 124 /* Assume memchr is always declared. */ |
92 _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " | 125 _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " |
93 "use gnulib module memchr for portability" ); | 126 "use gnulib module memchr for portability" ); |
94 #endif | 127 #endif |
95 | 128 |
96 /* Return the first occurrence of NEEDLE in HAYSTACK. */ | 129 /* Return the first occurrence of NEEDLE in HAYSTACK. */ |
97 #if @GNULIB_MEMMEM@ | 130 #if @GNULIB_MEMMEM@ |
98 # if @REPLACE_MEMMEM@ | 131 # if @REPLACE_MEMMEM@ |
99 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 132 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
100 # define memmem rpl_memmem | 133 # define memmem rpl_memmem |
101 # endif | 134 # endif |
102 _GL_FUNCDECL_RPL (memmem, void *, | 135 _GL_FUNCDECL_RPL (memmem, void *, |
103 (void const *__haystack, size_t __haystack_len, | 136 (void const *__haystack, size_t __haystack_len, |
104 void const *__needle, size_t __needle_len) | 137 void const *__needle, size_t __needle_len) |
105 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3))); | 138 _GL_ATTRIBUTE_PURE |
| 139 _GL_ARG_NONNULL ((1, 3))); |
106 _GL_CXXALIAS_RPL (memmem, void *, | 140 _GL_CXXALIAS_RPL (memmem, void *, |
107 (void const *__haystack, size_t __haystack_len, | 141 (void const *__haystack, size_t __haystack_len, |
108 void const *__needle, size_t __needle_len)); | 142 void const *__needle, size_t __needle_len)); |
109 # else | 143 # else |
110 # if ! @HAVE_DECL_MEMMEM@ | 144 # if ! @HAVE_DECL_MEMMEM@ |
111 _GL_FUNCDECL_SYS (memmem, void *, | 145 _GL_FUNCDECL_SYS (memmem, void *, |
112 (void const *__haystack, size_t __haystack_len, | 146 (void const *__haystack, size_t __haystack_len, |
113 void const *__needle, size_t __needle_len) | 147 void const *__needle, size_t __needle_len) |
114 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3))); | 148 _GL_ATTRIBUTE_PURE |
| 149 _GL_ARG_NONNULL ((1, 3))); |
115 # endif | 150 # endif |
116 _GL_CXXALIAS_SYS (memmem, void *, | 151 _GL_CXXALIAS_SYS (memmem, void *, |
117 (void const *__haystack, size_t __haystack_len, | 152 (void const *__haystack, size_t __haystack_len, |
118 void const *__needle, size_t __needle_len)); | 153 void const *__needle, size_t __needle_len)); |
119 # endif | 154 # endif |
120 _GL_CXXALIASWARN (memmem); | 155 _GL_CXXALIASWARN (memmem); |
121 #elif defined GNULIB_POSIXCHECK | 156 #elif defined GNULIB_POSIXCHECK |
122 # undef memmem | 157 # undef memmem |
123 # if HAVE_RAW_DECL_MEMMEM | 158 # if HAVE_RAW_DECL_MEMMEM |
124 _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " | 159 _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " |
(...skipping 20 matching lines...) Expand all Loading... |
145 # if HAVE_RAW_DECL_MEMPCPY | 180 # if HAVE_RAW_DECL_MEMPCPY |
146 _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " | 181 _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " |
147 "use gnulib module mempcpy for portability"); | 182 "use gnulib module mempcpy for portability"); |
148 # endif | 183 # endif |
149 #endif | 184 #endif |
150 | 185 |
151 /* Search backwards through a block for a byte (specified as an int). */ | 186 /* Search backwards through a block for a byte (specified as an int). */ |
152 #if @GNULIB_MEMRCHR@ | 187 #if @GNULIB_MEMRCHR@ |
153 # if ! @HAVE_DECL_MEMRCHR@ | 188 # if ! @HAVE_DECL_MEMRCHR@ |
154 _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) | 189 _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) |
155 __attribute__ ((__pure__)) | 190 _GL_ATTRIBUTE_PURE |
156 _GL_ARG_NONNULL ((1))); | 191 _GL_ARG_NONNULL ((1))); |
157 # endif | 192 # endif |
158 /* On some systems, this function is defined as an overloaded function: | 193 /* On some systems, this function is defined as an overloaded function: |
159 extern "C++" { const void * std::memrchr (const void *, int, size_t); } | 194 extern "C++" { const void * std::memrchr (const void *, int, size_t); } |
160 extern "C++" { void * std::memrchr (void *, int, size_t); } */ | 195 extern "C++" { void * std::memrchr (void *, int, size_t); } */ |
161 _GL_CXXALIAS_SYS_CAST2 (memrchr, | 196 _GL_CXXALIAS_SYS_CAST2 (memrchr, |
162 void *, (void const *, int, size_t), | 197 void *, (void const *, int, size_t), |
163 void const *, (void const *, int, size_t)); | 198 void const *, (void const *, int, size_t)); |
164 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | 199 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
165 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | 200 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
166 _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); | 201 _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); |
167 _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); | 202 _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); |
168 # else | 203 # else |
169 _GL_CXXALIASWARN (memrchr); | 204 _GL_CXXALIASWARN (memrchr); |
170 # endif | 205 # endif |
171 #elif defined GNULIB_POSIXCHECK | 206 #elif defined GNULIB_POSIXCHECK |
172 # undef memrchr | 207 # undef memrchr |
173 # if HAVE_RAW_DECL_MEMRCHR | 208 # if HAVE_RAW_DECL_MEMRCHR |
174 _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " | 209 _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " |
175 "use gnulib module memrchr for portability"); | 210 "use gnulib module memrchr for portability"); |
176 # endif | 211 # endif |
177 #endif | 212 #endif |
178 | 213 |
179 /* Find the first occurrence of C in S. More efficient than | 214 /* Find the first occurrence of C in S. More efficient than |
180 memchr(S,C,N), at the expense of undefined behavior if C does not | 215 memchr(S,C,N), at the expense of undefined behavior if C does not |
181 occur within N bytes. */ | 216 occur within N bytes. */ |
182 #if @GNULIB_RAWMEMCHR@ | 217 #if @GNULIB_RAWMEMCHR@ |
183 # if ! @HAVE_RAWMEMCHR@ | 218 # if ! @HAVE_RAWMEMCHR@ |
184 _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) | 219 _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) |
185 __attribute__ ((__pure__)) | 220 _GL_ATTRIBUTE_PURE |
186 _GL_ARG_NONNULL ((1))); | 221 _GL_ARG_NONNULL ((1))); |
187 # endif | 222 # endif |
188 /* On some systems, this function is defined as an overloaded function: | 223 /* On some systems, this function is defined as an overloaded function: |
189 extern "C++" { const void * std::rawmemchr (const void *, int); } | 224 extern "C++" { const void * std::rawmemchr (const void *, int); } |
190 extern "C++" { void * std::rawmemchr (void *, int); } */ | 225 extern "C++" { void * std::rawmemchr (void *, int); } */ |
191 _GL_CXXALIAS_SYS_CAST2 (rawmemchr, | 226 _GL_CXXALIAS_SYS_CAST2 (rawmemchr, |
192 void *, (void const *__s, int __c_in), | 227 void *, (void const *__s, int __c_in), |
193 void const *, (void const *__s, int __c_in)); | 228 void const *, (void const *__s, int __c_in)); |
194 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | 229 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
195 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | 230 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
196 _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); | 231 _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); |
197 _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); | 232 _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); |
198 # else | 233 # else |
199 _GL_CXXALIASWARN (rawmemchr); | 234 _GL_CXXALIASWARN (rawmemchr); |
200 # endif | 235 # endif |
201 #elif defined GNULIB_POSIXCHECK | 236 #elif defined GNULIB_POSIXCHECK |
202 # undef rawmemchr | 237 # undef rawmemchr |
203 # if HAVE_RAW_DECL_RAWMEMCHR | 238 # if HAVE_RAW_DECL_RAWMEMCHR |
204 _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " | 239 _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " |
(...skipping 17 matching lines...) Expand all Loading... |
222 _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " | 257 _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " |
223 "use gnulib module stpcpy for portability"); | 258 "use gnulib module stpcpy for portability"); |
224 # endif | 259 # endif |
225 #endif | 260 #endif |
226 | 261 |
227 /* Copy no more than N bytes of SRC to DST, returning a pointer past the | 262 /* Copy no more than N bytes of SRC to DST, returning a pointer past the |
228 last non-NUL byte written into DST. */ | 263 last non-NUL byte written into DST. */ |
229 #if @GNULIB_STPNCPY@ | 264 #if @GNULIB_STPNCPY@ |
230 # if @REPLACE_STPNCPY@ | 265 # if @REPLACE_STPNCPY@ |
231 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 266 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 267 # undef stpncpy |
232 # define stpncpy rpl_stpncpy | 268 # define stpncpy rpl_stpncpy |
233 # endif | 269 # endif |
234 _GL_FUNCDECL_RPL (stpncpy, char *, | 270 _GL_FUNCDECL_RPL (stpncpy, char *, |
235 (char *restrict __dst, char const *restrict __src, | 271 (char *restrict __dst, char const *restrict __src, |
236 size_t __n) | 272 size_t __n) |
237 _GL_ARG_NONNULL ((1, 2))); | 273 _GL_ARG_NONNULL ((1, 2))); |
238 _GL_CXXALIAS_RPL (stpncpy, char *, | 274 _GL_CXXALIAS_RPL (stpncpy, char *, |
239 (char *restrict __dst, char const *restrict __src, | 275 (char *restrict __dst, char const *restrict __src, |
240 size_t __n)); | 276 size_t __n)); |
241 # else | 277 # else |
(...skipping 21 matching lines...) Expand all Loading... |
263 GB18030 and the character to be searched is a digit. */ | 299 GB18030 and the character to be searched is a digit. */ |
264 # undef strchr | 300 # undef strchr |
265 /* Assume strchr is always declared. */ | 301 /* Assume strchr is always declared. */ |
266 _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " | 302 _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " |
267 "in some multibyte locales - " | 303 "in some multibyte locales - " |
268 "use mbschr if you care about internationalization"); | 304 "use mbschr if you care about internationalization"); |
269 #endif | 305 #endif |
270 | 306 |
271 /* Find the first occurrence of C in S or the final NUL byte. */ | 307 /* Find the first occurrence of C in S or the final NUL byte. */ |
272 #if @GNULIB_STRCHRNUL@ | 308 #if @GNULIB_STRCHRNUL@ |
273 # if ! @HAVE_STRCHRNUL@ | 309 # if @REPLACE_STRCHRNUL@ |
| 310 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 311 # define strchrnul rpl_strchrnul |
| 312 # endif |
| 313 _GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in) |
| 314 _GL_ATTRIBUTE_PURE |
| 315 _GL_ARG_NONNULL ((1))); |
| 316 _GL_CXXALIAS_RPL (strchrnul, char *, |
| 317 (const char *str, int ch)); |
| 318 # else |
| 319 # if ! @HAVE_STRCHRNUL@ |
274 _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) | 320 _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) |
275 __attribute__ ((__pure__)) | 321 _GL_ATTRIBUTE_PURE |
276 _GL_ARG_NONNULL ((1))); | 322 _GL_ARG_NONNULL ((1))); |
277 # endif | 323 # endif |
278 /* On some systems, this function is defined as an overloaded function: | 324 /* On some systems, this function is defined as an overloaded function: |
279 extern "C++" { const char * std::strchrnul (const char *, int); } | 325 extern "C++" { const char * std::strchrnul (const char *, int); } |
280 extern "C++" { char * std::strchrnul (char *, int); } */ | 326 extern "C++" { char * std::strchrnul (char *, int); } */ |
281 _GL_CXXALIAS_SYS_CAST2 (strchrnul, | 327 _GL_CXXALIAS_SYS_CAST2 (strchrnul, |
282 char *, (char const *__s, int __c_in), | 328 char *, (char const *__s, int __c_in), |
283 char const *, (char const *__s, int __c_in)); | 329 char const *, (char const *__s, int __c_in)); |
284 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | 330 # endif |
| 331 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
285 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | 332 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
286 _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); | 333 _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); |
287 _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); | 334 _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); |
288 # else | 335 # else |
289 _GL_CXXALIASWARN (strchrnul); | 336 _GL_CXXALIASWARN (strchrnul); |
290 # endif | 337 # endif |
291 #elif defined GNULIB_POSIXCHECK | 338 #elif defined GNULIB_POSIXCHECK |
292 # undef strchrnul | 339 # undef strchrnul |
293 # if HAVE_RAW_DECL_STRCHRNUL | 340 # if HAVE_RAW_DECL_STRCHRNUL |
294 _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " | 341 _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " |
295 "use gnulib module strchrnul for portability"); | 342 "use gnulib module strchrnul for portability"); |
296 # endif | 343 # endif |
297 #endif | 344 #endif |
298 | 345 |
299 /* Duplicate S, returning an identical malloc'd string. */ | 346 /* Duplicate S, returning an identical malloc'd string. */ |
300 #if @GNULIB_STRDUP@ | 347 #if @GNULIB_STRDUP@ |
301 # if @REPLACE_STRDUP@ | 348 # if @REPLACE_STRDUP@ |
302 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 349 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
303 # undef strdup | 350 # undef strdup |
304 # define strdup rpl_strdup | 351 # define strdup rpl_strdup |
305 # endif | 352 # endif |
306 _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); | 353 _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); |
307 _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); | 354 _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); |
308 # else | 355 # else |
| 356 # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup |
| 357 /* strdup exists as a function and as a macro. Get rid of the macro. */ |
| 358 # undef strdup |
| 359 # endif |
309 # if !(@HAVE_DECL_STRDUP@ || defined strdup) | 360 # if !(@HAVE_DECL_STRDUP@ || defined strdup) |
310 _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); | 361 _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); |
311 # endif | 362 # endif |
312 _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); | 363 _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); |
313 # endif | 364 # endif |
314 _GL_CXXALIASWARN (strdup); | 365 _GL_CXXALIASWARN (strdup); |
315 #elif defined GNULIB_POSIXCHECK | 366 #elif defined GNULIB_POSIXCHECK |
316 # undef strdup | 367 # undef strdup |
317 # if HAVE_RAW_DECL_STRDUP | 368 # if HAVE_RAW_DECL_STRDUP |
318 _GL_WARN_ON_USE (strdup, "strdup is unportable - " | 369 _GL_WARN_ON_USE (strdup, "strdup is unportable - " |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 /* Find the length (number of bytes) of STRING, but scan at most | 422 /* Find the length (number of bytes) of STRING, but scan at most |
372 MAXLEN bytes. If no '\0' terminator is found in that many bytes, | 423 MAXLEN bytes. If no '\0' terminator is found in that many bytes, |
373 return MAXLEN. */ | 424 return MAXLEN. */ |
374 #if @GNULIB_STRNLEN@ | 425 #if @GNULIB_STRNLEN@ |
375 # if @REPLACE_STRNLEN@ | 426 # if @REPLACE_STRNLEN@ |
376 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 427 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
377 # undef strnlen | 428 # undef strnlen |
378 # define strnlen rpl_strnlen | 429 # define strnlen rpl_strnlen |
379 # endif | 430 # endif |
380 _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) | 431 _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) |
381 __attribute__ ((__pure__)) | 432 _GL_ATTRIBUTE_PURE |
382 _GL_ARG_NONNULL ((1))); | 433 _GL_ARG_NONNULL ((1))); |
383 _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); | 434 _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); |
384 # else | 435 # else |
385 # if ! @HAVE_DECL_STRNLEN@ | 436 # if ! @HAVE_DECL_STRNLEN@ |
386 _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) | 437 _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) |
387 __attribute__ ((__pure__)) | 438 _GL_ATTRIBUTE_PURE |
388 _GL_ARG_NONNULL ((1))); | 439 _GL_ARG_NONNULL ((1))); |
389 # endif | 440 # endif |
390 _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); | 441 _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); |
391 # endif | 442 # endif |
392 _GL_CXXALIASWARN (strnlen); | 443 _GL_CXXALIASWARN (strnlen); |
393 #elif defined GNULIB_POSIXCHECK | 444 #elif defined GNULIB_POSIXCHECK |
394 # undef strnlen | 445 # undef strnlen |
395 # if HAVE_RAW_DECL_STRNLEN | 446 # if HAVE_RAW_DECL_STRNLEN |
396 _GL_WARN_ON_USE (strnlen, "strnlen is unportable - " | 447 _GL_WARN_ON_USE (strnlen, "strnlen is unportable - " |
397 "use gnulib module strnlen for portability"); | 448 "use gnulib module strnlen for portability"); |
398 # endif | 449 # endif |
399 #endif | 450 #endif |
400 | 451 |
401 #if defined GNULIB_POSIXCHECK | 452 #if defined GNULIB_POSIXCHECK |
402 /* strcspn() assumes the second argument is a list of single-byte characters. | 453 /* strcspn() assumes the second argument is a list of single-byte characters. |
403 Even in this simple case, it does not work with multibyte strings if the | 454 Even in this simple case, it does not work with multibyte strings if the |
404 locale encoding is GB18030 and one of the characters to be searched is a | 455 locale encoding is GB18030 and one of the characters to be searched is a |
405 digit. */ | 456 digit. */ |
406 # undef strcspn | 457 # undef strcspn |
407 /* Assume strcspn is always declared. */ | 458 /* Assume strcspn is always declared. */ |
408 _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " | 459 _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " |
409 "in multibyte locales - " | 460 "in multibyte locales - " |
410 "use mbscspn if you care about internationalization"); | 461 "use mbscspn if you care about internationalization"); |
411 #endif | 462 #endif |
412 | 463 |
413 /* Find the first occurrence in S of any character in ACCEPT. */ | 464 /* Find the first occurrence in S of any character in ACCEPT. */ |
414 #if @GNULIB_STRPBRK@ | 465 #if @GNULIB_STRPBRK@ |
415 # if ! @HAVE_STRPBRK@ | 466 # if ! @HAVE_STRPBRK@ |
416 _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) | 467 _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) |
417 __attribute__ ((__pure__)) | 468 _GL_ATTRIBUTE_PURE |
418 _GL_ARG_NONNULL ((1, 2))); | 469 _GL_ARG_NONNULL ((1, 2))); |
419 # endif | 470 # endif |
420 /* On some systems, this function is defined as an overloaded function: | 471 /* On some systems, this function is defined as an overloaded function: |
421 extern "C" { const char * strpbrk (const char *, const char *); } | 472 extern "C" { const char * strpbrk (const char *, const char *); } |
422 extern "C++" { char * strpbrk (char *, const char *); } */ | 473 extern "C++" { char * strpbrk (char *, const char *); } */ |
423 _GL_CXXALIAS_SYS_CAST2 (strpbrk, | 474 _GL_CXXALIAS_SYS_CAST2 (strpbrk, |
424 char *, (char const *__s, char const *__accept), | 475 char *, (char const *__s, char const *__accept), |
425 const char *, (char const *__s, char const *__accept)); | 476 const char *, (char const *__s, char const *__accept)); |
426 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | 477 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
427 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | 478 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
428 _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); | 479 _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); |
429 _GL_CXXALIASWARN1 (strpbrk, char const *, | 480 _GL_CXXALIASWARN1 (strpbrk, char const *, |
430 (char const *__s, char const *__accept)); | 481 (char const *__s, char const *__accept)); |
431 # else | 482 # else |
432 _GL_CXXALIASWARN (strpbrk); | 483 _GL_CXXALIASWARN (strpbrk); |
433 # endif | 484 # endif |
434 # if defined GNULIB_POSIXCHECK | 485 # if defined GNULIB_POSIXCHECK |
435 /* strpbrk() assumes the second argument is a list of single-byte characters. | 486 /* strpbrk() assumes the second argument is a list of single-byte characters. |
436 Even in this simple case, it does not work with multibyte strings if the | 487 Even in this simple case, it does not work with multibyte strings if the |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 "use gnulib module strsep for portability"); | 558 "use gnulib module strsep for portability"); |
508 # endif | 559 # endif |
509 #endif | 560 #endif |
510 | 561 |
511 #if @GNULIB_STRSTR@ | 562 #if @GNULIB_STRSTR@ |
512 # if @REPLACE_STRSTR@ | 563 # if @REPLACE_STRSTR@ |
513 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 564 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
514 # define strstr rpl_strstr | 565 # define strstr rpl_strstr |
515 # endif | 566 # endif |
516 _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) | 567 _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) |
517 __attribute__ ((__pure__)) | 568 _GL_ATTRIBUTE_PURE |
518 _GL_ARG_NONNULL ((1, 2))); | 569 _GL_ARG_NONNULL ((1, 2))); |
519 _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); | 570 _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); |
520 # else | 571 # else |
521 /* On some systems, this function is defined as an overloaded function: | 572 /* On some systems, this function is defined as an overloaded function: |
522 extern "C++" { const char * strstr (const char *, const char *); } | 573 extern "C++" { const char * strstr (const char *, const char *); } |
523 extern "C++" { char * strstr (char *, const char *); } */ | 574 extern "C++" { char * strstr (char *, const char *); } */ |
524 _GL_CXXALIAS_SYS_CAST2 (strstr, | 575 _GL_CXXALIAS_SYS_CAST2 (strstr, |
525 char *, (const char *haystack, const char *needle), | 576 char *, (const char *haystack, const char *needle), |
526 const char *, (const char *haystack, const char *needle)
); | 577 const char *, (const char *haystack, const char *needle)
); |
527 # endif | 578 # endif |
528 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | 579 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
529 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | 580 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
530 _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); | 581 _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); |
531 _GL_CXXALIASWARN1 (strstr, const char *, | 582 _GL_CXXALIASWARN1 (strstr, const char *, |
532 (const char *haystack, const char *needle)); | 583 (const char *haystack, const char *needle)); |
533 # else | 584 # else |
534 _GL_CXXALIASWARN (strstr); | 585 _GL_CXXALIASWARN (strstr); |
535 # endif | 586 # endif |
536 #elif defined GNULIB_POSIXCHECK | 587 #elif defined GNULIB_POSIXCHECK |
537 /* strstr() does not work with multibyte strings if the locale encoding is | 588 /* strstr() does not work with multibyte strings if the locale encoding is |
538 different from UTF-8: | 589 different from UTF-8: |
(...skipping 10 matching lines...) Expand all Loading... |
549 | 600 |
550 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive | 601 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive |
551 comparison. */ | 602 comparison. */ |
552 #if @GNULIB_STRCASESTR@ | 603 #if @GNULIB_STRCASESTR@ |
553 # if @REPLACE_STRCASESTR@ | 604 # if @REPLACE_STRCASESTR@ |
554 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 605 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
555 # define strcasestr rpl_strcasestr | 606 # define strcasestr rpl_strcasestr |
556 # endif | 607 # endif |
557 _GL_FUNCDECL_RPL (strcasestr, char *, | 608 _GL_FUNCDECL_RPL (strcasestr, char *, |
558 (const char *haystack, const char *needle) | 609 (const char *haystack, const char *needle) |
559 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2))); | 610 _GL_ATTRIBUTE_PURE |
| 611 _GL_ARG_NONNULL ((1, 2))); |
560 _GL_CXXALIAS_RPL (strcasestr, char *, | 612 _GL_CXXALIAS_RPL (strcasestr, char *, |
561 (const char *haystack, const char *needle)); | 613 (const char *haystack, const char *needle)); |
562 # else | 614 # else |
563 # if ! @HAVE_STRCASESTR@ | 615 # if ! @HAVE_STRCASESTR@ |
564 _GL_FUNCDECL_SYS (strcasestr, char *, | 616 _GL_FUNCDECL_SYS (strcasestr, char *, |
565 (const char *haystack, const char *needle) | 617 (const char *haystack, const char *needle) |
566 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2))); | 618 _GL_ATTRIBUTE_PURE |
| 619 _GL_ARG_NONNULL ((1, 2))); |
567 # endif | 620 # endif |
568 /* On some systems, this function is defined as an overloaded function: | 621 /* On some systems, this function is defined as an overloaded function: |
569 extern "C++" { const char * strcasestr (const char *, const char *); } | 622 extern "C++" { const char * strcasestr (const char *, const char *); } |
570 extern "C++" { char * strcasestr (char *, const char *); } */ | 623 extern "C++" { char * strcasestr (char *, const char *); } */ |
571 _GL_CXXALIAS_SYS_CAST2 (strcasestr, | 624 _GL_CXXALIAS_SYS_CAST2 (strcasestr, |
572 char *, (const char *haystack, const char *needle), | 625 char *, (const char *haystack, const char *needle), |
573 const char *, (const char *haystack, const char *needle)
); | 626 const char *, (const char *haystack, const char *needle)
); |
574 # endif | 627 # endif |
575 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | 628 # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
576 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | 629 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
577 _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); | 630 _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); |
578 _GL_CXXALIASWARN1 (strcasestr, const char *, | 631 _GL_CXXALIASWARN1 (strcasestr, const char *, |
579 (const char *haystack, const char *needle)); | 632 (const char *haystack, const char *needle)); |
580 # else | 633 # else |
581 _GL_CXXALIASWARN (strcasestr); | 634 _GL_CXXALIASWARN (strcasestr); |
582 # endif | 635 # endif |
583 #elif defined GNULIB_POSIXCHECK | 636 #elif defined GNULIB_POSIXCHECK |
584 /* strcasestr() does not work with multibyte strings: | 637 /* strcasestr() does not work with multibyte strings: |
585 It is a glibc extension, and glibc implements it only for unibyte | 638 It is a glibc extension, and glibc implements it only for unibyte |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 #if @GNULIB_MBSLEN@ | 717 #if @GNULIB_MBSLEN@ |
665 /* Return the number of multibyte characters in the character string STRING. | 718 /* Return the number of multibyte characters in the character string STRING. |
666 This considers multibyte characters, unlike strlen, which counts bytes. */ | 719 This considers multibyte characters, unlike strlen, which counts bytes. */ |
667 # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ | 720 # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ |
668 # undef mbslen | 721 # undef mbslen |
669 # endif | 722 # endif |
670 # if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */ | 723 # if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */ |
671 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 724 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
672 # define mbslen rpl_mbslen | 725 # define mbslen rpl_mbslen |
673 # endif | 726 # endif |
674 _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1))); | 727 _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) |
| 728 _GL_ATTRIBUTE_PURE |
| 729 _GL_ARG_NONNULL ((1))); |
675 _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); | 730 _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); |
676 # else | 731 # else |
677 _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1))); | 732 _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) |
| 733 _GL_ATTRIBUTE_PURE |
| 734 _GL_ARG_NONNULL ((1))); |
678 _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); | 735 _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); |
679 # endif | 736 # endif |
680 _GL_CXXALIASWARN (mbslen); | 737 _GL_CXXALIASWARN (mbslen); |
681 #endif | 738 #endif |
682 | 739 |
683 #if @GNULIB_MBSNLEN@ | 740 #if @GNULIB_MBSNLEN@ |
684 /* Return the number of multibyte characters in the character string starting | 741 /* Return the number of multibyte characters in the character string starting |
685 at STRING and ending at STRING + LEN. */ | 742 at STRING and ending at STRING + LEN. */ |
686 _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) | 743 _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) |
| 744 _GL_ATTRIBUTE_PURE |
687 _GL_ARG_NONNULL ((1)); | 745 _GL_ARG_NONNULL ((1)); |
688 #endif | 746 #endif |
689 | 747 |
690 #if @GNULIB_MBSCHR@ | 748 #if @GNULIB_MBSCHR@ |
691 /* Locate the first single-byte character C in the character string STRING, | 749 /* Locate the first single-byte character C in the character string STRING, |
692 and return a pointer to it. Return NULL if C is not found in STRING. | 750 and return a pointer to it. Return NULL if C is not found in STRING. |
693 Unlike strchr(), this function works correctly in multibyte locales with | 751 Unlike strchr(), this function works correctly in multibyte locales with |
694 encodings such as GB18030. */ | 752 encodings such as GB18030. */ |
695 # if defined __hpux | 753 # if defined __hpux |
696 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 754 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
697 # define mbschr rpl_mbschr /* avoid collision with HP-UX function */ | 755 # define mbschr rpl_mbschr /* avoid collision with HP-UX function */ |
698 # endif | 756 # endif |
699 _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) | 757 _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) |
| 758 _GL_ATTRIBUTE_PURE |
700 _GL_ARG_NONNULL ((1))); | 759 _GL_ARG_NONNULL ((1))); |
701 _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); | 760 _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); |
702 # else | 761 # else |
703 _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) | 762 _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) |
| 763 _GL_ATTRIBUTE_PURE |
704 _GL_ARG_NONNULL ((1))); | 764 _GL_ARG_NONNULL ((1))); |
705 _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); | 765 _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); |
706 # endif | 766 # endif |
707 _GL_CXXALIASWARN (mbschr); | 767 _GL_CXXALIASWARN (mbschr); |
708 #endif | 768 #endif |
709 | 769 |
710 #if @GNULIB_MBSRCHR@ | 770 #if @GNULIB_MBSRCHR@ |
711 /* Locate the last single-byte character C in the character string STRING, | 771 /* Locate the last single-byte character C in the character string STRING, |
712 and return a pointer to it. Return NULL if C is not found in STRING. | 772 and return a pointer to it. Return NULL if C is not found in STRING. |
713 Unlike strrchr(), this function works correctly in multibyte locales with | 773 Unlike strrchr(), this function works correctly in multibyte locales with |
714 encodings such as GB18030. */ | 774 encodings such as GB18030. */ |
715 # if defined __hpux | 775 # if defined __hpux || defined __INTERIX |
716 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 776 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
717 # define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */ | 777 # define mbsrchr rpl_mbsrchr /* avoid collision with system function */ |
718 # endif | 778 # endif |
719 _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) | 779 _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) |
| 780 _GL_ATTRIBUTE_PURE |
720 _GL_ARG_NONNULL ((1))); | 781 _GL_ARG_NONNULL ((1))); |
721 _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); | 782 _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); |
722 # else | 783 # else |
723 _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) | 784 _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) |
| 785 _GL_ATTRIBUTE_PURE |
724 _GL_ARG_NONNULL ((1))); | 786 _GL_ARG_NONNULL ((1))); |
725 _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); | 787 _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); |
726 # endif | 788 # endif |
727 _GL_CXXALIASWARN (mbsrchr); | 789 _GL_CXXALIASWARN (mbsrchr); |
728 #endif | 790 #endif |
729 | 791 |
730 #if @GNULIB_MBSSTR@ | 792 #if @GNULIB_MBSSTR@ |
731 /* Find the first occurrence of the character string NEEDLE in the character | 793 /* Find the first occurrence of the character string NEEDLE in the character |
732 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. | 794 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. |
733 Unlike strstr(), this function works correctly in multibyte locales with | 795 Unlike strstr(), this function works correctly in multibyte locales with |
734 encodings different from UTF-8. */ | 796 encodings different from UTF-8. */ |
735 _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) | 797 _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) |
| 798 _GL_ATTRIBUTE_PURE |
736 _GL_ARG_NONNULL ((1, 2)); | 799 _GL_ARG_NONNULL ((1, 2)); |
737 #endif | 800 #endif |
738 | 801 |
739 #if @GNULIB_MBSCASECMP@ | 802 #if @GNULIB_MBSCASECMP@ |
740 /* Compare the character strings S1 and S2, ignoring case, returning less than, | 803 /* Compare the character strings S1 and S2, ignoring case, returning less than, |
741 equal to or greater than zero if S1 is lexicographically less than, equal to | 804 equal to or greater than zero if S1 is lexicographically less than, equal to |
742 or greater than S2. | 805 or greater than S2. |
743 Note: This function may, in multibyte locales, return 0 for strings of | 806 Note: This function may, in multibyte locales, return 0 for strings of |
744 different lengths! | 807 different lengths! |
745 Unlike strcasecmp(), this function works correctly in multibyte locales. */ | 808 Unlike strcasecmp(), this function works correctly in multibyte locales. */ |
746 _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2) | 809 _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2) |
| 810 _GL_ATTRIBUTE_PURE |
747 _GL_ARG_NONNULL ((1, 2)); | 811 _GL_ARG_NONNULL ((1, 2)); |
748 #endif | 812 #endif |
749 | 813 |
750 #if @GNULIB_MBSNCASECMP@ | 814 #if @GNULIB_MBSNCASECMP@ |
751 /* Compare the initial segment of the character string S1 consisting of at most | 815 /* Compare the initial segment of the character string S1 consisting of at most |
752 N characters with the initial segment of the character string S2 consisting | 816 N characters with the initial segment of the character string S2 consisting |
753 of at most N characters, ignoring case, returning less than, equal to or | 817 of at most N characters, ignoring case, returning less than, equal to or |
754 greater than zero if the initial segment of S1 is lexicographically less | 818 greater than zero if the initial segment of S1 is lexicographically less |
755 than, equal to or greater than the initial segment of S2. | 819 than, equal to or greater than the initial segment of S2. |
756 Note: This function may, in multibyte locales, return 0 for initial segments | 820 Note: This function may, in multibyte locales, return 0 for initial segments |
757 of different lengths! | 821 of different lengths! |
758 Unlike strncasecmp(), this function works correctly in multibyte locales. | 822 Unlike strncasecmp(), this function works correctly in multibyte locales. |
759 But beware that N is not a byte count but a character count! */ | 823 But beware that N is not a byte count but a character count! */ |
760 _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) | 824 _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) |
| 825 _GL_ATTRIBUTE_PURE |
761 _GL_ARG_NONNULL ((1, 2)); | 826 _GL_ARG_NONNULL ((1, 2)); |
762 #endif | 827 #endif |
763 | 828 |
764 #if @GNULIB_MBSPCASECMP@ | 829 #if @GNULIB_MBSPCASECMP@ |
765 /* Compare the initial segment of the character string STRING consisting of | 830 /* Compare the initial segment of the character string STRING consisting of |
766 at most mbslen (PREFIX) characters with the character string PREFIX, | 831 at most mbslen (PREFIX) characters with the character string PREFIX, |
767 ignoring case, returning less than, equal to or greater than zero if this | 832 ignoring case. If the two match, return a pointer to the first byte |
768 initial segment is lexicographically less than, equal to or greater than | 833 after this prefix in STRING. Otherwise, return NULL. |
769 PREFIX. | 834 Note: This function may, in multibyte locales, return non-NULL if STRING |
770 Note: This function may, in multibyte locales, return 0 if STRING is of | 835 is of smaller length than PREFIX! |
771 smaller length than PREFIX! | |
772 Unlike strncasecmp(), this function works correctly in multibyte | 836 Unlike strncasecmp(), this function works correctly in multibyte |
773 locales. */ | 837 locales. */ |
774 _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) | 838 _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) |
| 839 _GL_ATTRIBUTE_PURE |
775 _GL_ARG_NONNULL ((1, 2)); | 840 _GL_ARG_NONNULL ((1, 2)); |
776 #endif | 841 #endif |
777 | 842 |
778 #if @GNULIB_MBSCASESTR@ | 843 #if @GNULIB_MBSCASESTR@ |
779 /* Find the first occurrence of the character string NEEDLE in the character | 844 /* Find the first occurrence of the character string NEEDLE in the character |
780 string HAYSTACK, using case-insensitive comparison. | 845 string HAYSTACK, using case-insensitive comparison. |
781 Note: This function may, in multibyte locales, return success even if | 846 Note: This function may, in multibyte locales, return success even if |
782 strlen (haystack) < strlen (needle) ! | 847 strlen (haystack) < strlen (needle) ! |
783 Unlike strcasestr(), this function works correctly in multibyte locales. */ | 848 Unlike strcasestr(), this function works correctly in multibyte locales. */ |
784 _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) | 849 _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) |
| 850 _GL_ATTRIBUTE_PURE |
785 _GL_ARG_NONNULL ((1, 2)); | 851 _GL_ARG_NONNULL ((1, 2)); |
786 #endif | 852 #endif |
787 | 853 |
788 #if @GNULIB_MBSCSPN@ | 854 #if @GNULIB_MBSCSPN@ |
789 /* Find the first occurrence in the character string STRING of any character | 855 /* Find the first occurrence in the character string STRING of any character |
790 in the character string ACCEPT. Return the number of bytes from the | 856 in the character string ACCEPT. Return the number of bytes from the |
791 beginning of the string to this occurrence, or to the end of the string | 857 beginning of the string to this occurrence, or to the end of the string |
792 if none exists. | 858 if none exists. |
793 Unlike strcspn(), this function works correctly in multibyte locales. */ | 859 Unlike strcspn(), this function works correctly in multibyte locales. */ |
794 _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) | 860 _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) |
| 861 _GL_ATTRIBUTE_PURE |
795 _GL_ARG_NONNULL ((1, 2)); | 862 _GL_ARG_NONNULL ((1, 2)); |
796 #endif | 863 #endif |
797 | 864 |
798 #if @GNULIB_MBSPBRK@ | 865 #if @GNULIB_MBSPBRK@ |
799 /* Find the first occurrence in the character string STRING of any character | 866 /* Find the first occurrence in the character string STRING of any character |
800 in the character string ACCEPT. Return the pointer to it, or NULL if none | 867 in the character string ACCEPT. Return the pointer to it, or NULL if none |
801 exists. | 868 exists. |
802 Unlike strpbrk(), this function works correctly in multibyte locales. */ | 869 Unlike strpbrk(), this function works correctly in multibyte locales. */ |
803 # if defined __hpux | 870 # if defined __hpux |
804 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 871 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
805 # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ | 872 # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ |
806 # endif | 873 # endif |
807 _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) | 874 _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) |
| 875 _GL_ATTRIBUTE_PURE |
808 _GL_ARG_NONNULL ((1, 2))); | 876 _GL_ARG_NONNULL ((1, 2))); |
809 _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); | 877 _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); |
810 # else | 878 # else |
811 _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) | 879 _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) |
| 880 _GL_ATTRIBUTE_PURE |
812 _GL_ARG_NONNULL ((1, 2))); | 881 _GL_ARG_NONNULL ((1, 2))); |
813 _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); | 882 _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); |
814 # endif | 883 # endif |
815 _GL_CXXALIASWARN (mbspbrk); | 884 _GL_CXXALIASWARN (mbspbrk); |
816 #endif | 885 #endif |
817 | 886 |
818 #if @GNULIB_MBSSPN@ | 887 #if @GNULIB_MBSSPN@ |
819 /* Find the first occurrence in the character string STRING of any character | 888 /* Find the first occurrence in the character string STRING of any character |
820 not in the character string REJECT. Return the number of bytes from the | 889 not in the character string REJECT. Return the number of bytes from the |
821 beginning of the string to this occurrence, or to the end of the string | 890 beginning of the string to this occurrence, or to the end of the string |
822 if none exists. | 891 if none exists. |
823 Unlike strspn(), this function works correctly in multibyte locales. */ | 892 Unlike strspn(), this function works correctly in multibyte locales. */ |
824 _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject) | 893 _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject) |
| 894 _GL_ATTRIBUTE_PURE |
825 _GL_ARG_NONNULL ((1, 2)); | 895 _GL_ARG_NONNULL ((1, 2)); |
826 #endif | 896 #endif |
827 | 897 |
828 #if @GNULIB_MBSSEP@ | 898 #if @GNULIB_MBSSEP@ |
829 /* Search the next delimiter (multibyte character listed in the character | 899 /* Search the next delimiter (multibyte character listed in the character |
830 string DELIM) starting at the character string *STRINGP. | 900 string DELIM) starting at the character string *STRINGP. |
831 If one is found, overwrite it with a NUL, and advance *STRINGP to point | 901 If one is found, overwrite it with a NUL, and advance *STRINGP to point |
832 to the next multibyte character after it. Otherwise, set *STRINGP to NULL. | 902 to the next multibyte character after it. Otherwise, set *STRINGP to NULL. |
833 If *STRINGP was already NULL, nothing happens. | 903 If *STRINGP was already NULL, nothing happens. |
834 Return the old value of *STRINGP. | 904 Return the old value of *STRINGP. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 _GL_CXXALIAS_SYS (strerror, char *, (int)); | 948 _GL_CXXALIAS_SYS (strerror, char *, (int)); |
879 # endif | 949 # endif |
880 _GL_CXXALIASWARN (strerror); | 950 _GL_CXXALIASWARN (strerror); |
881 #elif defined GNULIB_POSIXCHECK | 951 #elif defined GNULIB_POSIXCHECK |
882 # undef strerror | 952 # undef strerror |
883 /* Assume strerror is always declared. */ | 953 /* Assume strerror is always declared. */ |
884 _GL_WARN_ON_USE (strerror, "strerror is unportable - " | 954 _GL_WARN_ON_USE (strerror, "strerror is unportable - " |
885 "use gnulib module strerror to guarantee non-NULL result"); | 955 "use gnulib module strerror to guarantee non-NULL result"); |
886 #endif | 956 #endif |
887 | 957 |
| 958 /* Map any int, typically from errno, into an error message. Multithread-safe. |
| 959 Uses the POSIX declaration, not the glibc declaration. */ |
| 960 #if @GNULIB_STRERROR_R@ |
| 961 # if @REPLACE_STRERROR_R@ |
| 962 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 963 # undef strerror_r |
| 964 # define strerror_r rpl_strerror_r |
| 965 # endif |
| 966 _GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) |
| 967 _GL_ARG_NONNULL ((2))); |
| 968 _GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); |
| 969 # else |
| 970 # if !@HAVE_DECL_STRERROR_R@ |
| 971 _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) |
| 972 _GL_ARG_NONNULL ((2))); |
| 973 # endif |
| 974 _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); |
| 975 # endif |
| 976 # if @HAVE_DECL_STRERROR_R@ |
| 977 _GL_CXXALIASWARN (strerror_r); |
| 978 # endif |
| 979 #elif defined GNULIB_POSIXCHECK |
| 980 # undef strerror_r |
| 981 # if HAVE_RAW_DECL_STRERROR_R |
| 982 _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " |
| 983 "use gnulib module strerror_r-posix for portability"); |
| 984 # endif |
| 985 #endif |
| 986 |
888 #if @GNULIB_STRSIGNAL@ | 987 #if @GNULIB_STRSIGNAL@ |
889 # if @REPLACE_STRSIGNAL@ | 988 # if @REPLACE_STRSIGNAL@ |
890 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 989 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
891 # define strsignal rpl_strsignal | 990 # define strsignal rpl_strsignal |
892 # endif | 991 # endif |
893 _GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); | 992 _GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); |
894 _GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); | 993 _GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); |
895 # else | 994 # else |
896 # if ! @HAVE_DECL_STRSIGNAL@ | 995 # if ! @HAVE_DECL_STRSIGNAL@ |
897 _GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); | 996 _GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); |
898 # endif | 997 # endif |
899 /* Need to cast, because on Cygwin 1.5.x systems, the return type is | 998 /* Need to cast, because on Cygwin 1.5.x systems, the return type is |
900 'const char *'. */ | 999 'const char *'. */ |
901 _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig)); | 1000 _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig)); |
902 # endif | 1001 # endif |
903 _GL_CXXALIASWARN (strsignal); | 1002 _GL_CXXALIASWARN (strsignal); |
904 #elif defined GNULIB_POSIXCHECK | 1003 #elif defined GNULIB_POSIXCHECK |
905 # undef strsignal | 1004 # undef strsignal |
906 # if HAVE_RAW_DECL_STRSIGNAL | 1005 # if HAVE_RAW_DECL_STRSIGNAL |
907 _GL_WARN_ON_USE (strsignal, "strsignal is unportable - " | 1006 _GL_WARN_ON_USE (strsignal, "strsignal is unportable - " |
908 "use gnulib module strsignal for portability"); | 1007 "use gnulib module strsignal for portability"); |
909 # endif | 1008 # endif |
910 #endif | 1009 #endif |
911 | 1010 |
912 #if @GNULIB_STRVERSCMP@ | 1011 #if @GNULIB_STRVERSCMP@ |
913 # if !@HAVE_STRVERSCMP@ | 1012 # if !@HAVE_STRVERSCMP@ |
914 _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) | 1013 _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) |
| 1014 _GL_ATTRIBUTE_PURE |
915 _GL_ARG_NONNULL ((1, 2))); | 1015 _GL_ARG_NONNULL ((1, 2))); |
916 # endif | 1016 # endif |
917 _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); | 1017 _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); |
918 _GL_CXXALIASWARN (strverscmp); | 1018 _GL_CXXALIASWARN (strverscmp); |
919 #elif defined GNULIB_POSIXCHECK | 1019 #elif defined GNULIB_POSIXCHECK |
920 # undef strverscmp | 1020 # undef strverscmp |
921 # if HAVE_RAW_DECL_STRVERSCMP | 1021 # if HAVE_RAW_DECL_STRVERSCMP |
922 _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " | 1022 _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " |
923 "use gnulib module strverscmp for portability"); | 1023 "use gnulib module strverscmp for portability"); |
924 # endif | 1024 # endif |
925 #endif | 1025 #endif |
926 | 1026 |
927 | 1027 |
928 #endif /* _GL_STRING_H */ | 1028 #endif /* _@GUARD_PREFIX@_STRING_H */ |
929 #endif /* _GL_STRING_H */ | 1029 #endif /* _@GUARD_PREFIX@_STRING_H */ |
OLD | NEW |