diff options
author | Denys Vlasenko | 2017-08-23 17:56:03 +0200 |
---|---|---|
committer | Denys Vlasenko | 2017-08-23 17:56:03 +0200 |
commit | 9c47c43e07365abe1eda02d69572b9e579b49cec (patch) | |
tree | 00d5d88812ecf1eddc37f2112e9cf4ae57e2570c /editors | |
parent | 8b77a9ea81a0bd89ee69e7742d9b920dd1562763 (diff) | |
download | busybox-9c47c43e07365abe1eda02d69572b9e579b49cec.zip busybox-9c47c43e07365abe1eda02d69572b9e579b49cec.tar.gz |
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>
Diffstat (limited to 'editors')
-rw-r--r-- | editors/sed.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/editors/sed.c b/editors/sed.c index 3fc40ce..7ed9937 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -350,10 +350,16 @@ static int get_address(const char *my_str, int *linenum, regex_t ** regex) if (*my_str == '\\') delimiter = *++pos; 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); - free(temp); + if (next != 0) { + temp = copy_parsing_escapes(pos, next); + G.previous_regex_ptr = *regex = xzalloc(sizeof(regex_t)); + 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 */ pos += (next+1); } |