diff options
author | yar <yar@FreeBSD.org> | 2007-04-02 08:14:46 +0000 |
---|---|---|
committer | yar <yar@FreeBSD.org> | 2007-04-02 08:14:46 +0000 |
commit | d1f2d71a20a71a7677a23d9186db3bcf9732ae91 (patch) | |
tree | 4d4c93e2f77d47665b55333133bf5aa5c3b8f7ab /usr.bin/sed | |
parent | 03cf2678d28b868b3e66659a634c7932527eef53 (diff) | |
download | FreeBSD-src-d1f2d71a20a71a7677a23d9186db3bcf9732ae91.zip FreeBSD-src-d1f2d71a20a71a7677a23d9186db3bcf9732ae91.tar.gz |
Don't forget to close the range if we branched over its end
and had no chance to match it by the 2nd address precisely.
Otherwise the unclosed range would bogusly extend to the end
of stream.
Add a basic regression test for the bug fixed. (This change
also fixes the more complex case 5.3 from `multitest.t'.)
Compared with: SUN and GNU seds
Tested by: regression tests
MFC after: 1 week
Diffstat (limited to 'usr.bin/sed')
-rw-r--r-- | usr.bin/sed/process.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index c609908..44c75f6 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -285,8 +285,17 @@ applies(struct s_command *cp) if (MATCH(cp->a2)) { cp->inrange = 0; lastaddr = 1; - } - r = 1; + r = 1; + } else if (cp->a2->type == AT_LINE && + linenum > cp->a2->u.l) { + /* + * We missed the 2nd address due to a branch, + * so just close the range and return false. + */ + cp->inrange = 0; + r = 0; + } else + r = 1; } else if (MATCH(cp->a1)) { /* * If the second address is a number less than or |