From a9964cd6d046c8562ccf55586fb6087812b2b573 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 10 Jul 2022 11:17:05 -0700 Subject: [PATCH] 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. --- src/fish_tests.cpp | 6 ------ src/re.cpp | 1 - src/re.h | 1 - 3 files changed, 8 deletions(-) diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 8cd0c69b4..5266ee881 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -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"); diff --git a/src/re.cpp b/src/re.cpp index 1064fb70f..03079bd6d 100644 --- a/src/re.cpp +++ b/src/re.cpp @@ -237,7 +237,6 @@ maybe_t 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; diff --git a/src/re.h b/src/re.h index 02848bcb6..5a503099b 100644 --- a/src/re.h +++ b/src/re.h @@ -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? };