summaryrefslogtreecommitdiffstats
path: root/gl/string.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/string.in.h')
-rw-r--r--gl/string.in.h729
1 files changed, 521 insertions, 208 deletions
diff --git a/gl/string.in.h b/gl/string.in.h
index f021a3e..eb8d758 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-2008 Free Software Foundation, Inc. 3 Copyright (C) 1995-1996, 2001-2010 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
@@ -28,6 +28,13 @@
28#ifndef _GL_STRING_H 28#ifndef _GL_STRING_H
29#define _GL_STRING_H 29#define _GL_STRING_H
30 30
31/* NetBSD 5.0 mis-defines NULL. */
32#include <stddef.h>
33
34/* MirBSD defines mbslen as a macro. */
35#if @GNULIB_MBSLEN@ && defined __MirBSD__
36# include <wchar.h>
37#endif
31 38
32#ifndef __attribute__ 39#ifndef __attribute__
33/* This feature is available in gcc versions 2.5 and later. */ 40/* This feature is available in gcc versions 2.5 and later. */
@@ -41,60 +48,132 @@
41#endif 48#endif
42 49
43 50
44/* The definition of GL_LINK_WARNING is copied here. */ 51/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
45 52
46 53/* The definition of _GL_ARG_NONNULL is copied here. */
47#ifdef __cplusplus 54
48extern "C" { 55/* The definition of _GL_WARN_ON_USE is copied here. */
56
57
58/* Return the first instance of C within N bytes of S, or NULL. */
59#if @GNULIB_MEMCHR@
60# if @REPLACE_MEMCHR@
61# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
62# define memchr rpl_memchr
63# endif
64_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
65 __attribute__ ((__pure__))
66 _GL_ARG_NONNULL ((1)));
67_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
68# else
69# if ! @HAVE_MEMCHR@
70_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
71 __attribute__ ((__pure__))
72 _GL_ARG_NONNULL ((1)));
73# endif
74 /* On some systems, this function is defined as an overloaded function:
75 extern "C" { const void * std::memchr (const void *, int, size_t); }
76 extern "C++" { void * std::memchr (void *, int, size_t); } */
77_GL_CXXALIAS_SYS_CAST2 (memchr,
78 void *, (void const *__s, int __c, size_t __n),
79 void const *, (void const *__s, int __c, size_t __n));
80# endif
81# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
82 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
83_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
84_GL_CXXALIASWARN1 (memchr, void const *,
85 (void const *__s, int __c, size_t __n));
86# else
87_GL_CXXALIASWARN (memchr);
88# endif
89#elif defined GNULIB_POSIXCHECK
90# undef memchr
91/* Assume memchr is always declared. */
92_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
93 "use gnulib module memchr for portability" );
49#endif 94#endif
50 95
51
52/* Return the first occurrence of NEEDLE in HAYSTACK. */ 96/* Return the first occurrence of NEEDLE in HAYSTACK. */
53#if @GNULIB_MEMMEM@ 97#if @GNULIB_MEMMEM@
54# if @REPLACE_MEMMEM@ 98# if @REPLACE_MEMMEM@
55# define memmem rpl_memmem 99# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
56# endif 100# define memmem rpl_memmem
57# if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@ 101# endif
58extern void *memmem (void const *__haystack, size_t __haystack_len, 102_GL_FUNCDECL_RPL (memmem, void *,
59 void const *__needle, size_t __needle_len) 103 (void const *__haystack, size_t __haystack_len,
60 __attribute__ ((__pure__)); 104 void const *__needle, size_t __needle_len)
105 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3)));
106_GL_CXXALIAS_RPL (memmem, void *,
107 (void const *__haystack, size_t __haystack_len,
108 void const *__needle, size_t __needle_len));
109# else
110# if ! @HAVE_DECL_MEMMEM@
111_GL_FUNCDECL_SYS (memmem, void *,
112 (void const *__haystack, size_t __haystack_len,
113 void const *__needle, size_t __needle_len)
114 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3)));
115# endif
116_GL_CXXALIAS_SYS (memmem, void *,
117 (void const *__haystack, size_t __haystack_len,
118 void const *__needle, size_t __needle_len));
61# endif 119# endif
120_GL_CXXALIASWARN (memmem);
62#elif defined GNULIB_POSIXCHECK 121#elif defined GNULIB_POSIXCHECK
63# undef memmem 122# undef memmem
64# define memmem(a,al,b,bl) \ 123# if HAVE_RAW_DECL_MEMMEM
65 (GL_LINK_WARNING ("memmem is unportable and often quadratic - " \ 124_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
66 "use gnulib module memmem-simple for portability, " \ 125 "use gnulib module memmem-simple for portability, "
67 "and module memmem for speed" ), \ 126 "and module memmem for speed" );
68 memmem (a, al, b, bl)) 127# endif
69#endif 128#endif
70 129
71/* Copy N bytes of SRC to DEST, return pointer to bytes after the 130/* Copy N bytes of SRC to DEST, return pointer to bytes after the
72 last written byte. */ 131 last written byte. */
73#if @GNULIB_MEMPCPY@ 132#if @GNULIB_MEMPCPY@
74# if ! @HAVE_MEMPCPY@ 133# if ! @HAVE_MEMPCPY@
75extern void *mempcpy (void *restrict __dest, void const *restrict __src, 134_GL_FUNCDECL_SYS (mempcpy, void *,
76 size_t __n); 135 (void *restrict __dest, void const *restrict __src,
136 size_t __n)
137 _GL_ARG_NONNULL ((1, 2)));
77# endif 138# endif
139_GL_CXXALIAS_SYS (mempcpy, void *,
140 (void *restrict __dest, void const *restrict __src,
141 size_t __n));
142_GL_CXXALIASWARN (mempcpy);
78#elif defined GNULIB_POSIXCHECK 143#elif defined GNULIB_POSIXCHECK
79# undef mempcpy 144# undef mempcpy
80# define mempcpy(a,b,n) \ 145# if HAVE_RAW_DECL_MEMPCPY
81 (GL_LINK_WARNING ("mempcpy is unportable - " \ 146_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
82 "use gnulib module mempcpy for portability"), \ 147 "use gnulib module mempcpy for portability");
83 mempcpy (a, b, n)) 148# endif
84#endif 149#endif
85 150
86/* Search backwards through a block for a byte (specified as an int). */ 151/* Search backwards through a block for a byte (specified as an int). */
87#if @GNULIB_MEMRCHR@ 152#if @GNULIB_MEMRCHR@
88# if ! @HAVE_DECL_MEMRCHR@ 153# if ! @HAVE_DECL_MEMRCHR@
89extern void *memrchr (void const *, int, size_t) 154_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
90 __attribute__ ((__pure__)); 155 __attribute__ ((__pure__))
156 _GL_ARG_NONNULL ((1)));
157# endif
158 /* On some systems, this function is defined as an overloaded function:
159 extern "C++" { const void * std::memrchr (const void *, int, size_t); }
160 extern "C++" { void * std::memrchr (void *, int, size_t); } */
161_GL_CXXALIAS_SYS_CAST2 (memrchr,
162 void *, (void const *, int, size_t),
163 void const *, (void const *, int, size_t));
164# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
165 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
166_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
167_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
168# else
169_GL_CXXALIASWARN (memrchr);
91# endif 170# endif
92#elif defined GNULIB_POSIXCHECK 171#elif defined GNULIB_POSIXCHECK
93# undef memrchr 172# undef memrchr
94# define memrchr(a,b,c) \ 173# if HAVE_RAW_DECL_MEMRCHR
95 (GL_LINK_WARNING ("memrchr is unportable - " \ 174_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
96 "use gnulib module memrchr for portability"), \ 175 "use gnulib module memrchr for portability");
97 memrchr (a, b, c)) 176# endif
98#endif 177#endif
99 178
100/* Find the first occurrence of C in S. More efficient than 179/* Find the first occurrence of C in S. More efficient than
@@ -102,103 +181,191 @@ extern void *memrchr (void const *, int, size_t)
102 occur within N bytes. */ 181 occur within N bytes. */
103#if @GNULIB_RAWMEMCHR@ 182#if @GNULIB_RAWMEMCHR@
104# if ! @HAVE_RAWMEMCHR@ 183# if ! @HAVE_RAWMEMCHR@
105extern void *rawmemchr (void const *__s, int __c_in) 184_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
106 __attribute__ ((__pure__)); 185 __attribute__ ((__pure__))
186 _GL_ARG_NONNULL ((1)));
187# endif
188 /* On some systems, this function is defined as an overloaded function:
189 extern "C++" { const void * std::rawmemchr (const void *, int); }
190 extern "C++" { void * std::rawmemchr (void *, int); } */
191_GL_CXXALIAS_SYS_CAST2 (rawmemchr,
192 void *, (void const *__s, int __c_in),
193 void const *, (void const *__s, int __c_in));
194# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
195 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
196_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
197_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
198# else
199_GL_CXXALIASWARN (rawmemchr);
107# endif 200# endif
108#elif defined GNULIB_POSIXCHECK 201#elif defined GNULIB_POSIXCHECK
109# undef rawmemchr 202# undef rawmemchr
110# define rawmemchr(a,b) \ 203# if HAVE_RAW_DECL_RAWMEMCHR
111 (GL_LINK_WARNING ("rawmemchr is unportable - " \ 204_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
112 "use gnulib module rawmemchr for portability"), \ 205 "use gnulib module rawmemchr for portability");
113 rawmemchr (a, b)) 206# endif
114#endif 207#endif
115 208
116/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ 209/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
117#if @GNULIB_STPCPY@ 210#if @GNULIB_STPCPY@
118# if ! @HAVE_STPCPY@ 211# if ! @HAVE_STPCPY@
119extern char *stpcpy (char *restrict __dst, char const *restrict __src); 212_GL_FUNCDECL_SYS (stpcpy, char *,
213 (char *restrict __dst, char const *restrict __src)
214 _GL_ARG_NONNULL ((1, 2)));
120# endif 215# endif
216_GL_CXXALIAS_SYS (stpcpy, char *,
217 (char *restrict __dst, char const *restrict __src));
218_GL_CXXALIASWARN (stpcpy);
121#elif defined GNULIB_POSIXCHECK 219#elif defined GNULIB_POSIXCHECK
122# undef stpcpy 220# undef stpcpy
123# define stpcpy(a,b) \ 221# if HAVE_RAW_DECL_STPCPY
124 (GL_LINK_WARNING ("stpcpy is unportable - " \ 222_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
125 "use gnulib module stpcpy for portability"), \ 223 "use gnulib module stpcpy for portability");
126 stpcpy (a, b)) 224# endif
127#endif 225#endif
128 226
129/* Copy no more than N bytes of SRC to DST, returning a pointer past the 227/* Copy no more than N bytes of SRC to DST, returning a pointer past the
130 last non-NUL byte written into DST. */ 228 last non-NUL byte written into DST. */
131#if @GNULIB_STPNCPY@ 229#if @GNULIB_STPNCPY@
132# if ! @HAVE_STPNCPY@ 230# if @REPLACE_STPNCPY@
133# define stpncpy gnu_stpncpy 231# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
134extern char *stpncpy (char *restrict __dst, char const *restrict __src, 232# define stpncpy rpl_stpncpy
135 size_t __n); 233# endif
234_GL_FUNCDECL_RPL (stpncpy, char *,
235 (char *restrict __dst, char const *restrict __src,
236 size_t __n)
237 _GL_ARG_NONNULL ((1, 2)));
238_GL_CXXALIAS_RPL (stpncpy, char *,
239 (char *restrict __dst, char const *restrict __src,
240 size_t __n));
241# else
242# if ! @HAVE_STPNCPY@
243_GL_FUNCDECL_SYS (stpncpy, char *,
244 (char *restrict __dst, char const *restrict __src,
245 size_t __n)
246 _GL_ARG_NONNULL ((1, 2)));
247# endif
248_GL_CXXALIAS_SYS (stpncpy, char *,
249 (char *restrict __dst, char const *restrict __src,
250 size_t __n));
136# endif 251# endif
252_GL_CXXALIASWARN (stpncpy);
137#elif defined GNULIB_POSIXCHECK 253#elif defined GNULIB_POSIXCHECK
138# undef stpncpy 254# undef stpncpy
139# define stpncpy(a,b,n) \ 255# if HAVE_RAW_DECL_STPNCPY
140 (GL_LINK_WARNING ("stpncpy is unportable - " \ 256_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
141 "use gnulib module stpncpy for portability"), \ 257 "use gnulib module stpncpy for portability");
142 stpncpy (a, b, n)) 258# endif
143#endif 259#endif
144 260
145#if defined GNULIB_POSIXCHECK 261#if defined GNULIB_POSIXCHECK
146/* strchr() does not work with multibyte strings if the locale encoding is 262/* strchr() does not work with multibyte strings if the locale encoding is
147 GB18030 and the character to be searched is a digit. */ 263 GB18030 and the character to be searched is a digit. */
148# undef strchr 264# undef strchr
149# define strchr(s,c) \ 265/* Assume strchr is always declared. */
150 (GL_LINK_WARNING ("strchr cannot work correctly on character strings " \ 266_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
151 "in some multibyte locales - " \ 267 "in some multibyte locales - "
152 "use mbschr if you care about internationalization"), \ 268 "use mbschr if you care about internationalization");
153 strchr (s, c))
154#endif 269#endif
155 270
156/* Find the first occurrence of C in S or the final NUL byte. */ 271/* Find the first occurrence of C in S or the final NUL byte. */
157#if @GNULIB_STRCHRNUL@ 272#if @GNULIB_STRCHRNUL@
158# if ! @HAVE_STRCHRNUL@ 273# if ! @HAVE_STRCHRNUL@
159extern char *strchrnul (char const *__s, int __c_in) 274_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
160 __attribute__ ((__pure__)); 275 __attribute__ ((__pure__))
276 _GL_ARG_NONNULL ((1)));
277# endif
278 /* On some systems, this function is defined as an overloaded function:
279 extern "C++" { const char * std::strchrnul (const char *, int); }
280 extern "C++" { char * std::strchrnul (char *, int); } */
281_GL_CXXALIAS_SYS_CAST2 (strchrnul,
282 char *, (char const *__s, int __c_in),
283 char const *, (char const *__s, int __c_in));
284# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
285 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
286_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
287_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
288# else
289_GL_CXXALIASWARN (strchrnul);
161# endif 290# endif
162#elif defined GNULIB_POSIXCHECK 291#elif defined GNULIB_POSIXCHECK
163# undef strchrnul 292# undef strchrnul
164# define strchrnul(a,b) \ 293# if HAVE_RAW_DECL_STRCHRNUL
165 (GL_LINK_WARNING ("strchrnul is unportable - " \ 294_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
166 "use gnulib module strchrnul for portability"), \ 295 "use gnulib module strchrnul for portability");
167 strchrnul (a, b)) 296# endif
168#endif 297#endif
169 298
170/* Duplicate S, returning an identical malloc'd string. */ 299/* Duplicate S, returning an identical malloc'd string. */
171#if @GNULIB_STRDUP@ 300#if @GNULIB_STRDUP@
172# if @REPLACE_STRDUP@ 301# if @REPLACE_STRDUP@
173# undef strdup 302# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
174# define strdup rpl_strdup 303# undef strdup
175# endif 304# define strdup rpl_strdup
176# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@ 305# endif
177extern char *strdup (char const *__s); 306_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
307_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
308# else
309# if !(@HAVE_DECL_STRDUP@ || defined strdup)
310_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
311# endif
312_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
178# endif 313# endif
314_GL_CXXALIASWARN (strdup);
179#elif defined GNULIB_POSIXCHECK 315#elif defined GNULIB_POSIXCHECK
180# undef strdup 316# undef strdup
181# define strdup(a) \ 317# if HAVE_RAW_DECL_STRDUP
182 (GL_LINK_WARNING ("strdup is unportable - " \ 318_GL_WARN_ON_USE (strdup, "strdup is unportable - "
183 "use gnulib module strdup for portability"), \ 319 "use gnulib module strdup for portability");
184 strdup (a)) 320# endif
321#endif
322
323/* Append no more than N characters from SRC onto DEST. */
324#if @GNULIB_STRNCAT@
325# if @REPLACE_STRNCAT@
326# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
327# undef strncat
328# define strncat rpl_strncat
329# endif
330_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
331 _GL_ARG_NONNULL ((1, 2)));
332_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
333# else
334_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
335# endif
336_GL_CXXALIASWARN (strncat);
337#elif defined GNULIB_POSIXCHECK
338# undef strncat
339# if HAVE_RAW_DECL_STRNCAT
340_GL_WARN_ON_USE (strncat, "strncat is unportable - "
341 "use gnulib module strncat for portability");
342# endif
185#endif 343#endif
186 344
187/* Return a newly allocated copy of at most N bytes of STRING. */ 345/* Return a newly allocated copy of at most N bytes of STRING. */
188#if @GNULIB_STRNDUP@ 346#if @GNULIB_STRNDUP@
189# if ! @HAVE_STRNDUP@ 347# if @REPLACE_STRNDUP@
190# undef strndup 348# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
191# define strndup rpl_strndup 349# undef strndup
192# endif 350# define strndup rpl_strndup
193# if ! @HAVE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@ 351# endif
194extern char *strndup (char const *__string, size_t __n); 352_GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n)
353 _GL_ARG_NONNULL ((1)));
354_GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n));
355# else
356# if ! @HAVE_DECL_STRNDUP@
357_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
358 _GL_ARG_NONNULL ((1)));
359# endif
360_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
195# endif 361# endif
362_GL_CXXALIASWARN (strndup);
196#elif defined GNULIB_POSIXCHECK 363#elif defined GNULIB_POSIXCHECK
197# undef strndup 364# undef strndup
198# define strndup(a,n) \ 365# if HAVE_RAW_DECL_STRNDUP
199 (GL_LINK_WARNING ("strndup is unportable - " \ 366_GL_WARN_ON_USE (strndup, "strndup is unportable - "
200 "use gnulib module strndup for portability"), \ 367 "use gnulib module strndup for portability");
201 strndup (a, n)) 368# endif
202#endif 369#endif
203 370
204/* Find the length (number of bytes) of STRING, but scan at most 371/* Find the length (number of bytes) of STRING, but scan at most
@@ -206,15 +373,18 @@ extern char *strndup (char const *__string, size_t __n);
206 return MAXLEN. */ 373 return MAXLEN. */
207#if @GNULIB_STRNLEN@ 374#if @GNULIB_STRNLEN@
208# if ! @HAVE_DECL_STRNLEN@ 375# if ! @HAVE_DECL_STRNLEN@
209extern size_t strnlen (char const *__string, size_t __maxlen) 376_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
210 __attribute__ ((__pure__)); 377 __attribute__ ((__pure__))
378 _GL_ARG_NONNULL ((1)));
211# endif 379# endif
380_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
381_GL_CXXALIASWARN (strnlen);
212#elif defined GNULIB_POSIXCHECK 382#elif defined GNULIB_POSIXCHECK
213# undef strnlen 383# undef strnlen
214# define strnlen(a,n) \ 384# if HAVE_RAW_DECL_STRNLEN
215 (GL_LINK_WARNING ("strnlen is unportable - " \ 385_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
216 "use gnulib module strnlen for portability"), \ 386 "use gnulib module strnlen for portability");
217 strnlen (a, n)) 387# endif
218#endif 388#endif
219 389
220#if defined GNULIB_POSIXCHECK 390#if defined GNULIB_POSIXCHECK
@@ -223,18 +393,32 @@ extern size_t strnlen (char const *__string, size_t __maxlen)
223 locale encoding is GB18030 and one of the characters to be searched is a 393 locale encoding is GB18030 and one of the characters to be searched is a
224 digit. */ 394 digit. */
225# undef strcspn 395# undef strcspn
226# define strcspn(s,a) \ 396/* Assume strcspn is always declared. */
227 (GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \ 397_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
228 "in multibyte locales - " \ 398 "in multibyte locales - "
229 "use mbscspn if you care about internationalization"), \ 399 "use mbscspn if you care about internationalization");
230 strcspn (s, a))
231#endif 400#endif
232 401
233/* Find the first occurrence in S of any character in ACCEPT. */ 402/* Find the first occurrence in S of any character in ACCEPT. */
234#if @GNULIB_STRPBRK@ 403#if @GNULIB_STRPBRK@
235# if ! @HAVE_STRPBRK@ 404# if ! @HAVE_STRPBRK@
236extern char *strpbrk (char const *__s, char const *__accept) 405_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
237 __attribute__ ((__pure__)); 406 __attribute__ ((__pure__))
407 _GL_ARG_NONNULL ((1, 2)));
408# endif
409 /* On some systems, this function is defined as an overloaded function:
410 extern "C" { const char * strpbrk (const char *, const char *); }
411 extern "C++" { char * strpbrk (char *, const char *); } */
412_GL_CXXALIAS_SYS_CAST2 (strpbrk,
413 char *, (char const *__s, char const *__accept),
414 const char *, (char const *__s, char const *__accept));
415# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
416 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
417_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
418_GL_CXXALIASWARN1 (strpbrk, char const *,
419 (char const *__s, char const *__accept));
420# else
421_GL_CXXALIASWARN (strpbrk);
238# endif 422# endif
239# if defined GNULIB_POSIXCHECK 423# if defined GNULIB_POSIXCHECK
240/* strpbrk() assumes the second argument is a list of single-byte characters. 424/* strpbrk() assumes the second argument is a list of single-byte characters.
@@ -242,40 +426,36 @@ extern char *strpbrk (char const *__s, char const *__accept)
242 locale encoding is GB18030 and one of the characters to be searched is a 426 locale encoding is GB18030 and one of the characters to be searched is a
243 digit. */ 427 digit. */
244# undef strpbrk 428# undef strpbrk
245# define strpbrk(s,a) \ 429_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
246 (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \ 430 "in multibyte locales - "
247 "in multibyte locales - " \ 431 "use mbspbrk if you care about internationalization");
248 "use mbspbrk if you care about internationalization"), \
249 strpbrk (s, a))
250# endif 432# endif
251#elif defined GNULIB_POSIXCHECK 433#elif defined GNULIB_POSIXCHECK
252# undef strpbrk 434# undef strpbrk
253# define strpbrk(s,a) \ 435# if HAVE_RAW_DECL_STRPBRK
254 (GL_LINK_WARNING ("strpbrk is unportable - " \ 436_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
255 "use gnulib module strpbrk for portability"), \ 437 "use gnulib module strpbrk for portability");
256 strpbrk (s, a)) 438# endif
257#endif 439#endif
258 440
259#if defined GNULIB_POSIXCHECK 441#if defined GNULIB_POSIXCHECK
260/* strspn() assumes the second argument is a list of single-byte characters. 442/* strspn() assumes the second argument is a list of single-byte characters.
261 Even in this simple case, it cannot work with multibyte strings. */ 443 Even in this simple case, it cannot work with multibyte strings. */
262# undef strspn 444# undef strspn
263# define strspn(s,a) \ 445/* Assume strspn is always declared. */
264 (GL_LINK_WARNING ("strspn cannot work correctly on character strings " \ 446_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
265 "in multibyte locales - " \ 447 "in multibyte locales - "
266 "use mbsspn if you care about internationalization"), \ 448 "use mbsspn if you care about internationalization");
267 strspn (s, a))
268#endif 449#endif
269 450
270#if defined GNULIB_POSIXCHECK 451#if defined GNULIB_POSIXCHECK
271/* strrchr() does not work with multibyte strings if the locale encoding is 452/* strrchr() does not work with multibyte strings if the locale encoding is
272 GB18030 and the character to be searched is a digit. */ 453 GB18030 and the character to be searched is a digit. */
273# undef strrchr 454# undef strrchr
274# define strrchr(s,c) \ 455/* Assume strrchr is always declared. */
275 (GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \ 456_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
276 "in some multibyte locales - " \ 457 "in some multibyte locales - "
277 "use mbsrchr if you care about internationalization"), \ 458 "use mbsrchr if you care about internationalization");
278 strrchr (s, c))
279#endif 459#endif
280 460
281/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. 461/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
@@ -296,29 +476,51 @@ extern char *strpbrk (char const *__s, char const *__accept)
296 See also strtok_r(). */ 476 See also strtok_r(). */
297#if @GNULIB_STRSEP@ 477#if @GNULIB_STRSEP@
298# if ! @HAVE_STRSEP@ 478# if ! @HAVE_STRSEP@
299extern char *strsep (char **restrict __stringp, char const *restrict __delim); 479_GL_FUNCDECL_SYS (strsep, char *,
480 (char **restrict __stringp, char const *restrict __delim)
481 _GL_ARG_NONNULL ((1, 2)));
300# endif 482# endif
483_GL_CXXALIAS_SYS (strsep, char *,
484 (char **restrict __stringp, char const *restrict __delim));
485_GL_CXXALIASWARN (strsep);
301# if defined GNULIB_POSIXCHECK 486# if defined GNULIB_POSIXCHECK
302# undef strsep 487# undef strsep
303# define strsep(s,d) \ 488_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
304 (GL_LINK_WARNING ("strsep cannot work correctly on character strings " \ 489 "in multibyte locales - "
305 "in multibyte locales - " \ 490 "use mbssep if you care about internationalization");
306 "use mbssep if you care about internationalization"), \
307 strsep (s, d))
308# endif 491# endif
309#elif defined GNULIB_POSIXCHECK 492#elif defined GNULIB_POSIXCHECK
310# undef strsep 493# undef strsep
311# define strsep(s,d) \ 494# if HAVE_RAW_DECL_STRSEP
312 (GL_LINK_WARNING ("strsep is unportable - " \ 495_GL_WARN_ON_USE (strsep, "strsep is unportable - "
313 "use gnulib module strsep for portability"), \ 496 "use gnulib module strsep for portability");
314 strsep (s, d)) 497# endif
315#endif 498#endif
316 499
317#if @GNULIB_STRSTR@ 500#if @GNULIB_STRSTR@
318# if @REPLACE_STRSTR@ 501# if @REPLACE_STRSTR@
319# define strstr rpl_strstr 502# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
320char *strstr (const char *haystack, const char *needle) 503# define strstr rpl_strstr
321 __attribute__ ((__pure__)); 504# endif
505_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
506 __attribute__ ((__pure__))
507 _GL_ARG_NONNULL ((1, 2)));
508_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
509# else
510 /* On some systems, this function is defined as an overloaded function:
511 extern "C++" { const char * strstr (const char *, const char *); }
512 extern "C++" { char * strstr (char *, const char *); } */
513_GL_CXXALIAS_SYS_CAST2 (strstr,
514 char *, (const char *haystack, const char *needle),
515 const char *, (const char *haystack, const char *needle));
516# endif
517# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
518 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
519_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
520_GL_CXXALIASWARN1 (strstr, const char *,
521 (const char *haystack, const char *needle));
522# else
523_GL_CXXALIASWARN (strstr);
322# endif 524# endif
323#elif defined GNULIB_POSIXCHECK 525#elif defined GNULIB_POSIXCHECK
324/* strstr() does not work with multibyte strings if the locale encoding is 526/* strstr() does not work with multibyte strings if the locale encoding is
@@ -326,48 +528,70 @@ char *strstr (const char *haystack, const char *needle)
326 POSIX says that it operates on "strings", and "string" in POSIX is defined 528 POSIX says that it operates on "strings", and "string" in POSIX is defined
327 as a sequence of bytes, not of characters. */ 529 as a sequence of bytes, not of characters. */
328# undef strstr 530# undef strstr
329# define strstr(a,b) \ 531/* Assume strstr is always declared. */
330 (GL_LINK_WARNING ("strstr is quadratic on many systems, and cannot " \ 532_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
331 "work correctly on character strings in most " \ 533 "work correctly on character strings in most "
332 "multibyte locales - " \ 534 "multibyte locales - "
333 "use mbsstr if you care about internationalization, " \ 535 "use mbsstr if you care about internationalization, "
334 "or use strstr if you care about speed"), \ 536 "or use strstr if you care about speed");
335 strstr (a, b))
336#endif 537#endif
337 538
338/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive 539/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
339 comparison. */ 540 comparison. */
340#if @GNULIB_STRCASESTR@ 541#if @GNULIB_STRCASESTR@
341# if @REPLACE_STRCASESTR@ 542# if @REPLACE_STRCASESTR@
342# define strcasestr rpl_strcasestr 543# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
544# define strcasestr rpl_strcasestr
545# endif
546_GL_FUNCDECL_RPL (strcasestr, char *,
547 (const char *haystack, const char *needle)
548 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)));
549_GL_CXXALIAS_RPL (strcasestr, char *,
550 (const char *haystack, const char *needle));
551# else
552# if ! @HAVE_STRCASESTR@
553_GL_FUNCDECL_SYS (strcasestr, char *,
554 (const char *haystack, const char *needle)
555 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)));
556# endif
557 /* On some systems, this function is defined as an overloaded function:
558 extern "C++" { const char * strcasestr (const char *, const char *); }
559 extern "C++" { char * strcasestr (char *, const char *); } */
560_GL_CXXALIAS_SYS_CAST2 (strcasestr,
561 char *, (const char *haystack, const char *needle),
562 const char *, (const char *haystack, const char *needle));
343# endif 563# endif
344# if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@ 564# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
345extern char *strcasestr (const char *haystack, const char *needle) 565 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
346 __attribute__ ((__pure__)); 566_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
567_GL_CXXALIASWARN1 (strcasestr, const char *,
568 (const char *haystack, const char *needle));
569# else
570_GL_CXXALIASWARN (strcasestr);
347# endif 571# endif
348#elif defined GNULIB_POSIXCHECK 572#elif defined GNULIB_POSIXCHECK
349/* strcasestr() does not work with multibyte strings: 573/* strcasestr() does not work with multibyte strings:
350 It is a glibc extension, and glibc implements it only for unibyte 574 It is a glibc extension, and glibc implements it only for unibyte
351 locales. */ 575 locales. */
352# undef strcasestr 576# undef strcasestr
353# define strcasestr(a,b) \ 577# if HAVE_RAW_DECL_STRCASESTR
354 (GL_LINK_WARNING ("strcasestr does work correctly on character strings " \ 578_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
355 "in multibyte locales - " \ 579 "strings in multibyte locales - "
356 "use mbscasestr if you care about " \ 580 "use mbscasestr if you care about "
357 "internationalization, or use c-strcasestr if you want " \ 581 "internationalization, or use c-strcasestr if you want "
358 "a locale independent function"), \ 582 "a locale independent function");
359 strcasestr (a, b)) 583# endif
360#endif 584#endif
361 585
362/* Parse S into tokens separated by characters in DELIM. 586/* Parse S into tokens separated by characters in DELIM.
363 If S is NULL, the saved pointer in SAVE_PTR is used as 587 If S is NULL, the saved pointer in SAVE_PTR is used as
364 the next starting point. For example: 588 the next starting point. For example:
365 char s[] = "-abc-=-def"; 589 char s[] = "-abc-=-def";
366 char *sp; 590 char *sp;
367 x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" 591 x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
368 x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL 592 x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
369 x = strtok_r(NULL, "=", &sp); // x = NULL 593 x = strtok_r(NULL, "=", &sp); // x = NULL
370 // s = "abc\0-def\0" 594 // s = "abc\0-def\0"
371 595
372 This is a variant of strtok() that is multithread-safe. 596 This is a variant of strtok() that is multithread-safe.
373 597
@@ -382,24 +606,44 @@ extern char *strcasestr (const char *haystack, const char *needle)
382 606
383 See also strsep(). */ 607 See also strsep(). */
384#if @GNULIB_STRTOK_R@ 608#if @GNULIB_STRTOK_R@
385# if ! @HAVE_DECL_STRTOK_R@ 609# if @REPLACE_STRTOK_R@
386extern char *strtok_r (char *restrict s, char const *restrict delim, 610# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
387 char **restrict save_ptr); 611# undef strtok_r
612# define strtok_r rpl_strtok_r
613# endif
614_GL_FUNCDECL_RPL (strtok_r, char *,
615 (char *restrict s, char const *restrict delim,
616 char **restrict save_ptr)
617 _GL_ARG_NONNULL ((2, 3)));
618_GL_CXXALIAS_RPL (strtok_r, char *,
619 (char *restrict s, char const *restrict delim,
620 char **restrict save_ptr));
621# else
622# if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
623# undef strtok_r
624# endif
625# if ! @HAVE_DECL_STRTOK_R@
626_GL_FUNCDECL_SYS (strtok_r, char *,
627 (char *restrict s, char const *restrict delim,
628 char **restrict save_ptr)
629 _GL_ARG_NONNULL ((2, 3)));
630# endif
631_GL_CXXALIAS_SYS (strtok_r, char *,
632 (char *restrict s, char const *restrict delim,
633 char **restrict save_ptr));
388# endif 634# endif
635_GL_CXXALIASWARN (strtok_r);
389# if defined GNULIB_POSIXCHECK 636# if defined GNULIB_POSIXCHECK
390# undef strtok_r 637_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
391# define strtok_r(s,d,p) \ 638 "strings in multibyte locales - "
392 (GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \ 639 "use mbstok_r if you care about internationalization");
393 "in multibyte locales - " \
394 "use mbstok_r if you care about internationalization"), \
395 strtok_r (s, d, p))
396# endif 640# endif
397#elif defined GNULIB_POSIXCHECK 641#elif defined GNULIB_POSIXCHECK
398# undef strtok_r 642# undef strtok_r
399# define strtok_r(s,d,p) \ 643# if HAVE_RAW_DECL_STRTOK_R
400 (GL_LINK_WARNING ("strtok_r is unportable - " \ 644_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
401 "use gnulib module strtok_r for portability"), \ 645 "use gnulib module strtok_r for portability");
402 strtok_r (s, d, p)) 646# endif
403#endif 647#endif
404 648
405 649
@@ -409,13 +653,27 @@ extern char *strtok_r (char *restrict s, char const *restrict delim,
409#if @GNULIB_MBSLEN@ 653#if @GNULIB_MBSLEN@
410/* Return the number of multibyte characters in the character string STRING. 654/* Return the number of multibyte characters in the character string STRING.
411 This considers multibyte characters, unlike strlen, which counts bytes. */ 655 This considers multibyte characters, unlike strlen, which counts bytes. */
412extern size_t mbslen (const char *string); 656# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
657# undef mbslen
658# endif
659# if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */
660# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
661# define mbslen rpl_mbslen
662# endif
663_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
664_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
665# else
666_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
667_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
668# endif
669_GL_CXXALIASWARN (mbslen);
413#endif 670#endif
414 671
415#if @GNULIB_MBSNLEN@ 672#if @GNULIB_MBSNLEN@
416/* Return the number of multibyte characters in the character string starting 673/* Return the number of multibyte characters in the character string starting
417 at STRING and ending at STRING + LEN. */ 674 at STRING and ending at STRING + LEN. */
418extern size_t mbsnlen (const char *string, size_t len); 675_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
676 _GL_ARG_NONNULL ((1));
419#endif 677#endif
420 678
421#if @GNULIB_MBSCHR@ 679#if @GNULIB_MBSCHR@
@@ -423,8 +681,19 @@ extern size_t mbsnlen (const char *string, size_t len);
423 and return a pointer to it. Return NULL if C is not found in STRING. 681 and return a pointer to it. Return NULL if C is not found in STRING.
424 Unlike strchr(), this function works correctly in multibyte locales with 682 Unlike strchr(), this function works correctly in multibyte locales with
425 encodings such as GB18030. */ 683 encodings such as GB18030. */
426# define mbschr rpl_mbschr /* avoid collision with HP-UX function */ 684# if defined __hpux
427extern char * mbschr (const char *string, int c); 685# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
686# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
687# endif
688_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
689 _GL_ARG_NONNULL ((1)));
690_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
691# else
692_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
693 _GL_ARG_NONNULL ((1)));
694_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
695# endif
696_GL_CXXALIASWARN (mbschr);
428#endif 697#endif
429 698
430#if @GNULIB_MBSRCHR@ 699#if @GNULIB_MBSRCHR@
@@ -432,8 +701,19 @@ extern char * mbschr (const char *string, int c);
432 and return a pointer to it. Return NULL if C is not found in STRING. 701 and return a pointer to it. Return NULL if C is not found in STRING.
433 Unlike strrchr(), this function works correctly in multibyte locales with 702 Unlike strrchr(), this function works correctly in multibyte locales with
434 encodings such as GB18030. */ 703 encodings such as GB18030. */
435# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */ 704# if defined __hpux
436extern char * mbsrchr (const char *string, int c); 705# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
706# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
707# endif
708_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
709 _GL_ARG_NONNULL ((1)));
710_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
711# else
712_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
713 _GL_ARG_NONNULL ((1)));
714_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
715# endif
716_GL_CXXALIASWARN (mbsrchr);
437#endif 717#endif
438 718
439#if @GNULIB_MBSSTR@ 719#if @GNULIB_MBSSTR@
@@ -441,7 +721,8 @@ extern char * mbsrchr (const char *string, int c);
441 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. 721 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
442 Unlike strstr(), this function works correctly in multibyte locales with 722 Unlike strstr(), this function works correctly in multibyte locales with
443 encodings different from UTF-8. */ 723 encodings different from UTF-8. */
444extern char * mbsstr (const char *haystack, const char *needle); 724_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
725 _GL_ARG_NONNULL ((1, 2));
445#endif 726#endif
446 727
447#if @GNULIB_MBSCASECMP@ 728#if @GNULIB_MBSCASECMP@
@@ -451,7 +732,8 @@ extern char * mbsstr (const char *haystack, const char *needle);
451 Note: This function may, in multibyte locales, return 0 for strings of 732 Note: This function may, in multibyte locales, return 0 for strings of
452 different lengths! 733 different lengths!
453 Unlike strcasecmp(), this function works correctly in multibyte locales. */ 734 Unlike strcasecmp(), this function works correctly in multibyte locales. */
454extern int mbscasecmp (const char *s1, const char *s2); 735_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
736 _GL_ARG_NONNULL ((1, 2));
455#endif 737#endif
456 738
457#if @GNULIB_MBSNCASECMP@ 739#if @GNULIB_MBSNCASECMP@
@@ -464,7 +746,8 @@ extern int mbscasecmp (const char *s1, const char *s2);
464 of different lengths! 746 of different lengths!
465 Unlike strncasecmp(), this function works correctly in multibyte locales. 747 Unlike strncasecmp(), this function works correctly in multibyte locales.
466 But beware that N is not a byte count but a character count! */ 748 But beware that N is not a byte count but a character count! */
467extern int mbsncasecmp (const char *s1, const char *s2, size_t n); 749_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
750 _GL_ARG_NONNULL ((1, 2));
468#endif 751#endif
469 752
470#if @GNULIB_MBSPCASECMP@ 753#if @GNULIB_MBSPCASECMP@
@@ -477,7 +760,8 @@ extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
477 smaller length than PREFIX! 760 smaller length than PREFIX!
478 Unlike strncasecmp(), this function works correctly in multibyte 761 Unlike strncasecmp(), this function works correctly in multibyte
479 locales. */ 762 locales. */
480extern char * mbspcasecmp (const char *string, const char *prefix); 763_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
764 _GL_ARG_NONNULL ((1, 2));
481#endif 765#endif
482 766
483#if @GNULIB_MBSCASESTR@ 767#if @GNULIB_MBSCASESTR@
@@ -486,7 +770,8 @@ extern char * mbspcasecmp (const char *string, const char *prefix);
486 Note: This function may, in multibyte locales, return success even if 770 Note: This function may, in multibyte locales, return success even if
487 strlen (haystack) < strlen (needle) ! 771 strlen (haystack) < strlen (needle) !
488 Unlike strcasestr(), this function works correctly in multibyte locales. */ 772 Unlike strcasestr(), this function works correctly in multibyte locales. */
489extern char * mbscasestr (const char *haystack, const char *needle); 773_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
774 _GL_ARG_NONNULL ((1, 2));
490#endif 775#endif
491 776
492#if @GNULIB_MBSCSPN@ 777#if @GNULIB_MBSCSPN@
@@ -495,7 +780,8 @@ extern char * mbscasestr (const char *haystack, const char *needle);
495 beginning of the string to this occurrence, or to the end of the string 780 beginning of the string to this occurrence, or to the end of the string
496 if none exists. 781 if none exists.
497 Unlike strcspn(), this function works correctly in multibyte locales. */ 782 Unlike strcspn(), this function works correctly in multibyte locales. */
498extern size_t mbscspn (const char *string, const char *accept); 783_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
784 _GL_ARG_NONNULL ((1, 2));
499#endif 785#endif
500 786
501#if @GNULIB_MBSPBRK@ 787#if @GNULIB_MBSPBRK@
@@ -503,8 +789,19 @@ extern size_t mbscspn (const char *string, const char *accept);
503 in the character string ACCEPT. Return the pointer to it, or NULL if none 789 in the character string ACCEPT. Return the pointer to it, or NULL if none
504 exists. 790 exists.
505 Unlike strpbrk(), this function works correctly in multibyte locales. */ 791 Unlike strpbrk(), this function works correctly in multibyte locales. */
506# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ 792# if defined __hpux
507extern char * mbspbrk (const char *string, const char *accept); 793# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
794# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
795# endif
796_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
797 _GL_ARG_NONNULL ((1, 2)));
798_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
799# else
800_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
801 _GL_ARG_NONNULL ((1, 2)));
802_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
803# endif
804_GL_CXXALIASWARN (mbspbrk);
508#endif 805#endif
509 806
510#if @GNULIB_MBSSPN@ 807#if @GNULIB_MBSSPN@
@@ -513,7 +810,8 @@ extern char * mbspbrk (const char *string, const char *accept);
513 beginning of the string to this occurrence, or to the end of the string 810 beginning of the string to this occurrence, or to the end of the string
514 if none exists. 811 if none exists.
515 Unlike strspn(), this function works correctly in multibyte locales. */ 812 Unlike strspn(), this function works correctly in multibyte locales. */
516extern size_t mbsspn (const char *string, const char *reject); 813_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
814 _GL_ARG_NONNULL ((1, 2));
517#endif 815#endif
518 816
519#if @GNULIB_MBSSEP@ 817#if @GNULIB_MBSSEP@
@@ -531,7 +829,8 @@ extern size_t mbsspn (const char *string, const char *reject);
531 Caveat: The identity of the delimiting character is lost. 829 Caveat: The identity of the delimiting character is lost.
532 830
533 See also mbstok_r(). */ 831 See also mbstok_r(). */
534extern char * mbssep (char **stringp, const char *delim); 832_GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
833 _GL_ARG_NONNULL ((1, 2));
535#endif 834#endif
536 835
537#if @GNULIB_MBSTOK_R@ 836#if @GNULIB_MBSTOK_R@
@@ -539,67 +838,81 @@ extern char * mbssep (char **stringp, const char *delim);
539 the character string DELIM. 838 the character string DELIM.
540 If STRING is NULL, the saved pointer in SAVE_PTR is used as 839 If STRING is NULL, the saved pointer in SAVE_PTR is used as
541 the next starting point. For example: 840 the next starting point. For example:
542 char s[] = "-abc-=-def"; 841 char s[] = "-abc-=-def";
543 char *sp; 842 char *sp;
544 x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" 843 x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
545 x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL 844 x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
546 x = mbstok_r(NULL, "=", &sp); // x = NULL 845 x = mbstok_r(NULL, "=", &sp); // x = NULL
547 // s = "abc\0-def\0" 846 // s = "abc\0-def\0"
548 847
549 Caveat: It modifies the original string. 848 Caveat: It modifies the original string.
550 Caveat: These functions cannot be used on constant strings. 849 Caveat: These functions cannot be used on constant strings.
551 Caveat: The identity of the delimiting character is lost. 850 Caveat: The identity of the delimiting character is lost.
552 851
553 See also mbssep(). */ 852 See also mbssep(). */
554extern char * mbstok_r (char *string, const char *delim, char **save_ptr); 853_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
854 _GL_ARG_NONNULL ((2, 3));
555#endif 855#endif
556 856
557/* Map any int, typically from errno, into an error message. */ 857/* Map any int, typically from errno, into an error message. */
558#if @GNULIB_STRERROR@ 858#if @GNULIB_STRERROR@
559# if @REPLACE_STRERROR@ 859# if @REPLACE_STRERROR@
560# undef strerror 860# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
561# define strerror rpl_strerror 861# undef strerror
562extern char *strerror (int); 862# define strerror rpl_strerror
863# endif
864_GL_FUNCDECL_RPL (strerror, char *, (int));
865_GL_CXXALIAS_RPL (strerror, char *, (int));
866# else
867_GL_CXXALIAS_SYS (strerror, char *, (int));
563# endif 868# endif
869_GL_CXXALIASWARN (strerror);
564#elif defined GNULIB_POSIXCHECK 870#elif defined GNULIB_POSIXCHECK
565# undef strerror 871# undef strerror
566# define strerror(e) \ 872/* Assume strerror is always declared. */
567 (GL_LINK_WARNING ("strerror is unportable - " \ 873_GL_WARN_ON_USE (strerror, "strerror is unportable - "
568 "use gnulib module strerror to guarantee non-NULL result"), \ 874 "use gnulib module strerror to guarantee non-NULL result");
569 strerror (e))
570#endif 875#endif
571 876
572#if @GNULIB_STRSIGNAL@ 877#if @GNULIB_STRSIGNAL@
573# if @REPLACE_STRSIGNAL@ 878# if @REPLACE_STRSIGNAL@
574# define strsignal rpl_strsignal 879# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
575# endif 880# define strsignal rpl_strsignal
576# if ! @HAVE_DECL_STRSIGNAL@ || @REPLACE_STRSIGNAL@ 881# endif
577extern char *strsignal (int __sig); 882_GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
883_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
884# else
885# if ! @HAVE_DECL_STRSIGNAL@
886_GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
887# endif
888/* Need to cast, because on Cygwin 1.5.x systems, the return type is
889 'const char *'. */
890_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
578# endif 891# endif
892_GL_CXXALIASWARN (strsignal);
579#elif defined GNULIB_POSIXCHECK 893#elif defined GNULIB_POSIXCHECK
580# undef strsignal 894# undef strsignal
581# define strsignal(a) \ 895# if HAVE_RAW_DECL_STRSIGNAL
582 (GL_LINK_WARNING ("strsignal is unportable - " \ 896_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
583 "use gnulib module strsignal for portability"), \ 897 "use gnulib module strsignal for portability");
584 strsignal (a)) 898# endif
585#endif 899#endif
586 900
587#if @GNULIB_STRVERSCMP@ 901#if @GNULIB_STRVERSCMP@
588# if !@HAVE_STRVERSCMP@ 902# if !@HAVE_STRVERSCMP@
589extern int strverscmp (const char *, const char *); 903_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
904 _GL_ARG_NONNULL ((1, 2)));
590# endif 905# endif
906_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
907_GL_CXXALIASWARN (strverscmp);
591#elif defined GNULIB_POSIXCHECK 908#elif defined GNULIB_POSIXCHECK
592# undef strverscmp 909# undef strverscmp
593# define strverscmp(a, b) \ 910# if HAVE_RAW_DECL_STRVERSCMP
594 (GL_LINK_WARNING ("strverscmp is unportable - " \ 911_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
595 "use gnulib module strverscmp for portability"), \ 912 "use gnulib module strverscmp for portability");
596 strverscmp (a, b)) 913# endif
597#endif 914#endif
598 915
599 916
600#ifdef __cplusplus
601}
602#endif
603
604#endif /* _GL_STRING_H */ 917#endif /* _GL_STRING_H */
605#endif /* _GL_STRING_H */ 918#endif /* _GL_STRING_H */