1 #include "stdio_impl.h"
2 #include "locale_impl.h"
8 wint_t ungetwc(wint_t c
, FILE *f
)
10 unsigned char mbc
[MB_LEN_MAX
];
12 locale_t
*ploc
= &CURRENT_LOCALE
, loc
= *ploc
;
16 if (f
->mode
<= 0) fwide(f
, 1);
19 if (!f
->rpos
) __toread(f
);
20 if (!f
->rpos
|| c
== WEOF
|| (l
= wcrtomb((void *)mbc
, c
, 0)) < 0 ||
21 f
->rpos
< f
->buf
- UNGET
+ l
) {
27 if (isascii(c
)) *--f
->rpos
= c
;
28 else memcpy(f
->rpos
-= l
, mbc
, l
);