Remove usage of PCRE2_SUBSTITUTE_LITERAL

We don't need this flag and this ties us to a newer version of PCRE2
than we would like. Fixes #9061.
This commit is contained in:
ridiculousfish 2022-07-10 11:17:05 -07:00
parent cbd0ec568c
commit a9964cd6d0
3 changed files with 0 additions and 8 deletions

View File

@ -6817,12 +6817,6 @@ static void test_re_substitute() {
do_test(res && *res == L"AA123qqqZZ AA123qqqZZ");
do_test(repl_count == 2);
sflags.literal = true;
res = re->substitute(subj, repl, sflags, 0, nullptr, &repl_count);
do_test(res && *res == L"AA$1qqqZZ AA$1qqqZZ");
do_test(repl_count == 2);
sflags.literal = false;
sflags.extended = true;
res = re->substitute(subj, L"\\x21", sflags, 0, nullptr, &repl_count); // \x21 = !
do_test(res && *res == L"AA!ZZ AA!ZZ");

View File

@ -237,7 +237,6 @@ maybe_t<wcstring> regex_t::substitute(const wcstring &subject, const wcstring &r
uint32_t options = PCRE2_SUBSTITUTE_UNSET_EMPTY // don't error on unmatched
| PCRE2_SUBSTITUTE_OVERFLOW_LENGTH // return required length on overflow
| (flags.global ? PCRE2_SUBSTITUTE_GLOBAL : 0) // replace multiple
| (flags.literal ? PCRE2_SUBSTITUTE_LITERAL : 0) // respect $1, etc.
| (flags.extended ? PCRE2_SUBSTITUTE_EXTENDED : 0) // backslash escapes
;
size_t bufflen = stack_bufflen;

View File

@ -32,7 +32,6 @@ struct flags_t {
/// Flags for substituting a regex.
struct sub_flags_t {
bool global{}; // perform multiple substitutions?
bool literal{}; // $1 is literal, not a capture reference
bool extended{}; // apply PCRE2 extended backslash escapes?
};