Author: ache Date: Mon Aug 22 15:44:54 2016 New Revision: 304607 URL: https://svnweb.freebsd.org/changeset/base/304607
Log: Fix error processing. 1) Don't forget to set __SERR on __slbexpand() error. 2) Check for __fgetwc() errors using errno. Don't check for __SERR as PR suggested, it user-visible flag which can stick from previous functions and stdio code don't check it for this purpose. PR: 212033 MFC after: 3 days Modified: head/lib/libc/stdio/fgetwln.c Modified: head/lib/libc/stdio/fgetwln.c ============================================================================== --- head/lib/libc/stdio/fgetwln.c Mon Aug 22 15:27:37 2016 (r304606) +++ head/lib/libc/stdio/fgetwln.c Mon Aug 22 15:44:54 2016 (r304607) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" +#include <errno.h> #include <stdio.h> #include <wchar.h> #include "un-namespace.h" @@ -47,12 +48,15 @@ fgetwln_l(FILE * __restrict fp, size_t * { wint_t wc; size_t len; + int saverrno; FIX_LOCALE(locale); FLOCKFILE(fp); ORIENT(fp, 1); len = 0; + saverrno = errno; + errno = 0; while ((wc = __fgetwc(fp, locale)) != WEOF) { #define GROW 512 if (len * sizeof(wchar_t) >= fp->_lb._size && @@ -61,19 +65,27 @@ fgetwln_l(FILE * __restrict fp, size_t * *((wchar_t *)fp->_lb._base + len++) = wc; if (wc == L'\n') break; + errno = 0; } - if (len == 0) + if (wc == WEOF && errno != 0) goto error; + if (errno == 0) + errno = saverrno; + if (len == 0) + goto eof; FUNLOCKFILE(fp); *lenp = len; return ((wchar_t *)fp->_lb._base); error: + fp->_flags |= __SERR; +eof: FUNLOCKFILE(fp); *lenp = 0; return (NULL); } + wchar_t * fgetwln(FILE * __restrict fp, size_t *lenp) { _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"