From 1c584f59a55cb440f0487854db33b28a08898f82 Mon Sep 17 00:00:00 2001 From: tjr Date: Wed, 7 Apr 2004 09:55:05 +0000 Subject: 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. --- lib/libc/stdio/fputwc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/libc/stdio/fputwc.c') diff --git a/lib/libc/stdio/fputwc.c b/lib/libc/stdio/fputwc.c index ba3c5bb..f1e6bf1 100644 --- a/lib/libc/stdio/fputwc.c +++ b/lib/libc/stdio/fputwc.c @@ -43,6 +43,8 @@ __FBSDID("$FreeBSD$"); wint_t __fputwc(wchar_t wc, FILE *fp) { + static const mbstate_t initial; + mbstate_t mbs; char buf[MB_LEN_MAX]; size_t i, len; @@ -55,7 +57,8 @@ __fputwc(wchar_t wc, FILE *fp) *buf = (unsigned char)wc; len = 1; } else { - 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); } -- cgit v1.1