diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 2016-08-25 21:14:26 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 2016-08-25 21:14:26 +0000 |
commit | 3e48993c7c3b68102b8b38e267ad1c4ef1d99bf2 (patch) | |
tree | 0538d034f31c6bcc8ceb66d9f3fec99c2778a634 | |
parent | d14b24ef846cb1776a40402096e8030c5b4470e5 (diff) |
Notes
-rw-r--r-- | lib/libc/stdio/fgetln.c | 7 | ||||
-rw-r--r-- | lib/libc/stdio/fgetwln.c | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/libc/stdio/fgetln.c b/lib/libc/stdio/fgetln.c index 1509bc880a4a..c8e30ee2bf65 100644 --- a/lib/libc/stdio/fgetln.c +++ b/lib/libc/stdio/fgetln.c @@ -139,8 +139,11 @@ fgetln(FILE *fp, size_t *lenp) (void)memcpy((void *)(fp->_lb._base + off), (void *)fp->_p, len - off); off = len; - if (__srefill(fp)) - break; /* EOF or error: return partial line */ + if (__srefill(fp)) { + if (__sfeof(fp)) + break; + goto error; + } if ((p = memchr((void *)fp->_p, '\n', (size_t)fp->_r)) == NULL) continue; diff --git a/lib/libc/stdio/fgetwln.c b/lib/libc/stdio/fgetwln.c index 6a92b71ce775..34a80a076b56 100644 --- a/lib/libc/stdio/fgetwln.c +++ b/lib/libc/stdio/fgetwln.c @@ -53,7 +53,6 @@ fgetwln_l(FILE * __restrict fp, size_t *lenp, locale_t locale) ORIENT(fp, 1); len = 0; - /* WEOF or error: return partial line, see fgetln(3). */ while ((wc = __fgetwc(fp, locale)) != WEOF) { #define GROW 512 if (len * sizeof(wchar_t) >= fp->_lb._size && @@ -65,7 +64,7 @@ fgetwln_l(FILE * __restrict fp, size_t *lenp, locale_t locale) if (wc == L'\n') break; } - if (len == 0) + if (len == 0 || (wc == WEOF && !__sfeof(fp))) goto error; FUNLOCKFILE(fp); |