summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/ungetwc.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2004-04-07 09:55:05 +0000
committertjr <tjr@FreeBSD.org>2004-04-07 09:55:05 +0000
commit1c584f59a55cb440f0487854db33b28a08898f82 (patch)
tree12c84b3433d9dfe7221d8772b9282c58a3f99811 /lib/libc/stdio/ungetwc.c
parent226e976dd71faa4ff636611c2de2ce44dcce5ba9 (diff)
downloadFreeBSD-src-1c584f59a55cb440f0487854db33b28a08898f82.zip
FreeBSD-src-1c584f59a55cb440f0487854db33b28a08898f82.tar.gz
Prepare to handle trivial state-dependent encodings. Full support for
state-dependent encodings with locking shifts will come later if there is demand for it.
Diffstat (limited to 'lib/libc/stdio/ungetwc.c')
-rw-r--r--lib/libc/stdio/ungetwc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/stdio/ungetwc.c b/lib/libc/stdio/ungetwc.c
index c9d5c49..9ef4602 100644
--- a/lib/libc/stdio/ungetwc.c
+++ b/lib/libc/stdio/ungetwc.c
@@ -42,12 +42,15 @@ __FBSDID("$FreeBSD$");
wint_t
__ungetwc(wint_t wc, FILE *fp)
{
+ static const mbstate_t initial;
+ mbstate_t mbs;
char buf[MB_LEN_MAX];
size_t len;
if (wc == WEOF)
return (WEOF);
- if ((len = wcrtomb(buf, wc, NULL)) == (size_t)-1) {
+ mbs = initial;
+ if ((len = wcrtomb(buf, wc, &mbs)) == (size_t)-1) {
fp->_flags |= __SERR;
return (WEOF);
}
OpenPOWER on IntegriCloud