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