diff options
| author | 2021-09-26 20:41:19 +0100 | |
|---|---|---|
| committer | 2021-10-01 04:09:22 +0100 | |
| commit | 3fa012b75b14abd69c7bc67c27ae50cb9ba4c343 (patch) | |
| tree | fd985449387893d804489be821c4bb1e2e3b98c1 /src/modules | |
| parent | Release v4.0.0a5. (diff) | |
Add regex_pcre compatibility to regex_pcre2.
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/extra/m_regex_pcre2.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/modules/extra/m_regex_pcre2.cpp b/src/modules/extra/m_regex_pcre2.cpp index a8e9c535a..c0acd627d 100644 --- a/src/modules/extra/m_regex_pcre2.cpp +++ b/src/modules/extra/m_regex_pcre2.cpp @@ -75,15 +75,34 @@ class PCRE2Pattern final } }; +class PCRECompatEngine final + : public Regex::Engine +{ +public: + PCRECompatEngine(Module* Creator, const std::string& Name) + : Regex::Engine(Creator, Name) + { + if (!ServerInstance->Config->ConfValue("pcre2")->getBool("compat")) + DisableAutoRegister(); + } + + Regex::PatternPtr Create(const std::string& pattern, uint8_t options) override + { + return std::make_shared<PCRE2Pattern>(pattern, options); + } +}; + class ModuleRegexPCRE2 final : public Module { private: + PCRECompatEngine compatregex; Regex::SimpleEngine<PCRE2Pattern> regex; public: ModuleRegexPCRE2() : Module(VF_VENDOR, "Provides the pcre2 regular expression engine which uses the PCRE2 library.") + , compatregex(this, "pcre") , regex(this, "pcre2") { } |
