sed: fix matching of newlines by $
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 21 Jul 2013 20:09:44 +0000 (22:09 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 21 Jul 2013 20:09:44 +0000 (22:09 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
editors/sed.c
testsuite/sed.tests

index e625a09656b69d1b85d4a0ff09ba681e144bdbca..3a0d917aa1b39c5b4ea078578f322ba1bd12c051 100644 (file)
@@ -330,7 +330,7 @@ static int get_address(const char *my_str, int *linenum, regex_t ** regex)
                next = index_of_next_unescaped_regexp_delim(delimiter, ++pos);
                temp = copy_parsing_escapes(pos, next);
                *regex = xzalloc(sizeof(regex_t));
-               xregcomp(*regex, temp, G.regex_type|REG_NEWLINE);
+               xregcomp(*regex, temp, G.regex_type);
                free(temp);
                /* Move position to next character after last delimiter */
                pos += (next+1);
index 468565f47081280e9007d6ee80cc5687547900d1..2af1e4c979fc841c3205f933a6a054b4a38764a9 100755 (executable)
@@ -310,6 +310,27 @@ testing "sed zero chars match/replace logic must not falsely trigger here 2" \
        "sed 's/ *$/_/g'" \
        "qwerty_\n" "" "qwerty\n"
 
+testing "sed /\$_in_regex/ should not match newlines, only end-of-line" \
+       "sed ': testcont; /\\\\$/{ =; N; b testcont }'" \
+       "\
+this is a regular line
+2
+line with \\
+continuation
+more regular lines
+5
+line with \\
+continuation
+" \
+       "" "\
+this is a regular line
+line with \\
+continuation
+more regular lines
+line with \\
+continuation
+"
+
 # testing "description" "commands" "result" "infile" "stdin"
 
 exit $FAILCOUNT