summaryrefslogtreecommitdiff
path: root/modules/commands
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-04-02 13:06:48 -0400
committerAdam <Adam@anope.org>2014-04-02 13:08:14 -0400
commit52bc8e4bc799d38e92d38d497a2bd055950841bb (patch)
treeb80ea985f1adffa43ca046c014e3b81f9404db8d /modules/commands
parentee133c03f206a7fab78a700b183fbc8684b9d6bf (diff)
Remove regex mods, use std::regex instead
Diffstat (limited to 'modules/commands')
-rw-r--r--modules/commands/os_akill.cpp19
-rw-r--r--modules/commands/os_sxline.cpp40
2 files changed, 16 insertions, 43 deletions
diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp
index 44c8fb23d..81dd69ed2 100644
--- a/modules/commands/os_akill.cpp
+++ b/modules/commands/os_akill.cpp
@@ -122,29 +122,20 @@ class CommandOSAKill : public Command
if (mask[0] == '/' && mask[mask.length() - 1] == '/')
{
- const Anope::string &regexengine = 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;
}
}
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 &regexengine = 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 &regexengine = 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 &regexengine = 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;
}
}