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
This commit is contained in:
parent
d7cfea0e1a
commit
e9a0eed451
3
tools/regression/usr.bin/sed/regress.b2a.out
Normal file
3
tools/regression/usr.bin/sed/regress.b2a.out
Normal file
@ -0,0 +1,3 @@
|
||||
data
|
||||
for validation
|
||||
of sed(1)
|
@ -2,7 +2,7 @@
|
||||
|
||||
REGRESSION_START($1)
|
||||
|
||||
echo '1..15'
|
||||
echo '1..16'
|
||||
|
||||
REGRESSION_TEST(`G', `sed G < regress.in')
|
||||
REGRESSION_TEST(`P', `sed P < regress.in')
|
||||
@ -27,5 +27,7 @@ foo
|
||||
REGRESSION_TEST(`c3', `sed ''`3,/no such string/c\
|
||||
foo
|
||||
''`< regress.in')
|
||||
REGRESSION_TEST(`b2a', `sed ''`2,3b
|
||||
1,2d''` < regress.in')
|
||||
|
||||
REGRESSION_END()
|
||||
|
@ -285,7 +285,16 @@ applies(struct s_command *cp)
|
||||
if (MATCH(cp->a2)) {
|
||||
cp->inrange = 0;
|
||||
lastaddr = 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)) {
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user