freebsd-dev/usr.bin/sed
Yaroslav Tykhiy 6b8ef68111 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
2007-04-01 13:25:03 +00:00
..
compile.c Bug fix: a numeric flag specification in the substitute command would 2005-08-04 10:05:12 +00:00
defs.h Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived 2004-08-09 15:29:41 +00:00
extern.h Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived 2004-08-09 15:29:41 +00:00
main.c The function inplace_edit() doesn't exist anymore, remove the prototype. 2005-09-24 13:18:30 +00:00
Makefile
misc.c Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived 2004-08-09 15:29:41 +00:00
POSIX BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00
process.c This trivial change should fix at least 3 similar bugs. All of 2007-04-01 13:25:03 +00:00
sed.1 Markup and wording fixes. 2005-06-14 11:50:53 +00:00