sed: in '/regexp/cmd1;//cmd2', cmd2 should use the same regexp as cmd1
function old new delta get_address 165 211 +46 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
8b77a9ea81
commit
9c47c43e07
@ -350,10 +350,16 @@ static int get_address(const char *my_str, int *linenum, regex_t ** regex)
|
|||||||
if (*my_str == '\\')
|
if (*my_str == '\\')
|
||||||
delimiter = *++pos;
|
delimiter = *++pos;
|
||||||
next = index_of_next_unescaped_regexp_delim(delimiter, ++pos);
|
next = index_of_next_unescaped_regexp_delim(delimiter, ++pos);
|
||||||
temp = copy_parsing_escapes(pos, next);
|
if (next != 0) {
|
||||||
*regex = xzalloc(sizeof(regex_t));
|
temp = copy_parsing_escapes(pos, next);
|
||||||
xregcomp(*regex, temp, G.regex_type);
|
G.previous_regex_ptr = *regex = xzalloc(sizeof(regex_t));
|
||||||
free(temp);
|
xregcomp(*regex, temp, G.regex_type);
|
||||||
|
free(temp);
|
||||||
|
} else {
|
||||||
|
*regex = G.previous_regex_ptr;
|
||||||
|
if (!G.previous_regex_ptr)
|
||||||
|
bb_error_msg_and_die("no previous regexp");
|
||||||
|
}
|
||||||
/* Move position to next character after last delimiter */
|
/* Move position to next character after last delimiter */
|
||||||
pos += (next+1);
|
pos += (next+1);
|
||||||
}
|
}
|
||||||
|
@ -387,6 +387,12 @@ testing "sed 's///w FILE'" \
|
|||||||
"" \
|
"" \
|
||||||
"123\nqwe\nasd\n"
|
"123\nqwe\nasd\n"
|
||||||
|
|
||||||
|
testing "sed uses previous regexp" \
|
||||||
|
"sed '/w/p;//q'" \
|
||||||
|
"q\nw\nw\n" \
|
||||||
|
"" \
|
||||||
|
"q\nw\ne\nr\n"
|
||||||
|
|
||||||
# testing "description" "commands" "result" "infile" "stdin"
|
# testing "description" "commands" "result" "infile" "stdin"
|
||||||
|
|
||||||
exit $FAILCOUNT
|
exit $FAILCOUNT
|
||||||
|
Loading…
Reference in New Issue
Block a user