diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-23 19:04:27 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-23 19:04:27 +0100 |
commit | f12fb1e4092900f26f7f8c71cde44b1cd7d26439 (patch) | |
tree | b5dec7c96074267b6d299928481e649e75c00885 /editors/sed.c | |
parent | e998c7c032458a05a7afcc13ce0dc980b99ecc6c (diff) | |
download | busybox-w32-f12fb1e4092900f26f7f8c71cde44b1cd7d26439.tar.gz busybox-w32-f12fb1e4092900f26f7f8c71cde44b1cd7d26439.tar.bz2 busybox-w32-f12fb1e4092900f26f7f8c71cde44b1cd7d26439.zip |
sed: fix handling of escaped delimiters in s/// replacement
function old new delta
parse_regex_delim 111 140 +29
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors/sed.c')
-rw-r--r-- | editors/sed.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/editors/sed.c b/editors/sed.c index 02a527b4a..32a4b61f6 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -355,7 +355,10 @@ static int parse_regex_delim(const char *cmdstr, char **match, char **replace) | |||
355 | /* save the replacement string */ | 355 | /* save the replacement string */ |
356 | cmdstr_ptr += idx + 1; | 356 | cmdstr_ptr += idx + 1; |
357 | idx = index_of_next_unescaped_regexp_delim(- (int)delimiter, cmdstr_ptr); | 357 | idx = index_of_next_unescaped_regexp_delim(- (int)delimiter, cmdstr_ptr); |
358 | *replace = copy_parsing_escapes(cmdstr_ptr, idx, 0); | 358 | //GNU sed 4.8: |
359 | // echo 789 | sed 's&8&\&&' - 7&9 ("\&" remained "\&") | ||
360 | // echo 789 | sed 's1\(8\)1\1\11' - 7119 ("\1\1" become "11") | ||
361 | *replace = copy_parsing_escapes(cmdstr_ptr, idx, delimiter != '&' ? delimiter : 0); | ||
359 | 362 | ||
360 | return ((cmdstr_ptr - cmdstr) + idx); | 363 | return ((cmdstr_ptr - cmdstr) + idx); |
361 | } | 364 | } |