From 151bfb59482950c55b935a404df11b9d3961fb6c Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 27 Aug 2016 11:07:57 +0000 Subject: MFC r304607,r304641,r304819,r304811 1) Don't forget to set __SERR on __slbexpand() error. 2) Remove "Fast path" from fgetwc()/fputwc() since it can't detect encoding errors and ignores them all. One of affected encoding example: US-ASCII 3) Original fgetln() from 44lite return success for line tail errors, i.e. partial line, but set __SERR and errno in the same time, which is inconsistent. Now both OpenBSD and NetBSD return failure, i.e. no line and set error indicators for such case, so make our fgetln() and fgetwln() (as its wide version) compatible with the rest of *BSD. PR: 212033 --- lib/libc/stdio/fgetwc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'lib/libc/stdio/fgetwc.c') diff --git a/lib/libc/stdio/fgetwc.c b/lib/libc/stdio/fgetwc.c index 52bc988..cf649fd 100644 --- a/lib/libc/stdio/fgetwc.c +++ b/lib/libc/stdio/fgetwc.c @@ -79,18 +79,9 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, int *nread, locale_t locale) size_t nconv; struct xlocale_ctype *l = XLOCALE_CTYPE(locale); - if (fp->_r <= 0 && __srefill(fp)) { - *nread = 0; - return (WEOF); - } - if (MB_CUR_MAX == 1) { - /* Fast path for single-byte encodings. */ - wc = *fp->_p++; - fp->_r--; - *nread = 1; - return (wc); - } *nread = 0; + if (fp->_r <= 0 && __srefill(fp)) + return (WEOF); do { nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs); if (nconv == (size_t)-1) -- cgit v1.1