1 |
2 |
drasko |
/* Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc.
|
2 |
|
|
This file is part of the GNU C Library.
|
3 |
|
|
|
4 |
|
|
The GNU C Library is free software; you can redistribute it and/or
|
5 |
|
|
modify it under the terms of the GNU Lesser General Public
|
6 |
|
|
License as published by the Free Software Foundation; either
|
7 |
|
|
version 2.1 of the License, or (at your option) any later version.
|
8 |
|
|
|
9 |
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
10 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12 |
|
|
Lesser General Public License for more details.
|
13 |
|
|
|
14 |
|
|
You should have received a copy of the GNU Lesser General Public
|
15 |
|
|
License along with the GNU C Library; if not, write to the Free
|
16 |
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
17 |
|
|
02111-1307 USA. */
|
18 |
|
|
|
19 |
|
|
/*
|
20 |
|
|
* ISO C99 Standard: 7.24
|
21 |
|
|
* Extended multibyte and wide character utilities <wchar.h>
|
22 |
|
|
*/
|
23 |
|
|
|
24 |
|
|
#ifndef _WCHAR_H
|
25 |
|
|
|
26 |
|
|
#ifndef __need_mbstate_t
|
27 |
|
|
# define _WCHAR_H 1
|
28 |
|
|
# include <features.h>
|
29 |
|
|
#endif
|
30 |
|
|
|
31 |
|
|
#ifndef __UCLIBC_HAS_WCHAR__
|
32 |
|
|
#error Attempted to include wchar.h when uClibc built without wide char support.
|
33 |
|
|
#endif
|
34 |
|
|
|
35 |
|
|
#ifdef _WCHAR_H
|
36 |
|
|
/* Get FILE definition. */
|
37 |
|
|
# define __need___FILE
|
38 |
|
|
# ifdef __USE_UNIX98
|
39 |
|
|
# define __need_FILE
|
40 |
|
|
# endif
|
41 |
|
|
# include <stdio.h>
|
42 |
|
|
/* Get va_list definition. */
|
43 |
|
|
# define __need___va_list
|
44 |
|
|
# include <stdarg.h>
|
45 |
|
|
|
46 |
|
|
/* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */
|
47 |
|
|
# define __need_size_t
|
48 |
|
|
# define __need_wchar_t
|
49 |
|
|
# define __need_NULL
|
50 |
|
|
#endif
|
51 |
|
|
#define __need_wint_t
|
52 |
|
|
#include <stddef.h>
|
53 |
|
|
|
54 |
|
|
#include <bits/wchar.h>
|
55 |
|
|
|
56 |
|
|
/* We try to get wint_t from <stddef.h>, but not all GCC versions define it
|
57 |
|
|
there. So define it ourselves if it remains undefined. */
|
58 |
|
|
#ifndef _WINT_T
|
59 |
|
|
/* Integral type unchanged by default argument promotions that can
|
60 |
|
|
hold any value corresponding to members of the extended character
|
61 |
|
|
set, as well as at least one value that does not correspond to any
|
62 |
|
|
member of the extended character set. */
|
63 |
|
|
# define _WINT_T
|
64 |
|
|
typedef unsigned int wint_t;
|
65 |
|
|
#else
|
66 |
|
|
/* Work around problems with the <stddef.h> file which doesn't put
|
67 |
|
|
wint_t in the std namespace. */
|
68 |
|
|
# if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES \
|
69 |
|
|
&& defined __WINT_TYPE__
|
70 |
|
|
__BEGIN_NAMESPACE_STD
|
71 |
|
|
typedef __WINT_TYPE__ wint_t;
|
72 |
|
|
__END_NAMESPACE_STD
|
73 |
|
|
# endif
|
74 |
|
|
#endif
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
#ifndef __mbstate_t_defined
|
78 |
|
|
# define __mbstate_t_defined 1
|
79 |
|
|
/* Conversion state information. */
|
80 |
|
|
#if 1
|
81 |
|
|
typedef struct
|
82 |
|
|
{
|
83 |
|
|
wchar_t __mask;
|
84 |
|
|
wchar_t __wc;
|
85 |
|
|
} __mbstate_t;
|
86 |
|
|
#else
|
87 |
|
|
typedef struct
|
88 |
|
|
{
|
89 |
|
|
int __count;
|
90 |
|
|
union
|
91 |
|
|
{
|
92 |
|
|
wint_t __wch;
|
93 |
|
|
char __wchb[4];
|
94 |
|
|
} __value; /* Value so far. */
|
95 |
|
|
} __mbstate_t;
|
96 |
|
|
#endif
|
97 |
|
|
#endif
|
98 |
|
|
#undef __need_mbstate_t
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
/* The rest of the file is only used if used if __need_mbstate_t is not
|
102 |
|
|
defined. */
|
103 |
|
|
#ifdef _WCHAR_H
|
104 |
|
|
|
105 |
|
|
__BEGIN_NAMESPACE_C99
|
106 |
|
|
/* Public type. */
|
107 |
|
|
typedef __mbstate_t mbstate_t;
|
108 |
|
|
__END_NAMESPACE_C99
|
109 |
|
|
#ifdef __USE_GNU
|
110 |
|
|
__USING_NAMESPACE_C99(mbstate_t)
|
111 |
|
|
#endif
|
112 |
|
|
|
113 |
|
|
#ifndef WCHAR_MIN
|
114 |
|
|
/* These constants might also be defined in <inttypes.h>. */
|
115 |
|
|
# define WCHAR_MIN __WCHAR_MIN
|
116 |
|
|
# define WCHAR_MAX __WCHAR_MAX
|
117 |
|
|
#endif
|
118 |
|
|
|
119 |
|
|
#ifndef WEOF
|
120 |
|
|
# define WEOF (0xffffffffu)
|
121 |
|
|
#endif
|
122 |
|
|
|
123 |
|
|
/* For XPG4 compliance we have to define the stuff from <wctype.h> here
|
124 |
|
|
as well. */
|
125 |
|
|
#if defined __USE_XOPEN && !defined __USE_UNIX98
|
126 |
|
|
# include <wctype.h>
|
127 |
|
|
#endif
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
__BEGIN_DECLS
|
131 |
|
|
|
132 |
|
|
__BEGIN_NAMESPACE_STD
|
133 |
|
|
/* This incomplete type is defined in <time.h> but needed here because
|
134 |
|
|
of `wcsftime'. */
|
135 |
|
|
struct tm;
|
136 |
|
|
/* XXX We have to clean this up at some point. Since tm is in the std
|
137 |
|
|
namespace but wcsftime is in __c99 the type wouldn't be found
|
138 |
|
|
without inserting it in the global namespace. */
|
139 |
|
|
__USING_NAMESPACE_STD(tm)
|
140 |
|
|
__END_NAMESPACE_STD
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
__BEGIN_NAMESPACE_C99
|
144 |
|
|
/* Copy SRC to DEST. */
|
145 |
|
|
extern wchar_t *wcscpy (wchar_t *__restrict __dest,
|
146 |
|
|
__const wchar_t *__restrict __src) __THROW;
|
147 |
|
|
/* Copy no more than N wide-characters of SRC to DEST. */
|
148 |
|
|
extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
|
149 |
|
|
__const wchar_t *__restrict __src, size_t __n)
|
150 |
|
|
__THROW;
|
151 |
|
|
|
152 |
|
|
/* Append SRC onto DEST. */
|
153 |
|
|
extern wchar_t *wcscat (wchar_t *__restrict __dest,
|
154 |
|
|
__const wchar_t *__restrict __src) __THROW;
|
155 |
|
|
/* Append no more than N wide-characters of SRC onto DEST. */
|
156 |
|
|
extern wchar_t *wcsncat (wchar_t *__restrict __dest,
|
157 |
|
|
__const wchar_t *__restrict __src, size_t __n)
|
158 |
|
|
__THROW;
|
159 |
|
|
|
160 |
|
|
/* Compare S1 and S2. */
|
161 |
|
|
extern int wcscmp (__const wchar_t *__s1, __const wchar_t *__s2)
|
162 |
|
|
__THROW __attribute_pure__;
|
163 |
|
|
/* Compare N wide-characters of S1 and S2. */
|
164 |
|
|
extern int wcsncmp (__const wchar_t *__s1, __const wchar_t *__s2, size_t __n)
|
165 |
|
|
__THROW __attribute_pure__;
|
166 |
|
|
__END_NAMESPACE_C99
|
167 |
|
|
|
168 |
|
|
#ifdef __USE_GNU
|
169 |
|
|
/* Compare S1 and S2, ignoring case. */
|
170 |
|
|
extern int wcscasecmp (__const wchar_t *__s1, __const wchar_t *__s2) __THROW;
|
171 |
|
|
|
172 |
|
|
/* Compare no more than N chars of S1 and S2, ignoring case. */
|
173 |
|
|
extern int wcsncasecmp (__const wchar_t *__s1, __const wchar_t *__s2,
|
174 |
|
|
size_t __n) __THROW;
|
175 |
|
|
|
176 |
|
|
#ifdef __UCLIBC_HAS_XLOCALE__
|
177 |
|
|
/* Similar to the two functions above but take the information from
|
178 |
|
|
the provided locale and not the global locale. */
|
179 |
|
|
# include <xlocale.h>
|
180 |
|
|
|
181 |
|
|
extern int wcscasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
|
182 |
|
|
__locale_t __loc) __THROW;
|
183 |
|
|
|
184 |
|
|
extern int wcsncasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
|
185 |
|
|
size_t __n, __locale_t __loc) __THROW;
|
186 |
|
|
#endif /* __UCLIBC_HAS_XLOCALE__ */
|
187 |
|
|
#endif
|
188 |
|
|
|
189 |
|
|
__BEGIN_NAMESPACE_C99
|
190 |
|
|
/* Compare S1 and S2, both interpreted as appropriate to the
|
191 |
|
|
LC_COLLATE category of the current locale. */
|
192 |
|
|
extern int wcscoll (__const wchar_t *__s1, __const wchar_t *__s2) __THROW;
|
193 |
|
|
/* Transform S2 into array pointed to by S1 such that if wcscmp is
|
194 |
|
|
applied to two transformed strings the result is the as applying
|
195 |
|
|
`wcscoll' to the original strings. */
|
196 |
|
|
extern size_t wcsxfrm (wchar_t *__restrict __s1,
|
197 |
|
|
__const wchar_t *__restrict __s2, size_t __n) __THROW;
|
198 |
|
|
__END_NAMESPACE_C99
|
199 |
|
|
|
200 |
|
|
#ifdef __USE_GNU
|
201 |
|
|
#ifdef __UCLIBC_HAS_XLOCALE__
|
202 |
|
|
/* Similar to the two functions above but take the information from
|
203 |
|
|
the provided locale and not the global locale. */
|
204 |
|
|
|
205 |
|
|
/* Compare S1 and S2, both interpreted as appropriate to the
|
206 |
|
|
LC_COLLATE category of the given locale. */
|
207 |
|
|
extern int wcscoll_l (__const wchar_t *__s1, __const wchar_t *__s2,
|
208 |
|
|
__locale_t __loc) __THROW;
|
209 |
|
|
|
210 |
|
|
/* Transform S2 into array pointed to by S1 such that if wcscmp is
|
211 |
|
|
applied to two transformed strings the result is the as applying
|
212 |
|
|
`wcscoll' to the original strings. */
|
213 |
|
|
extern size_t wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2,
|
214 |
|
|
size_t __n, __locale_t __loc) __THROW;
|
215 |
|
|
|
216 |
|
|
#endif /* __UCLIBC_HAS_XLOCALE__ */
|
217 |
|
|
|
218 |
|
|
/* Duplicate S, returning an identical malloc'd string. */
|
219 |
|
|
extern wchar_t *wcsdup (__const wchar_t *__s) __THROW __attribute_malloc__;
|
220 |
|
|
#endif
|
221 |
|
|
|
222 |
|
|
__BEGIN_NAMESPACE_C99
|
223 |
|
|
/* Find the first occurrence of WC in WCS. */
|
224 |
|
|
extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc)
|
225 |
|
|
__THROW __attribute_pure__;
|
226 |
|
|
/* Find the last occurrence of WC in WCS. */
|
227 |
|
|
extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc)
|
228 |
|
|
__THROW __attribute_pure__;
|
229 |
|
|
__END_NAMESPACE_C99
|
230 |
|
|
|
231 |
|
|
#ifdef __USE_GNU
|
232 |
|
|
/* This function is similar to `wcschr'. But it returns a pointer to
|
233 |
|
|
the closing NUL wide character in case C is not found in S. */
|
234 |
|
|
extern wchar_t *wcschrnul (__const wchar_t *__s, wchar_t __wc)
|
235 |
|
|
__THROW __attribute_pure__;
|
236 |
|
|
#endif
|
237 |
|
|
|
238 |
|
|
__BEGIN_NAMESPACE_C99
|
239 |
|
|
/* Return the length of the initial segmet of WCS which
|
240 |
|
|
consists entirely of wide characters not in REJECT. */
|
241 |
|
|
extern size_t wcscspn (__const wchar_t *__wcs, __const wchar_t *__reject)
|
242 |
|
|
__THROW __attribute_pure__;
|
243 |
|
|
/* Return the length of the initial segmet of WCS which
|
244 |
|
|
consists entirely of wide characters in ACCEPT. */
|
245 |
|
|
extern size_t wcsspn (__const wchar_t *__wcs, __const wchar_t *__accept)
|
246 |
|
|
__THROW __attribute_pure__;
|
247 |
|
|
/* Find the first occurrence in WCS of any character in ACCEPT. */
|
248 |
|
|
extern wchar_t *wcspbrk (__const wchar_t *__wcs, __const wchar_t *__accept)
|
249 |
|
|
__THROW __attribute_pure__;
|
250 |
|
|
/* Find the first occurrence of NEEDLE in HAYSTACK. */
|
251 |
|
|
extern wchar_t *wcsstr (__const wchar_t *__haystack, __const wchar_t *__needle)
|
252 |
|
|
__THROW __attribute_pure__;
|
253 |
|
|
|
254 |
|
|
/* Divide WCS into tokens separated by characters in DELIM. */
|
255 |
|
|
extern wchar_t *wcstok (wchar_t *__restrict __s,
|
256 |
|
|
__const wchar_t *__restrict __delim,
|
257 |
|
|
wchar_t **__restrict __ptr) __THROW;
|
258 |
|
|
|
259 |
|
|
/* Return the number of wide characters in S. */
|
260 |
|
|
extern size_t wcslen (__const wchar_t *__s) __THROW __attribute_pure__;
|
261 |
|
|
__END_NAMESPACE_C99
|
262 |
|
|
|
263 |
|
|
#ifdef __USE_XOPEN
|
264 |
|
|
/* Another name for `wcsstr' from XPG4. */
|
265 |
|
|
extern wchar_t *wcswcs (__const wchar_t *__haystack, __const wchar_t *__needle)
|
266 |
|
|
__THROW __attribute_pure__;
|
267 |
|
|
#endif
|
268 |
|
|
|
269 |
|
|
#ifdef __USE_GNU
|
270 |
|
|
/* Return the number of wide characters in S, but at most MAXLEN. */
|
271 |
|
|
extern size_t wcsnlen (__const wchar_t *__s, size_t __maxlen)
|
272 |
|
|
__THROW __attribute_pure__;
|
273 |
|
|
#endif
|
274 |
|
|
|
275 |
|
|
|
276 |
|
|
__BEGIN_NAMESPACE_C99
|
277 |
|
|
/* Search N wide characters of S for C. */
|
278 |
|
|
extern wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n)
|
279 |
|
|
__THROW __attribute_pure__;
|
280 |
|
|
|
281 |
|
|
/* Compare N wide characters of S1 and S2. */
|
282 |
|
|
extern int wmemcmp (__const wchar_t *__restrict __s1,
|
283 |
|
|
__const wchar_t *__restrict __s2, size_t __n)
|
284 |
|
|
__THROW __attribute_pure__;
|
285 |
|
|
|
286 |
|
|
/* Copy N wide characters of SRC to DEST. */
|
287 |
|
|
extern wchar_t *wmemcpy (wchar_t *__restrict __s1,
|
288 |
|
|
__const wchar_t *__restrict __s2, size_t __n) __THROW;
|
289 |
|
|
|
290 |
|
|
/* Copy N wide characters of SRC to DEST, guaranteeing
|
291 |
|
|
correct behavior for overlapping strings. */
|
292 |
|
|
extern wchar_t *wmemmove (wchar_t *__s1, __const wchar_t *__s2, size_t __n)
|
293 |
|
|
__THROW;
|
294 |
|
|
|
295 |
|
|
/* Set N wide characters of S to C. */
|
296 |
|
|
extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
|
297 |
|
|
__END_NAMESPACE_C99
|
298 |
|
|
|
299 |
|
|
#ifdef __USE_GNU
|
300 |
|
|
/* Copy N wide characters of SRC to DEST and return pointer to following
|
301 |
|
|
wide character. */
|
302 |
|
|
extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
|
303 |
|
|
__const wchar_t *__restrict __s2, size_t __n)
|
304 |
|
|
__THROW;
|
305 |
|
|
#endif
|
306 |
|
|
|
307 |
|
|
|
308 |
|
|
__BEGIN_NAMESPACE_C99
|
309 |
|
|
/* Determine whether C constitutes a valid (one-byte) multibyte
|
310 |
|
|
character. */
|
311 |
|
|
extern wint_t btowc (int __c) __THROW;
|
312 |
|
|
|
313 |
|
|
/* Determine whether C corresponds to a member of the extended
|
314 |
|
|
character set whose multibyte representation is a single byte. */
|
315 |
|
|
extern int wctob (wint_t __c) __THROW;
|
316 |
|
|
|
317 |
|
|
/* Determine whether PS points to an object representing the initial
|
318 |
|
|
state. */
|
319 |
|
|
extern int mbsinit (__const mbstate_t *__ps) __THROW __attribute_pure__;
|
320 |
|
|
|
321 |
|
|
/* Write wide character representation of multibyte character pointed
|
322 |
|
|
to by S to PWC. */
|
323 |
|
|
extern size_t mbrtowc (wchar_t *__restrict __pwc,
|
324 |
|
|
__const char *__restrict __s, size_t __n,
|
325 |
|
|
mbstate_t *__p) __THROW;
|
326 |
|
|
|
327 |
|
|
/* Write multibyte representation of wide character WC to S. */
|
328 |
|
|
extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
|
329 |
|
|
mbstate_t *__restrict __ps) __THROW;
|
330 |
|
|
|
331 |
|
|
/* Return number of bytes in multibyte character pointed to by S. */
|
332 |
|
|
#if 0 /* uClibc: disabled */
|
333 |
|
|
extern size_t __mbrlen (__const char *__restrict __s, size_t __n,
|
334 |
|
|
mbstate_t *__restrict __ps) __THROW;
|
335 |
|
|
#endif
|
336 |
|
|
extern size_t mbrlen (__const char *__restrict __s, size_t __n,
|
337 |
|
|
mbstate_t *__restrict __ps) __THROW;
|
338 |
|
|
|
339 |
|
|
/* Write wide character representation of multibyte character string
|
340 |
|
|
SRC to DST. */
|
341 |
|
|
extern size_t mbsrtowcs (wchar_t *__restrict __dst,
|
342 |
|
|
__const char **__restrict __src, size_t __len,
|
343 |
|
|
mbstate_t *__restrict __ps) __THROW;
|
344 |
|
|
|
345 |
|
|
/* Write multibyte character representation of wide character string
|
346 |
|
|
SRC to DST. */
|
347 |
|
|
extern size_t wcsrtombs (char *__restrict __dst,
|
348 |
|
|
__const wchar_t **__restrict __src, size_t __len,
|
349 |
|
|
mbstate_t *__restrict __ps) __THROW;
|
350 |
|
|
__END_NAMESPACE_C99
|
351 |
|
|
|
352 |
|
|
|
353 |
|
|
#ifdef __USE_GNU
|
354 |
|
|
/* Write wide character representation of at most NMC bytes of the
|
355 |
|
|
multibyte character string SRC to DST. */
|
356 |
|
|
extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
|
357 |
|
|
__const char **__restrict __src, size_t __nmc,
|
358 |
|
|
size_t __len, mbstate_t *__restrict __ps) __THROW;
|
359 |
|
|
|
360 |
|
|
/* Write multibyte character representation of at most NWC characters
|
361 |
|
|
from the wide character string SRC to DST. */
|
362 |
|
|
extern size_t wcsnrtombs (char *__restrict __dst,
|
363 |
|
|
__const wchar_t **__restrict __src,
|
364 |
|
|
size_t __nwc, size_t __len,
|
365 |
|
|
mbstate_t *__restrict __ps) __THROW;
|
366 |
|
|
#endif /* use GNU */
|
367 |
|
|
|
368 |
|
|
|
369 |
|
|
/* The following functions are extensions found in X/Open CAE. */
|
370 |
|
|
#ifdef __USE_XOPEN
|
371 |
|
|
/* Determine number of column positions required for C. */
|
372 |
|
|
extern int wcwidth (wchar_t __c) __THROW;
|
373 |
|
|
|
374 |
|
|
/* Determine number of column positions required for first N wide
|
375 |
|
|
characters (or fewer if S ends before this) in S. */
|
376 |
|
|
extern int wcswidth (__const wchar_t *__s, size_t __n) __THROW;
|
377 |
|
|
#endif /* Use X/Open. */
|
378 |
|
|
|
379 |
|
|
|
380 |
|
|
__BEGIN_NAMESPACE_C99
|
381 |
|
|
#ifdef __UCLIBC_HAS_FLOATS__
|
382 |
|
|
/* Convert initial portion of the wide string NPTR to `double'
|
383 |
|
|
representation. */
|
384 |
|
|
extern double wcstod (__const wchar_t *__restrict __nptr,
|
385 |
|
|
wchar_t **__restrict __endptr) __THROW;
|
386 |
|
|
|
387 |
|
|
#ifdef __USE_ISOC99
|
388 |
|
|
/* Likewise for `float' and `long double' sizes of floating-point numbers. */
|
389 |
|
|
extern float wcstof (__const wchar_t *__restrict __nptr,
|
390 |
|
|
wchar_t **__restrict __endptr) __THROW;
|
391 |
|
|
extern long double wcstold (__const wchar_t *__restrict __nptr,
|
392 |
|
|
wchar_t **__restrict __endptr) __THROW;
|
393 |
|
|
#endif /* C99 */
|
394 |
|
|
#endif /* __UCLIBC_HAS_FLOATS__ */
|
395 |
|
|
|
396 |
|
|
|
397 |
|
|
/* Convert initial portion of wide string NPTR to `long int'
|
398 |
|
|
representation. */
|
399 |
|
|
extern long int wcstol (__const wchar_t *__restrict __nptr,
|
400 |
|
|
wchar_t **__restrict __endptr, int __base) __THROW;
|
401 |
|
|
|
402 |
|
|
/* Convert initial portion of wide string NPTR to `unsigned long int'
|
403 |
|
|
representation. */
|
404 |
|
|
extern unsigned long int wcstoul (__const wchar_t *__restrict __nptr,
|
405 |
|
|
wchar_t **__restrict __endptr, int __base)
|
406 |
|
|
__THROW;
|
407 |
|
|
|
408 |
|
|
#if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_GNU)
|
409 |
|
|
/* Convert initial portion of wide string NPTR to `long int'
|
410 |
|
|
representation. */
|
411 |
|
|
__extension__
|
412 |
|
|
extern long long int wcstoll (__const wchar_t *__restrict __nptr,
|
413 |
|
|
wchar_t **__restrict __endptr, int __base)
|
414 |
|
|
__THROW;
|
415 |
|
|
|
416 |
|
|
/* Convert initial portion of wide string NPTR to `unsigned long long int'
|
417 |
|
|
representation. */
|
418 |
|
|
__extension__
|
419 |
|
|
extern unsigned long long int wcstoull (__const wchar_t *__restrict __nptr,
|
420 |
|
|
wchar_t **__restrict __endptr,
|
421 |
|
|
int __base) __THROW;
|
422 |
|
|
#endif /* ISO C99 or GCC and GNU. */
|
423 |
|
|
__END_NAMESPACE_C99
|
424 |
|
|
|
425 |
|
|
#if defined __GNUC__ && defined __USE_GNU
|
426 |
|
|
/* Convert initial portion of wide string NPTR to `long int'
|
427 |
|
|
representation. */
|
428 |
|
|
__extension__
|
429 |
|
|
extern long long int wcstoq (__const wchar_t *__restrict __nptr,
|
430 |
|
|
wchar_t **__restrict __endptr, int __base)
|
431 |
|
|
__THROW;
|
432 |
|
|
|
433 |
|
|
/* Convert initial portion of wide string NPTR to `unsigned long long int'
|
434 |
|
|
representation. */
|
435 |
|
|
__extension__
|
436 |
|
|
extern unsigned long long int wcstouq (__const wchar_t *__restrict __nptr,
|
437 |
|
|
wchar_t **__restrict __endptr,
|
438 |
|
|
int __base) __THROW;
|
439 |
|
|
#endif /* GCC and use GNU. */
|
440 |
|
|
|
441 |
|
|
#ifdef __USE_GNU
|
442 |
|
|
#ifdef __UCLIBC_HAS_XLOCALE__
|
443 |
|
|
/* The concept of one static locale per category is not very well
|
444 |
|
|
thought out. Many applications will need to process its data using
|
445 |
|
|
information from several different locales. Another application is
|
446 |
|
|
the implementation of the internationalization handling in the
|
447 |
|
|
upcoming ISO C++ standard library. To support this another set of
|
448 |
|
|
the functions using locale data exist which have an additional
|
449 |
|
|
argument.
|
450 |
|
|
|
451 |
|
|
Attention: all these functions are *not* standardized in any form.
|
452 |
|
|
This is a proof-of-concept implementation. */
|
453 |
|
|
|
454 |
|
|
/* Structure for reentrant locale using functions. This is an
|
455 |
|
|
(almost) opaque type for the user level programs. */
|
456 |
|
|
# include <xlocale.h>
|
457 |
|
|
|
458 |
|
|
/* Special versions of the functions above which take the locale to
|
459 |
|
|
use as an additional parameter. */
|
460 |
|
|
extern long int wcstol_l (__const wchar_t *__restrict __nptr,
|
461 |
|
|
wchar_t **__restrict __endptr, int __base,
|
462 |
|
|
__locale_t __loc) __THROW;
|
463 |
|
|
|
464 |
|
|
extern unsigned long int wcstoul_l (__const wchar_t *__restrict __nptr,
|
465 |
|
|
wchar_t **__restrict __endptr,
|
466 |
|
|
int __base, __locale_t __loc) __THROW;
|
467 |
|
|
|
468 |
|
|
__extension__
|
469 |
|
|
extern long long int wcstoll_l (__const wchar_t *__restrict __nptr,
|
470 |
|
|
wchar_t **__restrict __endptr,
|
471 |
|
|
int __base, __locale_t __loc) __THROW;
|
472 |
|
|
|
473 |
|
|
__extension__
|
474 |
|
|
extern unsigned long long int wcstoull_l (__const wchar_t *__restrict __nptr,
|
475 |
|
|
wchar_t **__restrict __endptr,
|
476 |
|
|
int __base, __locale_t __loc)
|
477 |
|
|
__THROW;
|
478 |
|
|
|
479 |
|
|
#ifdef __UCLIBC_HAS_FLOATS__
|
480 |
|
|
extern double wcstod_l (__const wchar_t *__restrict __nptr,
|
481 |
|
|
wchar_t **__restrict __endptr, __locale_t __loc)
|
482 |
|
|
__THROW;
|
483 |
|
|
|
484 |
|
|
extern float wcstof_l (__const wchar_t *__restrict __nptr,
|
485 |
|
|
wchar_t **__restrict __endptr, __locale_t __loc)
|
486 |
|
|
__THROW;
|
487 |
|
|
|
488 |
|
|
extern long double wcstold_l (__const wchar_t *__restrict __nptr,
|
489 |
|
|
wchar_t **__restrict __endptr,
|
490 |
|
|
__locale_t __loc) __THROW;
|
491 |
|
|
#endif /* __UCLIBC_HAS_FLOATS__ */
|
492 |
|
|
#endif /* __UCLIBC_HAS_XLOCALE__ */
|
493 |
|
|
#endif /* GNU */
|
494 |
|
|
|
495 |
|
|
|
496 |
|
|
#ifdef __USE_GNU
|
497 |
|
|
/* Copy SRC to DEST, returning the address of the terminating L'\0' in
|
498 |
|
|
DEST. */
|
499 |
|
|
extern wchar_t *wcpcpy (wchar_t *__dest, __const wchar_t *__src) __THROW;
|
500 |
|
|
|
501 |
|
|
/* Copy no more than N characters of SRC to DEST, returning the address of
|
502 |
|
|
the last character written into DEST. */
|
503 |
|
|
extern wchar_t *wcpncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n)
|
504 |
|
|
__THROW;
|
505 |
|
|
#endif /* use GNU */
|
506 |
|
|
|
507 |
|
|
|
508 |
|
|
/* Wide character I/O functions. */
|
509 |
|
|
#if defined __USE_ISOC99 || defined __USE_UNIX98
|
510 |
|
|
__BEGIN_NAMESPACE_C99
|
511 |
|
|
|
512 |
|
|
/* Select orientation for stream. */
|
513 |
|
|
extern int fwide (__FILE *__fp, int __mode) __THROW;
|
514 |
|
|
|
515 |
|
|
|
516 |
|
|
/* Write formatted output to STREAM.
|
517 |
|
|
|
518 |
|
|
This function is a possible cancellation point and therefore not
|
519 |
|
|
marked with __THROW. */
|
520 |
|
|
extern int fwprintf (__FILE *__restrict __stream,
|
521 |
|
|
__const wchar_t *__restrict __format, ...)
|
522 |
|
|
/* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
|
523 |
|
|
/* Write formatted output to stdout.
|
524 |
|
|
|
525 |
|
|
This function is a possible cancellation point and therefore not
|
526 |
|
|
marked with __THROW. */
|
527 |
|
|
extern int wprintf (__const wchar_t *__restrict __format, ...)
|
528 |
|
|
/* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
|
529 |
|
|
/* Write formatted output of at most N characters to S. */
|
530 |
|
|
extern int swprintf (wchar_t *__restrict __s, size_t __n,
|
531 |
|
|
__const wchar_t *__restrict __format, ...)
|
532 |
|
|
__THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
|
533 |
|
|
|
534 |
|
|
/* Write formatted output to S from argument list ARG.
|
535 |
|
|
|
536 |
|
|
This function is a possible cancellation point and therefore not
|
537 |
|
|
marked with __THROW. */
|
538 |
|
|
extern int vfwprintf (__FILE *__restrict __s,
|
539 |
|
|
__const wchar_t *__restrict __format,
|
540 |
|
|
__gnuc_va_list __arg)
|
541 |
|
|
/* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
|
542 |
|
|
/* Write formatted output to stdout from argument list ARG.
|
543 |
|
|
|
544 |
|
|
This function is a possible cancellation point and therefore not
|
545 |
|
|
marked with __THROW. */
|
546 |
|
|
extern int vwprintf (__const wchar_t *__restrict __format,
|
547 |
|
|
__gnuc_va_list __arg)
|
548 |
|
|
/* __attribute__ ((__format__ (__wprintf__, 1, 0))) */;
|
549 |
|
|
/* Write formatted output of at most N character to S from argument
|
550 |
|
|
list ARG. */
|
551 |
|
|
extern int vswprintf (wchar_t *__restrict __s, size_t __n,
|
552 |
|
|
__const wchar_t *__restrict __format,
|
553 |
|
|
__gnuc_va_list __arg)
|
554 |
|
|
__THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
|
555 |
|
|
|
556 |
|
|
|
557 |
|
|
/* Read formatted input from STREAM.
|
558 |
|
|
|
559 |
|
|
This function is a possible cancellation point and therefore not
|
560 |
|
|
marked with __THROW. */
|
561 |
|
|
extern int fwscanf (__FILE *__restrict __stream,
|
562 |
|
|
__const wchar_t *__restrict __format, ...)
|
563 |
|
|
/* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
|
564 |
|
|
/* Read formatted input from stdin.
|
565 |
|
|
|
566 |
|
|
This function is a possible cancellation point and therefore not
|
567 |
|
|
marked with __THROW. */
|
568 |
|
|
extern int wscanf (__const wchar_t *__restrict __format, ...)
|
569 |
|
|
/* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
|
570 |
|
|
/* Read formatted input from S. */
|
571 |
|
|
extern int swscanf (__const wchar_t *__restrict __s,
|
572 |
|
|
__const wchar_t *__restrict __format, ...)
|
573 |
|
|
__THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
|
574 |
|
|
|
575 |
|
|
__END_NAMESPACE_C99
|
576 |
|
|
#endif /* Use ISO C99 and Unix98. */
|
577 |
|
|
|
578 |
|
|
#ifdef __USE_ISOC99
|
579 |
|
|
__BEGIN_NAMESPACE_C99
|
580 |
|
|
|
581 |
|
|
/* Read formatted input from S into argument list ARG.
|
582 |
|
|
|
583 |
|
|
This function is a possible cancellation point and therefore not
|
584 |
|
|
marked with __THROW. */
|
585 |
|
|
extern int vfwscanf (__FILE *__restrict __s,
|
586 |
|
|
__const wchar_t *__restrict __format,
|
587 |
|
|
__gnuc_va_list __arg)
|
588 |
|
|
/* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
|
589 |
|
|
/* Read formatted input from stdin into argument list ARG.
|
590 |
|
|
|
591 |
|
|
This function is a possible cancellation point and therefore not
|
592 |
|
|
marked with __THROW. */
|
593 |
|
|
extern int vwscanf (__const wchar_t *__restrict __format,
|
594 |
|
|
__gnuc_va_list __arg)
|
595 |
|
|
/* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
|
596 |
|
|
/* Read formatted input from S into argument list ARG. */
|
597 |
|
|
extern int vswscanf (__const wchar_t *__restrict __s,
|
598 |
|
|
__const wchar_t *__restrict __format,
|
599 |
|
|
__gnuc_va_list __arg)
|
600 |
|
|
__THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
|
601 |
|
|
|
602 |
|
|
__END_NAMESPACE_C99
|
603 |
|
|
#endif /* Use ISO C99. */
|
604 |
|
|
|
605 |
|
|
|
606 |
|
|
__BEGIN_NAMESPACE_C99
|
607 |
|
|
/* Read a character from STREAM.
|
608 |
|
|
|
609 |
|
|
These functions are possible cancellation points and therefore not
|
610 |
|
|
marked with __THROW. */
|
611 |
|
|
extern wint_t fgetwc (__FILE *__stream);
|
612 |
|
|
extern wint_t getwc (__FILE *__stream);
|
613 |
|
|
|
614 |
|
|
/* Read a character from stdin.
|
615 |
|
|
|
616 |
|
|
This function is a possible cancellation point and therefore not
|
617 |
|
|
marked with __THROW. */
|
618 |
|
|
extern wint_t getwchar (void);
|
619 |
|
|
|
620 |
|
|
|
621 |
|
|
/* Write a character to STREAM.
|
622 |
|
|
|
623 |
|
|
These functions are possible cancellation points and therefore not
|
624 |
|
|
marked with __THROW. */
|
625 |
|
|
extern wint_t fputwc (wchar_t __wc, __FILE *__stream);
|
626 |
|
|
extern wint_t putwc (wchar_t __wc, __FILE *__stream);
|
627 |
|
|
|
628 |
|
|
/* Write a character to stdout.
|
629 |
|
|
|
630 |
|
|
This function is a possible cancellation points and therefore not
|
631 |
|
|
marked with __THROW. */
|
632 |
|
|
extern wint_t putwchar (wchar_t __wc);
|
633 |
|
|
|
634 |
|
|
|
635 |
|
|
/* Get a newline-terminated wide character string of finite length
|
636 |
|
|
from STREAM.
|
637 |
|
|
|
638 |
|
|
This function is a possible cancellation points and therefore not
|
639 |
|
|
marked with __THROW. */
|
640 |
|
|
extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
|
641 |
|
|
__FILE *__restrict __stream);
|
642 |
|
|
|
643 |
|
|
/* Write a string to STREAM.
|
644 |
|
|
|
645 |
|
|
This function is a possible cancellation points and therefore not
|
646 |
|
|
marked with __THROW. */
|
647 |
|
|
extern int fputws (__const wchar_t *__restrict __ws,
|
648 |
|
|
__FILE *__restrict __stream);
|
649 |
|
|
|
650 |
|
|
|
651 |
|
|
/* Push a character back onto the input buffer of STREAM.
|
652 |
|
|
|
653 |
|
|
This function is a possible cancellation points and therefore not
|
654 |
|
|
marked with __THROW. */
|
655 |
|
|
extern wint_t ungetwc (wint_t __wc, __FILE *__stream);
|
656 |
|
|
__END_NAMESPACE_C99
|
657 |
|
|
|
658 |
|
|
|
659 |
|
|
#ifdef __USE_GNU
|
660 |
|
|
/* These are defined to be equivalent to the `char' functions defined
|
661 |
|
|
in POSIX.1:1996.
|
662 |
|
|
|
663 |
|
|
These functions are not part of POSIX and therefore no official
|
664 |
|
|
cancellation point. But due to similarity with an POSIX interface
|
665 |
|
|
or due to the implementation they are cancellation points and
|
666 |
|
|
therefore not marked with __THROW. */
|
667 |
|
|
extern wint_t getwc_unlocked (__FILE *__stream);
|
668 |
|
|
extern wint_t getwchar_unlocked (void);
|
669 |
|
|
|
670 |
|
|
/* This is the wide character version of a GNU extension.
|
671 |
|
|
|
672 |
|
|
This function is not part of POSIX and therefore no official
|
673 |
|
|
cancellation point. But due to similarity with an POSIX interface
|
674 |
|
|
or due to the implementation it is a cancellation point and
|
675 |
|
|
therefore not marked with __THROW. */
|
676 |
|
|
extern wint_t fgetwc_unlocked (__FILE *__stream);
|
677 |
|
|
|
678 |
|
|
/* Faster version when locking is not necessary.
|
679 |
|
|
|
680 |
|
|
This function is not part of POSIX and therefore no official
|
681 |
|
|
cancellation point. But due to similarity with an POSIX interface
|
682 |
|
|
or due to the implementation it is a cancellation point and
|
683 |
|
|
therefore not marked with __THROW. */
|
684 |
|
|
extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream);
|
685 |
|
|
|
686 |
|
|
/* These are defined to be equivalent to the `char' functions defined
|
687 |
|
|
in POSIX.1:1996.
|
688 |
|
|
|
689 |
|
|
These functions are not part of POSIX and therefore no official
|
690 |
|
|
cancellation point. But due to similarity with an POSIX interface
|
691 |
|
|
or due to the implementation they are cancellation points and
|
692 |
|
|
therefore not marked with __THROW. */
|
693 |
|
|
extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream);
|
694 |
|
|
extern wint_t putwchar_unlocked (wchar_t __wc);
|
695 |
|
|
|
696 |
|
|
|
697 |
|
|
/* This function does the same as `fgetws' but does not lock the stream.
|
698 |
|
|
|
699 |
|
|
This function is not part of POSIX and therefore no official
|
700 |
|
|
cancellation point. But due to similarity with an POSIX interface
|
701 |
|
|
or due to the implementation it is a cancellation point and
|
702 |
|
|
therefore not marked with __THROW. */
|
703 |
|
|
extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
|
704 |
|
|
__FILE *__restrict __stream);
|
705 |
|
|
|
706 |
|
|
/* This function does the same as `fputws' but does not lock the stream.
|
707 |
|
|
|
708 |
|
|
This function is not part of POSIX and therefore no official
|
709 |
|
|
cancellation point. But due to similarity with an POSIX interface
|
710 |
|
|
or due to the implementation it is a cancellation point and
|
711 |
|
|
therefore not marked with __THROW. */
|
712 |
|
|
extern int fputws_unlocked (__const wchar_t *__restrict __ws,
|
713 |
|
|
__FILE *__restrict __stream);
|
714 |
|
|
#endif
|
715 |
|
|
|
716 |
|
|
|
717 |
|
|
__BEGIN_NAMESPACE_C99
|
718 |
|
|
/* Format TP into S according to FORMAT.
|
719 |
|
|
Write no more than MAXSIZE wide characters and return the number
|
720 |
|
|
of wide characters written, or 0 if it would exceed MAXSIZE. */
|
721 |
|
|
extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
|
722 |
|
|
__const wchar_t *__restrict __format,
|
723 |
|
|
__const struct tm *__restrict __tp) __THROW;
|
724 |
|
|
__END_NAMESPACE_C99
|
725 |
|
|
|
726 |
|
|
# if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
|
727 |
|
|
# include <xlocale.h>
|
728 |
|
|
|
729 |
|
|
/* Similar to `wcsftime' but takes the information from
|
730 |
|
|
the provided locale and not the global locale. */
|
731 |
|
|
extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
|
732 |
|
|
__const wchar_t *__restrict __format,
|
733 |
|
|
__const struct tm *__restrict __tp,
|
734 |
|
|
__locale_t __loc) __THROW;
|
735 |
|
|
# endif
|
736 |
|
|
|
737 |
|
|
/* The X/Open standard demands that most of the functions defined in
|
738 |
|
|
the <wctype.h> header must also appear here. This is probably
|
739 |
|
|
because some X/Open members wrote their implementation before the
|
740 |
|
|
ISO C standard was published and introduced the better solution.
|
741 |
|
|
We have to provide these definitions for compliance reasons but we
|
742 |
|
|
do this nonsense only if really necessary. */
|
743 |
|
|
#if defined __USE_UNIX98 && !defined __USE_GNU
|
744 |
|
|
# define __need_iswxxx
|
745 |
|
|
# include <wctype.h>
|
746 |
|
|
#endif
|
747 |
|
|
|
748 |
|
|
__END_DECLS
|
749 |
|
|
|
750 |
|
|
#endif /* _WCHAR_H defined */
|
751 |
|
|
|
752 |
|
|
#endif /* wchar.h */
|