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.h196
1 files changed, 148 insertions, 48 deletions
diff --git a/gl/string.in.h b/gl/string.in.h
index 13c0f09..d7a6c9c 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-2010 Free Software Foundation, Inc. 3 Copyright (C) 1995-1996, 2001-2013 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
@@ -13,20 +13,20 @@
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>
@@ -36,17 +36,20 @@
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
@@ -55,6 +58,36 @@
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@
@@ -62,13 +95,13 @@
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:
@@ -78,7 +111,7 @@ _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 *,
@@ -102,7 +135,8 @@ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
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));
@@ -111,7 +145,8 @@ _GL_CXXALIAS_RPL (memmem, void *,
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,
@@ -152,7 +187,7 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
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:
@@ -161,7 +196,7 @@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, 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));
@@ -182,7 +217,7 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
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:
@@ -191,7 +226,7 @@ _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
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));
@@ -229,6 +264,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
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 *,
@@ -270,18 +306,29 @@ _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
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));
@@ -306,6 +353,10 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
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
@@ -378,13 +429,13 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
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));
@@ -414,7 +465,7 @@ _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
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:
@@ -423,7 +474,7 @@ _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
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 *,
@@ -514,7 +565,7 @@ _GL_WARN_ON_USE (strsep, "strsep is unportable - "
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
@@ -525,7 +576,7 @@ _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 *,
@@ -556,14 +607,16 @@ _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
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 *); }
@@ -572,7 +625,7 @@ _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 *,
@@ -671,10 +724,14 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
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);
@@ -684,6 +741,7 @@ _GL_CXXALIASWARN (mbslen);
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
@@ -697,10 +755,12 @@ _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
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
@@ -712,15 +772,17 @@ _GL_CXXALIASWARN (mbschr);
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
@@ -733,6 +795,7 @@ _GL_CXXALIASWARN (mbsrchr);
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
@@ -744,6 +807,7 @@ _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
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
@@ -758,20 +822,21 @@ _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
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
@@ -782,6 +847,7 @@ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
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
@@ -792,6 +858,7 @@ _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
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
@@ -805,10 +872,12 @@ _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
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
@@ -822,6 +891,7 @@ _GL_CXXALIASWARN (mbspbrk);
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
@@ -885,6 +955,35 @@ _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)
@@ -912,6 +1011,7 @@ _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
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 *));
@@ -925,5 +1025,5 @@ _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
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 */