diff options
-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" \ |