From owner-cvs-all@FreeBSD.ORG Sun Apr 1 13:25:04 2007 Return-Path: X-Original-To: cvs-all@FreeBSD.org Delivered-To: cvs-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0560816A403; Sun, 1 Apr 2007 13:25:03 +0000 (UTC) (envelope-from yar@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id E47F513C4F6; Sun, 1 Apr 2007 13:25:03 +0000 (UTC) (envelope-from yar@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l31DP3Zl008332; Sun, 1 Apr 2007 13:25:03 GMT (envelope-from yar@repoman.freebsd.org) Received: (from yar@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l31DP3r0008328; Sun, 1 Apr 2007 13:25:03 GMT (envelope-from yar) Message-Id: <200704011325.l31DP3r0008328@repoman.freebsd.org> From: Yar Tikhiy Date: Sun, 1 Apr 2007 13:25:03 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: Subject: cvs commit: src/usr.bin/sed process.c src/tools/regression/usr.bin/sed regress.c0.out regress.c1.out regress.c2.out regress.c3.out regress.sh X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2007 13:25:04 -0000 yar 2007-04-01 13:25:03 UTC FreeBSD src repository Modified files: usr.bin/sed process.c tools/regression/usr.bin/sed regress.sh Added files: tools/regression/usr.bin/sed regress.c0.out regress.c1.out regress.c2.out regress.c3.out Log: This trivial change should fix at least 3 similar bugs. All of them are related to the `c' function's need to know if we are at the actual end of the address range. (It must print the text not earlier than the whole pattern space was deleted.) It appears the only sed function with this requirement. There is `lastaddr' set by applies(), which is to notify the `c' function, but it can't always help because it's false when we are hitting the end of file early. There is also a bug in applies() due to which `lastaddr' isn't set to true on degenerate ranges such as `$,$' or `N,$' if N appears the last line number. Handling early EOF condition in applies() could look more logical, but it would effectively revert sed to the unreasonable behaviour rev. 1.26 of main.c fought against, as it would require lastline() be called for each line within each address range. So it's better to call lastline() only if needed by the `c' function. Together with this change to sed go regression tests for the bugs fixed (c1-c3). A basic test of `c' (c0) is also added as it helped me to spot my own error. Discussed with: dds Tested by: the regression tests MFC after: 1 week Revision Changes Path 1.1 +4 -0 src/tools/regression/usr.bin/sed/regress.c0.out (new) 1.1 +4 -0 src/tools/regression/usr.bin/sed/regress.c1.out (new) 1.1 +3 -0 src/tools/regression/usr.bin/sed/regress.c2.out (new) 1.1 +3 -0 src/tools/regression/usr.bin/sed/regress.c3.out (new) 1.12 +13 -1 src/tools/regression/usr.bin/sed/regress.sh 1.42 +1 -1 src/usr.bin/sed/process.c