diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-05-13 16:29:34 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-05-13 16:30:39 +0200 |
| commit | 0545bfa841540a0d7d7e2953bc205eda64144c2e (patch) | |
| tree | eff3d12359575675aefd94eca2d501fc2ebdcfbc | |
| parent | 15021f393d3d19d689028fceb5c35da930059430 (diff) | |
| download | busybox-w32-0545bfa841540a0d7d7e2953bc205eda64144c2e.tar.gz busybox-w32-0545bfa841540a0d7d7e2953bc205eda64144c2e.tar.bz2 busybox-w32-0545bfa841540a0d7d7e2953bc205eda64144c2e.zip | |
sed: fix /regex/,+N match triggering only once, closes 11871
function old new delta
process_files 2235 2246 +11
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | editors/sed.c | 2 | ||||
| -rwxr-xr-x | testsuite/sed.tests | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/editors/sed.c b/editors/sed.c index bb39de149..57d3dda16 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
| @@ -1097,6 +1097,8 @@ static void process_files(void) | |||
| 1097 | int old_matched, matched; | 1097 | int old_matched, matched; |
| 1098 | 1098 | ||
| 1099 | old_matched = sed_cmd->in_match; | 1099 | old_matched = sed_cmd->in_match; |
| 1100 | if (!old_matched) | ||
| 1101 | sed_cmd->end_line = sed_cmd->end_line_orig; | ||
| 1100 | 1102 | ||
| 1101 | /* Determine if this command matches this line: */ | 1103 | /* Determine if this command matches this line: */ |
| 1102 | 1104 | ||
diff --git a/testsuite/sed.tests b/testsuite/sed.tests index 675cb4f10..67ff87e93 100755 --- a/testsuite/sed.tests +++ b/testsuite/sed.tests | |||
| @@ -361,6 +361,12 @@ testing "sed /regex/,+N{...} addresses work" \ | |||
| 361 | "" \ | 361 | "" \ |
| 362 | "1\n2\n3\n4\n5\n" | 362 | "1\n2\n3\n4\n5\n" |
| 363 | 363 | ||
| 364 | testing "sed /regex/,+N{...} addresses work 2" \ | ||
| 365 | "sed -n '/a/,+1 p'" \ | ||
| 366 | "a\n1\na\n2\na\n3\n" \ | ||
| 367 | "" \ | ||
| 368 | "a\n1\nc\nc\na\n2\na\n3\n" | ||
| 369 | |||
| 364 | testing "sed /regex/,+N{...} -i works" \ | 370 | testing "sed /regex/,+N{...} -i works" \ |
| 365 | "cat - >input2; sed /^4/,+2{d} -i input input2; echo \$?; cat input input2; rm input2" \ | 371 | "cat - >input2; sed /^4/,+2{d} -i input input2; echo \$?; cat input input2; rm input2" \ |
| 366 | "0\n""1\n2\n3\n7\n8\n""1\n2\n7\n8\n" \ | 372 | "0\n""1\n2\n3\n7\n8\n""1\n2\n7\n8\n" \ |
