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