summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/fputwc.c
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2004-04-07 09:55:05 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2004-04-07 09:55:05 +0000
commit93996f6d58e252f9f975d3bc8522df8fe227f002 (patch)
tree12c84b3433d9dfe7221d8772b9282c58a3f99811 /lib/libc/stdio/fputwc.c
parente97e8562744f5b6a68d5ee5da07c791c42785e80 (diff)
Notes
Diffstat (limited to 'lib/libc/stdio/fputwc.c')
-rw-r--r--lib/libc/stdio/fputwc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/stdio/fputwc.c b/lib/libc/stdio/fputwc.c
index ba3c5bbfdf82..f1e6bf10cb46 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);
}