aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/sed.c2
-rwxr-xr-xtestsuite/sed.tests4
2 files changed, 5 insertions, 1 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 85c84665b..0fe82f337 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -767,7 +767,7 @@ static int do_subst_command(sed_cmd_t *sed_cmd, char **line_p)
767 * second is "" before "d", third is "" after "d". 767 * second is "" before "d", third is "" after "d".
768 * Second match is NOT replaced! 768 * Second match is NOT replaced!
769 */ 769 */
770 if (prev_match_empty || start != 0) { 770 if (prev_match_empty || start != 0 || start != end) {
771 dbg("inserting replacement at %d in '%s'", start, line); 771 dbg("inserting replacement at %d in '%s'", start, line);
772 do_subst_w_backrefs(line, sed_cmd->string); 772 do_subst_w_backrefs(line, sed_cmd->string);
773 } else { 773 } else {
diff --git a/testsuite/sed.tests b/testsuite/sed.tests
index 375beb518..12b36ae18 100755
--- a/testsuite/sed.tests
+++ b/testsuite/sed.tests
@@ -302,6 +302,10 @@ testing "sed zero chars match/replace advances correctly 2" \
302 "sed 's [^ .]* x g'" \ 302 "sed 's [^ .]* x g'" \
303 "x x.x\n" "" " a.b\n" 303 "x x.x\n" "" " a.b\n"
304 304
305testing "sed zero chars match/replace logic must not falsely trigger here" \
306 "sed 's/a/A/g'" \
307 "_AAA1AA\n" "" "_aaa1aa\n"
308
305# testing "description" "commands" "result" "infile" "stdin" 309# testing "description" "commands" "result" "infile" "stdin"
306 310
307exit $FAILCOUNT 311exit $FAILCOUNT