From owner-svn-src-head@freebsd.org Thu Aug 25 21:14:27 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 988F9BC6523; Thu, 25 Aug 2016 21:14:27 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4C42513E6; Thu, 25 Aug 2016 21:14:27 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7PLEQ1g060481; Thu, 25 Aug 2016 21:14:26 GMT (envelope-from ache@FreeBSD.org) Received: (from ache@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7PLEQSH060479; Thu, 25 Aug 2016 21:14:26 GMT (envelope-from ache@FreeBSD.org) Message-Id: <201608252114.u7PLEQSH060479@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ache set sender to ache@FreeBSD.org using -f From: "Andrey A. Chernov" Date: Thu, 25 Aug 2016 21:14:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r304819 - head/lib/libc/stdio X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Aug 2016 21:14:27 -0000 Author: ache Date: Thu Aug 25 21:14:26 2016 New Revision: 304819 URL: https://svnweb.freebsd.org/changeset/base/304819 Log: Original fgetln() from 44lite return sucess 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 MFC after: 7 days Modified: head/lib/libc/stdio/fgetln.c head/lib/libc/stdio/fgetwln.c Modified: head/lib/libc/stdio/fgetln.c ============================================================================== --- head/lib/libc/stdio/fgetln.c Thu Aug 25 21:13:16 2016 (r304818) +++ head/lib/libc/stdio/fgetln.c Thu Aug 25 21:14:26 2016 (r304819) @@ -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; Modified: head/lib/libc/stdio/fgetwln.c ============================================================================== --- head/lib/libc/stdio/fgetwln.c Thu Aug 25 21:13:16 2016 (r304818) +++ head/lib/libc/stdio/fgetwln.c Thu Aug 25 21:14:26 2016 (r304819) @@ -53,7 +53,6 @@ fgetwln_l(FILE * __restrict fp, size_t * 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 * if (wc == L'\n') break; } - if (len == 0) + if (len == 0 || (wc == WEOF && !__sfeof(fp))) goto error; FUNLOCKFILE(fp);