diff options
Diffstat (limited to 'modules/commands/os_sxline.cpp')
-rw-r--r-- | modules/commands/os_sxline.cpp | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp index 87d8efe5d..20b937bb0 100644 --- a/modules/commands/os_sxline.cpp +++ b/modules/commands/os_sxline.cpp @@ -317,29 +317,20 @@ class CommandOSSNLine : public CommandOSSXLineBase if (mask[0] == '/' && mask[mask.length() - 1] == '/') { - const Anope::string ®exengine = Config->GetBlock("options")->Get<const Anope::string>("regexengine"); - - if (regexengine.empty()) + if (!Config->regex_flags) { source.Reply(_("Regex is disabled.")); return; } - ServiceReference<RegexProvider> provider("Regex", regexengine); - if (!provider) - { - source.Reply(_("Unable to find regex engine %s."), regexengine.c_str()); - return; - } - + Anope::string stripped_mask = mask.substr(1, mask.length() - 2); try { - Anope::string stripped_mask = mask.substr(1, mask.length() - 2); - delete provider->Compile(stripped_mask); + std::regex(stripped_mask.str(), Config->regex_flags); } - catch (const RegexException &ex) + catch (const std::regex_error &ex) { - source.Reply("%s", ex.GetReason().c_str()); + source.Reply("%s", ex.what()); return; } } @@ -446,7 +437,7 @@ class CommandOSSNLine : public CommandOSSXLineBase "\002Note\002: because the realname mask may contain spaces, the\n" "separator between it and the reason is a colon.")); const Anope::string ®exengine = Config->GetBlock("options")->Get<const Anope::string>("regexengine"); - if (!regexengine.empty()) + if (Config->regex_flags && !regexengine.empty()) { source.Reply(" "); source.Reply(_("Regex matches are also supported using the %s engine.\n" @@ -531,29 +522,20 @@ class CommandOSSQLine : public CommandOSSXLineBase if (mask[0] == '/' && mask[mask.length() - 1] == '/') { - const Anope::string ®exengine = Config->GetBlock("options")->Get<const Anope::string>("regexengine"); - - if (regexengine.empty()) + if (!Config->regex_flags) { source.Reply(_("Regex is disabled.")); return; } - ServiceReference<RegexProvider> provider("Regex", regexengine); - if (!provider) - { - source.Reply(_("Unable to find regex engine %s."), regexengine.c_str()); - return; - } - + Anope::string stripped_mask = mask.substr(1, mask.length() - 2); try { - Anope::string stripped_mask = mask.substr(1, mask.length() - 2); - delete provider->Compile(stripped_mask); + std::regex(stripped_mask.str(), Config->regex_flags); } - catch (const RegexException &ex) + catch (const std::regex_error &ex) { - source.Reply("%s", ex.GetReason().c_str()); + source.Reply("%s", ex.what()); return; } } |