← Commit list

4fe954c14

Dominique Martinet
Dominique Martinet
2021-12-25
SUCCESS Duration: 152s

Subject

sed: do not ignore 'g' modifier when match starts with ^

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 -2
@@ -435,8 +435,7 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, const char *substr)
switch (substr[idx]) {
/* Replace all occurrences */
case 'g':
- if (match[0] != '^')
- sed_cmd->which_match = 0;
+ sed_cmd->which_match = 0;
break;
/* Print pattern space */
case 'p':
testsuite/sed.tests+6 -0
@@ -399,6 +399,12 @@ testing "sed uses previous regexp" \
"" \
"q\nw\ne\nr\n"
+testing "sed ^ OR not^" \
+ "sed -e 's/^a\|b//g'" \
+ "ca\n" \
+ "" \
+ "abca\n"
+
# testing "description" "commands" "result" "infile" "stdin"
exit $FAILCOUNT