1 #include "stdio_impl.h"
2 #include "locale_impl.h"
6 static wint_t __fgetwc_unlocked_internal(FILE *f
)
12 /* Convert character from buffer if possible */
13 if (f
->rpos
!= f
->rend
) {
14 l
= mbtowc(&wc
, (void *)f
->rpos
, f
->rend
- f
->rpos
);
16 f
->rpos
+= l
+ !l
; /* l==0 means 1 byte, null */
21 /* Convert character byte-by-byte */
26 b
= c
= getc_unlocked(f
);
34 l
= mbrtowc(&wc
, (void *)&b
, 1, &st
);
48 wint_t __fgetwc_unlocked(FILE *f
)
50 locale_t
*ploc
= &CURRENT_LOCALE
, loc
= *ploc
;
51 if (f
->mode
<= 0) fwide(f
, 1);
53 wchar_t wc
= __fgetwc_unlocked_internal(f
);
58 wint_t fgetwc(FILE *f
)
62 c
= __fgetwc_unlocked(f
);
67 weak_alias(__fgetwc_unlocked
, fgetwc_unlocked
);
68 weak_alias(__fgetwc_unlocked
, getwc_unlocked
);