annotate lib/string.in.h @ 273:88bbffa404ea 2.5 2.5

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