← Commit list

84406e459

Denys Vlasenko
Denys Vlasenko
2012-06-07
FAILED Duration: 187s

Subject

sed: fix breakage added by zero length match code

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

editors/sed.c+1 -1
@@ -767,7 +767,7 @@ static int do_subst_command(sed_cmd_t *sed_cmd, char **line_p)
* second is "" before "d", third is "" after "d".
* Second match is NOT replaced!
*/
- if (prev_match_empty || start != 0) {
+ if (prev_match_empty || start != 0 || start != end) {
dbg("inserting replacement at %d in '%s'", start, line);
do_subst_w_backrefs(line, sed_cmd->string);
} else {
testsuite/sed.tests+4 -0
@@ -302,6 +302,10 @@ testing "sed zero chars match/replace advances correctly 2" \
"sed 's [^ .]* x g'" \
"x x.x\n" "" " a.b\n"
+testing "sed zero chars match/replace logic must not falsely trigger here" \
+ "sed 's/a/A/g'" \
+ "_AAA1AA\n" "" "_aaa1aa\n"
+
# testing "description" "commands" "result" "infile" "stdin"
exit $FAILCOUNT