diff options
author | yar <yar@FreeBSD.org> | 2007-04-01 13:25:03 +0000 |
---|---|---|
committer | yar <yar@FreeBSD.org> | 2007-04-01 13:25:03 +0000 |
commit | 4a558e4ff58e8ae5339ea8a8fa3faf42078a77c9 (patch) | |
tree | daaa3fe985c3713ef72725927b0a86551826bd77 /usr.bin | |
parent | c5841647962413bcbcae0c48fba8f1429c59c6aa (diff) | |
download | FreeBSD-src-4a558e4ff58e8ae5339ea8a8fa3faf42078a77c9.zip FreeBSD-src-4a558e4ff58e8ae5339ea8a8fa3faf42078a77c9.tar.gz |
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
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/sed/process.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index 83fe325b..ee9334c 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -128,7 +128,7 @@ redirect: case 'c': pd = 1; psl = 0; - if (cp->a2 == NULL || lastaddr) + if (cp->a2 == NULL || lastaddr || lastline()) (void)fprintf(outfile, "%s", cp->t); break; case 'd': |