summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/ungetwc.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2004-05-22 15:19:41 +0000
committertjr <tjr@FreeBSD.org>2004-05-22 15:19:41 +0000
commitf5a461b2700c74383086e755fdaed26dc05d848c (patch)
treef6b3a5846b5b7d1a722dc68d0c48e70c32df2e55 /lib/libc/stdio/ungetwc.c
parent90c5701a2cddfda7b43823be60c581ef7dbd9bf0 (diff)
downloadFreeBSD-src-f5a461b2700c74383086e755fdaed26dc05d848c.zip
FreeBSD-src-f5a461b2700c74383086e755fdaed26dc05d848c.tar.gz
Associate a multibyte conversion state object with each stream. Reset it
to the initial state when a stream is opened or seeked upon. Use the stream's conversion state object instead of a freshly-zeroed one in fgetwc(), fputwc() and ungetwc(). This is only a performance improvement for now, but it would also be required in order to support state-dependent encodings.
Diffstat (limited to 'lib/libc/stdio/ungetwc.c')
-rw-r--r--lib/libc/stdio/ungetwc.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/libc/stdio/ungetwc.c b/lib/libc/stdio/ungetwc.c
index 9ef4602..28f873c 100644
--- a/lib/libc/stdio/ungetwc.c
+++ b/lib/libc/stdio/ungetwc.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2002 Tim J. Robbins.
+ * Copyright (c) 2002-2004 Tim J. Robbins.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -42,15 +42,12 @@ __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);
- mbs = initial;
- if ((len = wcrtomb(buf, wc, &mbs)) == (size_t)-1) {
+ if ((len = wcrtomb(buf, wc, &fp->_extra->mbstate)) == (size_t)-1) {
fp->_flags |= __SERR;
return (WEOF);
}
OpenPOWER on IntegriCloud