summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/ungetwc.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-10-16 12:09:43 +0000
committertjr <tjr@FreeBSD.org>2002-10-16 12:09:43 +0000
commit3a88c84c050889dfcdf58a721602c40f9ae03a96 (patch)
tree47fcbdba053baaebb80400ad1d663fa57af766bc /lib/libc/stdio/ungetwc.c
parentccd9275d4ea58567606a870a1c0faabbbabd889b (diff)
downloadFreeBSD-src-3a88c84c050889dfcdf58a721602c40f9ae03a96.zip
FreeBSD-src-3a88c84c050889dfcdf58a721602c40f9ae03a96.tar.gz
Set the error bit on the stream if an encoding error occurs. Improve
handling of multibyte sequences representing null wide characters.
Diffstat (limited to 'lib/libc/stdio/ungetwc.c')
-rw-r--r--lib/libc/stdio/ungetwc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libc/stdio/ungetwc.c b/lib/libc/stdio/ungetwc.c
index 5eeb8b1..e20a763 100644
--- a/lib/libc/stdio/ungetwc.c
+++ b/lib/libc/stdio/ungetwc.c
@@ -49,8 +49,10 @@ __ungetwc(wint_t wc, FILE *fp)
if (wc == WEOF)
return (WEOF);
memset(&mbs, 0, sizeof(mbs));
- if ((len = wcrtomb(buf, wc, &mbs)) == (size_t)-1)
+ if ((len = wcrtomb(buf, wc, &mbs)) == (size_t)-1) {
+ fp->_flags |= __SERR;
return (WEOF);
+ }
while (len-- != 0)
if (__ungetc((unsigned char)buf[len], fp) == EOF)
return (WEOF);
OpenPOWER on IntegriCloud