sed: fix matching of newlines by $
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
@@ -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);
|
next = index_of_next_unescaped_regexp_delim(delimiter, ++pos);
|
||||||
temp = copy_parsing_escapes(pos, next);
|
temp = copy_parsing_escapes(pos, next);
|
||||||
*regex = xzalloc(sizeof(regex_t));
|
*regex = xzalloc(sizeof(regex_t));
|
||||||
xregcomp(*regex, temp, G.regex_type|REG_NEWLINE);
|
xregcomp(*regex, temp, G.regex_type);
|
||||||
free(temp);
|
free(temp);
|
||||||
/* Move position to next character after last delimiter */
|
/* Move position to next character after last delimiter */
|
||||||
pos += (next+1);
|
pos += (next+1);
|
||||||
|
@@ -310,6 +310,27 @@ testing "sed zero chars match/replace logic must not falsely trigger here 2" \
|
|||||||
"sed 's/ *$/_/g'" \
|
"sed 's/ *$/_/g'" \
|
||||||
"qwerty_\n" "" "qwerty\n"
|
"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"
|
# testing "description" "commands" "result" "infile" "stdin"
|
||||||
|
|
||||||
exit $FAILCOUNT
|
exit $FAILCOUNT
|
||||||
|
Reference in New Issue
Block a user