author | Rich Felker <dalias@aerifal.cx> | 2015年06月16日 05:35:31 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2015年06月16日 06:10:29 +0000 |
commit | 16f18d036d9a7bf590ee6eb86785c0a9658220b6 (patch) | |
tree | deb18b50c750e47dce2e0de0061f6de93cb11957 /src/stdio/ungetwc.c | |
parent | 1507ebf837334e9e07cfab1ca1c2e88449069a80 (diff) | |
download | musl-16f18d036d9a7bf590ee6eb86785c0a9658220b6.tar.gz |
-rw-r--r-- | src/stdio/ungetwc.c | 5 |
diff --git a/src/stdio/ungetwc.c b/src/stdio/ungetwc.c index d4c7de39..80d6e203 100644 --- a/src/stdio/ungetwc.c +++ b/src/stdio/ungetwc.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include "locale_impl.h" #include <wchar.h> #include <limits.h> #include <ctype.h> @@ -8,15 +9,18 @@ wint_t ungetwc(wint_t c, FILE *f) { unsigned char mbc[MB_LEN_MAX]; int l=1; + locale_t *ploc = &CURRENT_LOCALE, loc = *ploc; FLOCK(f); if (f->mode <= 0) fwide(f, 1); + *ploc = f->locale; if (!f->rpos) __toread(f); if (!f->rpos || f->rpos < f->buf - UNGET + l || c == WEOF || (!isascii(c) && (l = wctomb((void *)mbc, c)) < 0)) { FUNLOCK(f); + *ploc = loc; return WEOF; } @@ -26,5 +30,6 @@ wint_t ungetwc(wint_t c, FILE *f) f->flags &= ~F_EOF; FUNLOCK(f); + *ploc = loc; return c; } |