summaryrefslogtreecommitdiff
path: root/src/stdio/ungetwc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdio/ungetwc.c')
-rw-r--r--src/stdio/ungetwc.c5
1 files changed, 5 insertions, 0 deletions
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;
}