annotate lib/string.in.h @ 423:079d43b6967b 3.0-beta2 3.0-beta2

Added missing file
author lost@l-w.ca
date Sun, 19 Sep 2010 01:44:47 -0600
parents 3c2e1f24cc7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
421
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
1 /* A GNU-like <string.h>.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
2
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
3 Copyright (C) 1995-1996, 2001-2010 Free Software Foundation, Inc.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
4
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
7 the Free Software Foundation; either version 3, or (at your option)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
8 any later version.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
9
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
13 GNU General Public License for more details.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
14
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
16 along with this program; if not, write to the Free Software Foundation,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
18
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
19 #ifndef _GL_STRING_H
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
20
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
21 #if __GNUC__ >= 3
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
22 @PRAGMA_SYSTEM_HEADER@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
23 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
24
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
25 /* The include_next requires a split double-inclusion guard. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
26 #@INCLUDE_NEXT@ @NEXT_STRING_H@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
27
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
28 #ifndef _GL_STRING_H
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
29 #define _GL_STRING_H
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
30
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
31 /* NetBSD 5.0 mis-defines NULL. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
32 #include <stddef.h>
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
33
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
34 /* MirBSD defines mbslen as a macro. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
35 #if @GNULIB_MBSLEN@ && defined __MirBSD__
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
36 # include <wchar.h>
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
37 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
38
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
39 #ifndef __attribute__
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
40 /* This feature is available in gcc versions 2.5 and later. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
41 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
42 # define __attribute__(Spec) /* empty */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
43 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
44 /* The attribute __pure__ was added in gcc 2.96. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
45 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
46 # define __pure__ /* empty */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
47 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
48 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
49
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
50
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
51 /* The definition of GL_LINK_WARNING is copied here. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
52
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
53 /* The definition of _GL_ARG_NONNULL is copied here. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
54
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
55
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
56 #ifdef __cplusplus
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
57 extern "C" {
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
58 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
59
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
60
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
61 /* Return the first instance of C within N bytes of S, or NULL. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
62 #if @GNULIB_MEMCHR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
63 # if @REPLACE_MEMCHR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
64 # define memchr rpl_memchr
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
65 extern void *memchr (void const *__s, int __c, size_t __n)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
66 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
67 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
68 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
69 # undef memchr
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
70 # define memchr(s,c,n) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
71 (GL_LINK_WARNING ("memchr has platform-specific bugs - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
72 "use gnulib module memchr for portability" ), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
73 memchr (s, c, n))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
74 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
75
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
76 /* Return the first occurrence of NEEDLE in HAYSTACK. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
77 #if @GNULIB_MEMMEM@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
78 # if @REPLACE_MEMMEM@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
79 # define memmem rpl_memmem
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
80 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
81 # if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
82 extern void *memmem (void const *__haystack, size_t __haystack_len,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
83 void const *__needle, size_t __needle_len)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
84 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
85 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
86 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
87 # undef memmem
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
88 # define memmem(a,al,b,bl) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
89 (GL_LINK_WARNING ("memmem is unportable and often quadratic - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
90 "use gnulib module memmem-simple for portability, " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
91 "and module memmem for speed" ), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
92 memmem (a, al, b, bl))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
93 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
94
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
95 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
96 last written byte. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
97 #if @GNULIB_MEMPCPY@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
98 # if ! @HAVE_MEMPCPY@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
99 extern void *mempcpy (void *restrict __dest, void const *restrict __src,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
100 size_t __n)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
101 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
102 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
103 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
104 # undef mempcpy
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
105 # define mempcpy(a,b,n) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
106 (GL_LINK_WARNING ("mempcpy is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
107 "use gnulib module mempcpy for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
108 mempcpy (a, b, n))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
109 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
110
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
111 /* Search backwards through a block for a byte (specified as an int). */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
112 #if @GNULIB_MEMRCHR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
113 # if ! @HAVE_DECL_MEMRCHR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
114 extern void *memrchr (void const *, int, size_t)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
115 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
116 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
117 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
118 # undef memrchr
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
119 # define memrchr(a,b,c) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
120 (GL_LINK_WARNING ("memrchr is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
121 "use gnulib module memrchr for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
122 memrchr (a, b, c))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
123 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
124
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
125 /* Find the first occurrence of C in S. More efficient than
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
126 memchr(S,C,N), at the expense of undefined behavior if C does not
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
127 occur within N bytes. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
128 #if @GNULIB_RAWMEMCHR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
129 # if ! @HAVE_RAWMEMCHR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
130 extern void *rawmemchr (void const *__s, int __c_in)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
131 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
132 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
133 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
134 # undef rawmemchr
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
135 # define rawmemchr(a,b) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
136 (GL_LINK_WARNING ("rawmemchr is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
137 "use gnulib module rawmemchr for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
138 rawmemchr (a, b))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
139 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
140
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
141 /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
142 #if @GNULIB_STPCPY@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
143 # if ! @HAVE_STPCPY@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
144 extern char *stpcpy (char *restrict __dst, char const *restrict __src)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
145 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
146 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
147 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
148 # undef stpcpy
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
149 # define stpcpy(a,b) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
150 (GL_LINK_WARNING ("stpcpy is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
151 "use gnulib module stpcpy for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
152 stpcpy (a, b))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
153 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
154
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
155 /* Copy no more than N bytes of SRC to DST, returning a pointer past the
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
156 last non-NUL byte written into DST. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
157 #if @GNULIB_STPNCPY@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
158 # if ! @HAVE_STPNCPY@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
159 # define stpncpy gnu_stpncpy
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
160 extern char *stpncpy (char *restrict __dst, char const *restrict __src,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
161 size_t __n)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
162 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
163 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
164 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
165 # undef stpncpy
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
166 # define stpncpy(a,b,n) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
167 (GL_LINK_WARNING ("stpncpy is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
168 "use gnulib module stpncpy for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
169 stpncpy (a, b, n))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
170 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
171
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
172 #if defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
173 /* strchr() does not work with multibyte strings if the locale encoding is
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
174 GB18030 and the character to be searched is a digit. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
175 # undef strchr
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
176 # define strchr(s,c) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
177 (GL_LINK_WARNING ("strchr cannot work correctly on character strings " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
178 "in some multibyte locales - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
179 "use mbschr if you care about internationalization"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
180 strchr (s, c))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
181 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
182
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
183 /* Find the first occurrence of C in S or the final NUL byte. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
184 #if @GNULIB_STRCHRNUL@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
185 # if ! @HAVE_STRCHRNUL@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
186 extern char *strchrnul (char const *__s, int __c_in)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
187 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
188 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
189 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
190 # undef strchrnul
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
191 # define strchrnul(a,b) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
192 (GL_LINK_WARNING ("strchrnul is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
193 "use gnulib module strchrnul for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
194 strchrnul (a, b))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
195 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
196
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
197 /* Duplicate S, returning an identical malloc'd string. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
198 #if @GNULIB_STRDUP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
199 # if @REPLACE_STRDUP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
200 # undef strdup
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
201 # define strdup rpl_strdup
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
202 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
203 # if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
204 extern char *strdup (char const *__s) _GL_ARG_NONNULL ((1));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
205 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
206 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
207 # undef strdup
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
208 # define strdup(a) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
209 (GL_LINK_WARNING ("strdup is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
210 "use gnulib module strdup for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
211 strdup (a))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
212 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
213
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
214 /* Return a newly allocated copy of at most N bytes of STRING. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
215 #if @GNULIB_STRNDUP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
216 # if @REPLACE_STRNDUP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
217 # undef strndup
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
218 # define strndup rpl_strndup
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
219 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
220 # if @REPLACE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
221 extern char *strndup (char const *__string, size_t __n) _GL_ARG_NONNULL ((1));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
222 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
223 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
224 # undef strndup
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
225 # define strndup(a,n) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
226 (GL_LINK_WARNING ("strndup is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
227 "use gnulib module strndup for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
228 strndup (a, n))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
229 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
230
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
231 /* Find the length (number of bytes) of STRING, but scan at most
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
232 MAXLEN bytes. If no '\0' terminator is found in that many bytes,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
233 return MAXLEN. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
234 #if @GNULIB_STRNLEN@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
235 # if ! @HAVE_DECL_STRNLEN@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
236 extern size_t strnlen (char const *__string, size_t __maxlen)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
237 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
238 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
239 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
240 # undef strnlen
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
241 # define strnlen(a,n) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
242 (GL_LINK_WARNING ("strnlen is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
243 "use gnulib module strnlen for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
244 strnlen (a, n))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
245 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
246
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
247 #if defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
248 /* strcspn() assumes the second argument is a list of single-byte characters.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
249 Even in this simple case, it does not work with multibyte strings if the
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
250 locale encoding is GB18030 and one of the characters to be searched is a
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
251 digit. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
252 # undef strcspn
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
253 # define strcspn(s,a) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
254 (GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
255 "in multibyte locales - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
256 "use mbscspn if you care about internationalization"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
257 strcspn (s, a))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
258 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
259
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
260 /* Find the first occurrence in S of any character in ACCEPT. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
261 #if @GNULIB_STRPBRK@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
262 # if ! @HAVE_STRPBRK@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
263 extern char *strpbrk (char const *__s, char const *__accept)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
264 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
265 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
266 # if defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
267 /* strpbrk() assumes the second argument is a list of single-byte characters.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
268 Even in this simple case, it does not work with multibyte strings if the
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
269 locale encoding is GB18030 and one of the characters to be searched is a
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
270 digit. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
271 # undef strpbrk
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
272 # define strpbrk(s,a) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
273 (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
274 "in multibyte locales - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
275 "use mbspbrk if you care about internationalization"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
276 strpbrk (s, a))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
277 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
278 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
279 # undef strpbrk
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
280 # define strpbrk(s,a) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
281 (GL_LINK_WARNING ("strpbrk is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
282 "use gnulib module strpbrk for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
283 strpbrk (s, a))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
284 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
285
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
286 #if defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
287 /* strspn() assumes the second argument is a list of single-byte characters.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
288 Even in this simple case, it cannot work with multibyte strings. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
289 # undef strspn
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
290 # define strspn(s,a) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
291 (GL_LINK_WARNING ("strspn cannot work correctly on character strings " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
292 "in multibyte locales - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
293 "use mbsspn if you care about internationalization"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
294 strspn (s, a))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
295 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
296
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
297 #if defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
298 /* strrchr() does not work with multibyte strings if the locale encoding is
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
299 GB18030 and the character to be searched is a digit. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
300 # undef strrchr
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
301 # define strrchr(s,c) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
302 (GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
303 "in some multibyte locales - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
304 "use mbsrchr if you care about internationalization"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
305 strrchr (s, c))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
306 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
307
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
308 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
309 If one is found, overwrite it with a NUL, and advance *STRINGP
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
310 to point to the next char after it. Otherwise, set *STRINGP to NULL.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
311 If *STRINGP was already NULL, nothing happens.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
312 Return the old value of *STRINGP.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
313
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
314 This is a variant of strtok() that is multithread-safe and supports
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
315 empty fields.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
316
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
317 Caveat: It modifies the original string.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
318 Caveat: These functions cannot be used on constant strings.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
319 Caveat: The identity of the delimiting character is lost.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
320 Caveat: It doesn't work with multibyte strings unless all of the delimiter
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
321 characters are ASCII characters < 0x30.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
322
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
323 See also strtok_r(). */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
324 #if @GNULIB_STRSEP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
325 # if ! @HAVE_STRSEP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
326 extern char *strsep (char **restrict __stringp, char const *restrict __delim)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
327 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
328 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
329 # if defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
330 # undef strsep
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
331 # define strsep(s,d) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
332 (GL_LINK_WARNING ("strsep cannot work correctly on character strings " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
333 "in multibyte locales - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
334 "use mbssep if you care about internationalization"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
335 strsep (s, d))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
336 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
337 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
338 # undef strsep
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
339 # define strsep(s,d) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
340 (GL_LINK_WARNING ("strsep is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
341 "use gnulib module strsep for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
342 strsep (s, d))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
343 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
344
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
345 #if @GNULIB_STRSTR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
346 # if @REPLACE_STRSTR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
347 # define strstr rpl_strstr
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
348 extern char *strstr (const char *haystack, const char *needle)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
349 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
350 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
351 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
352 /* strstr() does not work with multibyte strings if the locale encoding is
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
353 different from UTF-8:
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
354 POSIX says that it operates on "strings", and "string" in POSIX is defined
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
355 as a sequence of bytes, not of characters. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
356 # undef strstr
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
357 # define strstr(a,b) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
358 (GL_LINK_WARNING ("strstr is quadratic on many systems, and cannot " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
359 "work correctly on character strings in most " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
360 "multibyte locales - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
361 "use mbsstr if you care about internationalization, " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
362 "or use strstr if you care about speed"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
363 strstr (a, b))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
364 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
365
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
366 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
367 comparison. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
368 #if @GNULIB_STRCASESTR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
369 # if @REPLACE_STRCASESTR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
370 # define strcasestr rpl_strcasestr
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
371 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
372 # if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
373 extern char *strcasestr (const char *haystack, const char *needle)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
374 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
375 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
376 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
377 /* strcasestr() does not work with multibyte strings:
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
378 It is a glibc extension, and glibc implements it only for unibyte
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
379 locales. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
380 # undef strcasestr
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
381 # define strcasestr(a,b) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
382 (GL_LINK_WARNING ("strcasestr does work correctly on character strings " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
383 "in multibyte locales - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
384 "use mbscasestr if you care about " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
385 "internationalization, or use c-strcasestr if you want " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
386 "a locale independent function"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
387 strcasestr (a, b))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
388 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
389
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
390 /* Parse S into tokens separated by characters in DELIM.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
391 If S is NULL, the saved pointer in SAVE_PTR is used as
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
392 the next starting point. For example:
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
393 char s[] = "-abc-=-def";
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
394 char *sp;
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
395 x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
396 x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
397 x = strtok_r(NULL, "=", &sp); // x = NULL
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
398 // s = "abc\0-def\0"
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
399
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
400 This is a variant of strtok() that is multithread-safe.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
401
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
402 For the POSIX documentation for this function, see:
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
403 http://www.opengroup.org/susv3xsh/strtok.html
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
404
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
405 Caveat: It modifies the original string.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
406 Caveat: These functions cannot be used on constant strings.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
407 Caveat: The identity of the delimiting character is lost.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
408 Caveat: It doesn't work with multibyte strings unless all of the delimiter
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
409 characters are ASCII characters < 0x30.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
410
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
411 See also strsep(). */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
412 #if @GNULIB_STRTOK_R@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
413 # if @REPLACE_STRTOK_R@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
414 # undef strtok_r
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
415 # define strtok_r rpl_strtok_r
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
416 # elif @UNDEFINE_STRTOK_R@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
417 # undef strtok_r
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
418 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
419 # if ! @HAVE_DECL_STRTOK_R@ || @REPLACE_STRTOK_R@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
420 extern char *strtok_r (char *restrict s, char const *restrict delim,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
421 char **restrict save_ptr)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
422 _GL_ARG_NONNULL ((2, 3));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
423 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
424 # if defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
425 # undef strtok_r
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
426 # define strtok_r(s,d,p) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
427 (GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
428 "in multibyte locales - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
429 "use mbstok_r if you care about internationalization"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
430 strtok_r (s, d, p))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
431 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
432 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
433 # undef strtok_r
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
434 # define strtok_r(s,d,p) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
435 (GL_LINK_WARNING ("strtok_r is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
436 "use gnulib module strtok_r for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
437 strtok_r (s, d, p))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
438 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
439
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
440
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
441 /* The following functions are not specified by POSIX. They are gnulib
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
442 extensions. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
443
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
444 #if @GNULIB_MBSLEN@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
445 /* Return the number of multibyte characters in the character string STRING.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
446 This considers multibyte characters, unlike strlen, which counts bytes. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
447 # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
448 # undef mbslen
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
449 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
450 # if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
451 # define mbslen rpl_mbslen
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
452 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
453 extern size_t mbslen (const char *string) _GL_ARG_NONNULL ((1));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
454 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
455
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
456 #if @GNULIB_MBSNLEN@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
457 /* Return the number of multibyte characters in the character string starting
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
458 at STRING and ending at STRING + LEN. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
459 extern size_t mbsnlen (const char *string, size_t len) _GL_ARG_NONNULL ((1));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
460 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
461
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
462 #if @GNULIB_MBSCHR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
463 /* Locate the first single-byte character C in the character string STRING,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
464 and return a pointer to it. Return NULL if C is not found in STRING.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
465 Unlike strchr(), this function works correctly in multibyte locales with
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
466 encodings such as GB18030. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
467 # define mbschr rpl_mbschr /* avoid collision with HP-UX function */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
468 extern char * mbschr (const char *string, int c) _GL_ARG_NONNULL ((1));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
469 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
470
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
471 #if @GNULIB_MBSRCHR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
472 /* Locate the last single-byte character C in the character string STRING,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
473 and return a pointer to it. Return NULL if C is not found in STRING.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
474 Unlike strrchr(), this function works correctly in multibyte locales with
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
475 encodings such as GB18030. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
476 # define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
477 extern char * mbsrchr (const char *string, int c) _GL_ARG_NONNULL ((1));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
478 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
479
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
480 #if @GNULIB_MBSSTR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
481 /* Find the first occurrence of the character string NEEDLE in the character
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
482 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
483 Unlike strstr(), this function works correctly in multibyte locales with
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
484 encodings different from UTF-8. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
485 extern char * mbsstr (const char *haystack, const char *needle)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
486 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
487 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
488
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
489 #if @GNULIB_MBSCASECMP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
490 /* Compare the character strings S1 and S2, ignoring case, returning less than,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
491 equal to or greater than zero if S1 is lexicographically less than, equal to
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
492 or greater than S2.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
493 Note: This function may, in multibyte locales, return 0 for strings of
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
494 different lengths!
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
495 Unlike strcasecmp(), this function works correctly in multibyte locales. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
496 extern int mbscasecmp (const char *s1, const char *s2)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
497 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
498 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
499
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
500 #if @GNULIB_MBSNCASECMP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
501 /* Compare the initial segment of the character string S1 consisting of at most
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
502 N characters with the initial segment of the character string S2 consisting
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
503 of at most N characters, ignoring case, returning less than, equal to or
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
504 greater than zero if the initial segment of S1 is lexicographically less
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
505 than, equal to or greater than the initial segment of S2.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
506 Note: This function may, in multibyte locales, return 0 for initial segments
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
507 of different lengths!
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
508 Unlike strncasecmp(), this function works correctly in multibyte locales.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
509 But beware that N is not a byte count but a character count! */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
510 extern int mbsncasecmp (const char *s1, const char *s2, size_t n)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
511 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
512 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
513
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
514 #if @GNULIB_MBSPCASECMP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
515 /* Compare the initial segment of the character string STRING consisting of
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
516 at most mbslen (PREFIX) characters with the character string PREFIX,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
517 ignoring case, returning less than, equal to or greater than zero if this
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
518 initial segment is lexicographically less than, equal to or greater than
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
519 PREFIX.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
520 Note: This function may, in multibyte locales, return 0 if STRING is of
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
521 smaller length than PREFIX!
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
522 Unlike strncasecmp(), this function works correctly in multibyte
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
523 locales. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
524 extern char * mbspcasecmp (const char *string, const char *prefix)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
525 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
526 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
527
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
528 #if @GNULIB_MBSCASESTR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
529 /* Find the first occurrence of the character string NEEDLE in the character
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
530 string HAYSTACK, using case-insensitive comparison.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
531 Note: This function may, in multibyte locales, return success even if
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
532 strlen (haystack) < strlen (needle) !
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
533 Unlike strcasestr(), this function works correctly in multibyte locales. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
534 extern char * mbscasestr (const char *haystack, const char *needle)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
535 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
536 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
537
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
538 #if @GNULIB_MBSCSPN@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
539 /* Find the first occurrence in the character string STRING of any character
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
540 in the character string ACCEPT. Return the number of bytes from the
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
541 beginning of the string to this occurrence, or to the end of the string
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
542 if none exists.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
543 Unlike strcspn(), this function works correctly in multibyte locales. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
544 extern size_t mbscspn (const char *string, const char *accept)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
545 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
546 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
547
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
548 #if @GNULIB_MBSPBRK@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
549 /* Find the first occurrence in the character string STRING of any character
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
550 in the character string ACCEPT. Return the pointer to it, or NULL if none
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
551 exists.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
552 Unlike strpbrk(), this function works correctly in multibyte locales. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
553 # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
554 extern char * mbspbrk (const char *string, const char *accept)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
555 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
556 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
557
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
558 #if @GNULIB_MBSSPN@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
559 /* Find the first occurrence in the character string STRING of any character
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
560 not in the character string REJECT. Return the number of bytes from the
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
561 beginning of the string to this occurrence, or to the end of the string
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
562 if none exists.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
563 Unlike strspn(), this function works correctly in multibyte locales. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
564 extern size_t mbsspn (const char *string, const char *reject)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
565 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
566 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
567
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
568 #if @GNULIB_MBSSEP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
569 /* Search the next delimiter (multibyte character listed in the character
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
570 string DELIM) starting at the character string *STRINGP.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
571 If one is found, overwrite it with a NUL, and advance *STRINGP to point
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
572 to the next multibyte character after it. Otherwise, set *STRINGP to NULL.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
573 If *STRINGP was already NULL, nothing happens.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
574 Return the old value of *STRINGP.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
575
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
576 This is a variant of mbstok_r() that supports empty fields.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
577
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
578 Caveat: It modifies the original string.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
579 Caveat: These functions cannot be used on constant strings.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
580 Caveat: The identity of the delimiting character is lost.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
581
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
582 See also mbstok_r(). */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
583 extern char * mbssep (char **stringp, const char *delim)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
584 _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
585 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
586
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
587 #if @GNULIB_MBSTOK_R@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
588 /* Parse the character string STRING into tokens separated by characters in
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
589 the character string DELIM.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
590 If STRING is NULL, the saved pointer in SAVE_PTR is used as
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
591 the next starting point. For example:
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
592 char s[] = "-abc-=-def";
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
593 char *sp;
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
594 x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
595 x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
596 x = mbstok_r(NULL, "=", &sp); // x = NULL
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
597 // s = "abc\0-def\0"
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
598
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
599 Caveat: It modifies the original string.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
600 Caveat: These functions cannot be used on constant strings.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
601 Caveat: The identity of the delimiting character is lost.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
602
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
603 See also mbssep(). */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
604 extern char * mbstok_r (char *string, const char *delim, char **save_ptr)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
605 _GL_ARG_NONNULL ((2, 3));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
606 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
607
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
608 /* Map any int, typically from errno, into an error message. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
609 #if @GNULIB_STRERROR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
610 # if @REPLACE_STRERROR@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
611 # undef strerror
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
612 # define strerror rpl_strerror
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
613 extern char *strerror (int);
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
614 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
615 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
616 # undef strerror
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
617 # define strerror(e) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
618 (GL_LINK_WARNING ("strerror is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
619 "use gnulib module strerror to guarantee non-NULL result"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
620 strerror (e))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
621 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
622
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
623 #if @GNULIB_STRSIGNAL@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
624 # if @REPLACE_STRSIGNAL@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
625 # define strsignal rpl_strsignal
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
626 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
627 # if ! @HAVE_DECL_STRSIGNAL@ || @REPLACE_STRSIGNAL@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
628 extern char *strsignal (int __sig);
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
629 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
630 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
631 # undef strsignal
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
632 # define strsignal(a) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
633 (GL_LINK_WARNING ("strsignal is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
634 "use gnulib module strsignal for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
635 strsignal (a))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
636 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
637
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
638 #if @GNULIB_STRVERSCMP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
639 # if !@HAVE_STRVERSCMP@
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
640 extern int strverscmp (const char *, const char *) _GL_ARG_NONNULL ((1, 2));
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
641 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
642 #elif defined GNULIB_POSIXCHECK
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
643 # undef strverscmp
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
644 # define strverscmp(a, b) \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
645 (GL_LINK_WARNING ("strverscmp is unportable - " \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
646 "use gnulib module strverscmp for portability"), \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
647 strverscmp (a, b))
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
648 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
649
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
650
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
651 #ifdef __cplusplus
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
652 }
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
653 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
654
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
655 #endif /* _GL_STRING_H */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
656 #endif /* _GL_STRING_H */