sed: fix handling of escaped delimiters in s/// search pattern, closes 14541

function                                             old     new   delta
copy_parsing_escapes                                  67      96     +29
parse_regex_delim                                    109     111      +2
get_address                                          213     215      +2
add_cmd                                             1176    1178      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 35/0)               Total: 35 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2022-01-23 18:48:49 +01:00
parent 33a9f34df5
commit e998c7c032
2 changed files with 21 additions and 8 deletions

View File

@ -324,6 +324,16 @@ testing "sed zero chars match/replace logic must not falsely trigger here 2" \
"sed 's/ *$/_/g'" \
"qwerty_\n" "" "qwerty\n"
# the pattern here is interpreted as "9+", not as "9\+"
testing "sed special char as s/// delimiter, in pattern" \
"sed 's+9\++X+'" \
"X8=17\n" "" "9+8=17\n"
# but in replacement string, "\&" remains "\&", not interpreted as "&"
testing "sed special char as s/// delimiter, in replacement" \
"sed 's&9&X\&&'" \
"X&+8=17\n" "" "9+8=17\n"
testing "sed /\$_in_regex/ should not match newlines, only end-of-line" \
"sed ': testcont; /\\\\$/{ =; N; b testcont }'" \
"\