mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Add regex_pcre compatibility to regex_pcre2.
This commit is contained in:
parent
34a7471d0e
commit
3fa012b75b
@ -1765,6 +1765,10 @@
|
||||
# module. You must have at least 1 provider loaded to use the filter or
|
||||
# R-line modules.
|
||||
#<module name="regex_pcre2">
|
||||
#
|
||||
# If you were using PCRE in v3 or earlier you can enable this to try to
|
||||
# keep compatibility with your regular expressions from older versions.
|
||||
#<pcre2 compat="yes">
|
||||
|
||||
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||
# Regular Expression Provider for RE2 Regular Expressions.
|
||||
|
@ -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")
|
||||
{
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user