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.h160
1 files changed, 127 insertions, 33 deletions
diff --git a/gl/string.in.h b/gl/string.in.h
index f64fce30..d7a6c9c9 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,19 +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)
42# define __attribute__(Spec) /* empty */
43# endif
44#endif
45/* The attribute __pure__ was added in gcc 2.96. */
46#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 41#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
47# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 42# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
48#else 43#else
49# define _GL_ATTRIBUTE_PURE /* empty */ 44# define _GL_ATTRIBUTE_PURE /* empty */
50#endif 45#endif
51 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
52 53
53/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 54/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
54 55
@@ -57,6 +58,36 @@
57/* The definition of _GL_WARN_ON_USE is copied here. */ 58/* The definition of _GL_WARN_ON_USE is copied here. */
58 59
59 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
60/* 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. */
61#if @GNULIB_MEMCHR@ 92#if @GNULIB_MEMCHR@
62# if @REPLACE_MEMCHR@ 93# if @REPLACE_MEMCHR@
@@ -80,7 +111,7 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
80 void *, (void const *__s, int __c, size_t __n), 111 void *, (void const *__s, int __c, size_t __n),
81 void const *, (void const *__s, int __c, size_t __n)); 112 void const *, (void const *__s, int __c, size_t __n));
82# endif 113# endif
83# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 114# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
84 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 115 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
85_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); 116_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
86_GL_CXXALIASWARN1 (memchr, void const *, 117_GL_CXXALIASWARN1 (memchr, void const *,
@@ -165,7 +196,7 @@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
165_GL_CXXALIAS_SYS_CAST2 (memrchr, 196_GL_CXXALIAS_SYS_CAST2 (memrchr,
166 void *, (void const *, int, size_t), 197 void *, (void const *, int, size_t),
167 void const *, (void const *, int, size_t)); 198 void const *, (void const *, int, size_t));
168# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 199# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
169 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 200 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
170_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); 201_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
171_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); 202_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
@@ -195,7 +226,7 @@ _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
195_GL_CXXALIAS_SYS_CAST2 (rawmemchr, 226_GL_CXXALIAS_SYS_CAST2 (rawmemchr,
196 void *, (void const *__s, int __c_in), 227 void *, (void const *__s, int __c_in),
197 void const *, (void const *__s, int __c_in)); 228 void const *, (void const *__s, int __c_in));
198# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 229# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
199 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 230 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
200_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); 231_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
201_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); 232_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
@@ -233,6 +264,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
233#if @GNULIB_STPNCPY@ 264#if @GNULIB_STPNCPY@
234# if @REPLACE_STPNCPY@ 265# if @REPLACE_STPNCPY@
235# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 266# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
267# undef stpncpy
236# define stpncpy rpl_stpncpy 268# define stpncpy rpl_stpncpy
237# endif 269# endif
238_GL_FUNCDECL_RPL (stpncpy, char *, 270_GL_FUNCDECL_RPL (stpncpy, char *,
@@ -274,18 +306,29 @@ _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
274 306
275/* 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. */
276#if @GNULIB_STRCHRNUL@ 308#if @GNULIB_STRCHRNUL@
277# 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@
278_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) 320_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
279 _GL_ATTRIBUTE_PURE 321 _GL_ATTRIBUTE_PURE
280 _GL_ARG_NONNULL ((1))); 322 _GL_ARG_NONNULL ((1)));
281# endif 323# endif
282 /* On some systems, this function is defined as an overloaded function: 324 /* On some systems, this function is defined as an overloaded function:
283 extern "C++" { const char * std::strchrnul (const char *, int); } 325 extern "C++" { const char * std::strchrnul (const char *, int); }
284 extern "C++" { char * std::strchrnul (char *, int); } */ 326 extern "C++" { char * std::strchrnul (char *, int); } */
285_GL_CXXALIAS_SYS_CAST2 (strchrnul, 327_GL_CXXALIAS_SYS_CAST2 (strchrnul,
286 char *, (char const *__s, int __c_in), 328 char *, (char const *__s, int __c_in),
287 char const *, (char const *__s, int __c_in)); 329 char const *, (char const *__s, int __c_in));
288# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 330# endif
331# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
289 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 332 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
290_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); 333_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
291_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); 334_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
@@ -310,6 +353,10 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
310_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)));
311_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); 354_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
312# 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
313# if !(@HAVE_DECL_STRDUP@ || defined strdup) 360# if !(@HAVE_DECL_STRDUP@ || defined strdup)
314_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)));
315# endif 362# endif
@@ -427,7 +474,7 @@ _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
427_GL_CXXALIAS_SYS_CAST2 (strpbrk, 474_GL_CXXALIAS_SYS_CAST2 (strpbrk,
428 char *, (char const *__s, char const *__accept), 475 char *, (char const *__s, char const *__accept),
429 const char *, (char const *__s, char const *__accept)); 476 const char *, (char const *__s, char const *__accept));
430# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 477# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
431 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 478 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
432_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); 479_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
433_GL_CXXALIASWARN1 (strpbrk, char const *, 480_GL_CXXALIASWARN1 (strpbrk, char const *,
@@ -529,7 +576,7 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
529 char *, (const char *haystack, const char *needle), 576 char *, (const char *haystack, const char *needle),
530 const char *, (const char *haystack, const char *needle)); 577 const char *, (const char *haystack, const char *needle));
531# endif 578# endif
532# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 579# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
533 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 580 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
534_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); 581_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
535_GL_CXXALIASWARN1 (strstr, const char *, 582_GL_CXXALIASWARN1 (strstr, const char *,
@@ -578,7 +625,7 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
578 char *, (const char *haystack, const char *needle), 625 char *, (const char *haystack, const char *needle),
579 const char *, (const char *haystack, const char *needle)); 626 const char *, (const char *haystack, const char *needle));
580# endif 627# endif
581# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 628# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
582 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 629 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
583_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); 630_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
584_GL_CXXALIASWARN1 (strcasestr, const char *, 631_GL_CXXALIASWARN1 (strcasestr, const char *,
@@ -677,10 +724,14 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
677# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 724# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
678# define mbslen rpl_mbslen 725# define mbslen rpl_mbslen
679# endif 726# endif
680_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)));
681_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); 730_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
682# else 731# else
683_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)));
684_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); 735_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
685# endif 736# endif
686_GL_CXXALIASWARN (mbslen); 737_GL_CXXALIASWARN (mbslen);
@@ -690,6 +741,7 @@ _GL_CXXALIASWARN (mbslen);
690/* Return the number of multibyte characters in the character string starting 741/* Return the number of multibyte characters in the character string starting
691 at STRING and ending at STRING + LEN. */ 742 at STRING and ending at STRING + LEN. */
692_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
693 _GL_ARG_NONNULL ((1)); 745 _GL_ARG_NONNULL ((1));
694#endif 746#endif
695 747
@@ -703,10 +755,12 @@ _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
703# define mbschr rpl_mbschr /* avoid collision with HP-UX function */ 755# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
704# endif 756# endif
705_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
706 _GL_ARG_NONNULL ((1))); 759 _GL_ARG_NONNULL ((1)));
707_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); 760_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
708# else 761# else
709_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
710 _GL_ARG_NONNULL ((1))); 764 _GL_ARG_NONNULL ((1)));
711_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); 765_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
712# endif 766# endif
@@ -718,15 +772,17 @@ _GL_CXXALIASWARN (mbschr);
718 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.
719 Unlike strrchr(), this function works correctly in multibyte locales with 773 Unlike strrchr(), this function works correctly in multibyte locales with
720 encodings such as GB18030. */ 774 encodings such as GB18030. */
721# if defined __hpux 775# if defined __hpux || defined __INTERIX
722# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 776# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
723# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */ 777# define mbsrchr rpl_mbsrchr /* avoid collision with system function */
724# endif 778# endif
725_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
726 _GL_ARG_NONNULL ((1))); 781 _GL_ARG_NONNULL ((1)));
727_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); 782_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
728# else 783# else
729_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
730 _GL_ARG_NONNULL ((1))); 786 _GL_ARG_NONNULL ((1)));
731_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); 787_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
732# endif 788# endif
@@ -739,6 +795,7 @@ _GL_CXXALIASWARN (mbsrchr);
739 Unlike strstr(), this function works correctly in multibyte locales with 795 Unlike strstr(), this function works correctly in multibyte locales with
740 encodings different from UTF-8. */ 796 encodings different from UTF-8. */
741_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
742 _GL_ARG_NONNULL ((1, 2)); 799 _GL_ARG_NONNULL ((1, 2));
743#endif 800#endif
744 801
@@ -750,6 +807,7 @@ _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
750 different lengths! 807 different lengths!
751 Unlike strcasecmp(), this function works correctly in multibyte locales. */ 808 Unlike strcasecmp(), this function works correctly in multibyte locales. */
752_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
753 _GL_ARG_NONNULL ((1, 2)); 811 _GL_ARG_NONNULL ((1, 2));
754#endif 812#endif
755 813
@@ -764,20 +822,21 @@ _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
764 Unlike strncasecmp(), this function works correctly in multibyte locales. 822 Unlike strncasecmp(), this function works correctly in multibyte locales.
765 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! */
766_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
767 _GL_ARG_NONNULL ((1, 2)); 826 _GL_ARG_NONNULL ((1, 2));
768#endif 827#endif
769 828
770#if @GNULIB_MBSPCASECMP@ 829#if @GNULIB_MBSPCASECMP@
771/* Compare the initial segment of the character string STRING consisting of 830/* Compare the initial segment of the character string STRING consisting of
772 at most mbslen (PREFIX) characters with the character string PREFIX, 831 at most mbslen (PREFIX) characters with the character string PREFIX,
773 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
774 initial segment is lexicographically less than, equal to or greater than 833 after this prefix in STRING. Otherwise, return NULL.
775 PREFIX. 834 Note: This function may, in multibyte locales, return non-NULL if STRING
776 Note: This function may, in multibyte locales, return 0 if STRING is of 835 is of smaller length than PREFIX!
777 smaller length than PREFIX!
778 Unlike strncasecmp(), this function works correctly in multibyte 836 Unlike strncasecmp(), this function works correctly in multibyte
779 locales. */ 837 locales. */
780_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
781 _GL_ARG_NONNULL ((1, 2)); 840 _GL_ARG_NONNULL ((1, 2));
782#endif 841#endif
783 842
@@ -788,6 +847,7 @@ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
788 strlen (haystack) < strlen (needle) ! 847 strlen (haystack) < strlen (needle) !
789 Unlike strcasestr(), this function works correctly in multibyte locales. */ 848 Unlike strcasestr(), this function works correctly in multibyte locales. */
790_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
791 _GL_ARG_NONNULL ((1, 2)); 851 _GL_ARG_NONNULL ((1, 2));
792#endif 852#endif
793 853
@@ -798,6 +858,7 @@ _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
798 if none exists. 858 if none exists.
799 Unlike strcspn(), this function works correctly in multibyte locales. */ 859 Unlike strcspn(), this function works correctly in multibyte locales. */
800_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
801 _GL_ARG_NONNULL ((1, 2)); 862 _GL_ARG_NONNULL ((1, 2));
802#endif 863#endif
803 864
@@ -811,10 +872,12 @@ _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
811# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ 872# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
812# endif 873# endif
813_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
814 _GL_ARG_NONNULL ((1, 2))); 876 _GL_ARG_NONNULL ((1, 2)));
815_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); 877_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
816# else 878# else
817_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
818 _GL_ARG_NONNULL ((1, 2))); 881 _GL_ARG_NONNULL ((1, 2)));
819_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); 882_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
820# endif 883# endif
@@ -828,6 +891,7 @@ _GL_CXXALIASWARN (mbspbrk);
828 if none exists. 891 if none exists.
829 Unlike strspn(), this function works correctly in multibyte locales. */ 892 Unlike strspn(), this function works correctly in multibyte locales. */
830_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
831 _GL_ARG_NONNULL ((1, 2)); 895 _GL_ARG_NONNULL ((1, 2));
832#endif 896#endif
833 897
@@ -891,6 +955,35 @@ _GL_WARN_ON_USE (strerror, "strerror is unportable - "
891 "use gnulib module strerror to guarantee non-NULL result"); 955 "use gnulib module strerror to guarantee non-NULL result");
892#endif 956#endif
893 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
894#if @GNULIB_STRSIGNAL@ 987#if @GNULIB_STRSIGNAL@
895# if @REPLACE_STRSIGNAL@ 988# if @REPLACE_STRSIGNAL@
896# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 989# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -918,6 +1011,7 @@ _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
918#if @GNULIB_STRVERSCMP@ 1011#if @GNULIB_STRVERSCMP@
919# if !@HAVE_STRVERSCMP@ 1012# if !@HAVE_STRVERSCMP@
920_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) 1013_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
1014 _GL_ATTRIBUTE_PURE
921 _GL_ARG_NONNULL ((1, 2))); 1015 _GL_ARG_NONNULL ((1, 2)));
922# endif 1016# endif
923_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); 1017_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
@@ -931,5 +1025,5 @@ _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
931#endif 1025#endif
932 1026
933 1027
934#endif /* _GL_STRING_H */ 1028#endif /* _@GUARD_PREFIX@_STRING_H */
935#endif /* _GL_STRING_H */ 1029#endif /* _@GUARD_PREFIX@_STRING_H */