]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_regex_posix.cpp
Fix various small issues.
[user/henk/code/inspircd.git] / src / modules / extra / m_regex_posix.cpp
index 064edb5f639b7a46d84c86b684611fa73a0f2a43..935cdbf92907edf2c6ac2d8017e9d6317df47454 100644 (file)
 #include <sys/types.h>
 #include <regex.h>
 
-/* $ModDep: modules/regex.h */
-
-class POSIXRegexException : public ModuleException
-{
- public:
-       POSIXRegexException(const std::string& rx, const std::string& error)
-               : ModuleException("Error in regex " + rx + ": " + error)
-       {
-       }
-};
-
 class POSIXRegex : public Regex
 {
        regex_t regbuf;
@@ -56,7 +45,7 @@ class POSIXRegex : public Regex
                        error = errbuf;
                        delete[] errbuf;
                        regfree(&regbuf);
-                       throw POSIXRegexException(rx, error);
+                       throw RegexException(rx, error);
                }
        }
 
@@ -65,14 +54,9 @@ class POSIXRegex : public Regex
                regfree(&regbuf);
        }
 
-       bool Matches(const std::string& text)
+       bool Matches(const std::string& text) CXX11_OVERRIDE
        {
-               if (regexec(&regbuf, text.c_str(), 0, NULL, 0) == 0)
-               {
-                       // Bang. :D
-                       return true;
-               }
-               return false;
+               return (regexec(&regbuf, text.c_str(), 0, NULL, 0) == 0);
        }
 };
 
@@ -81,7 +65,7 @@ class PosixFactory : public RegexFactory
  public:
        bool extended;
        PosixFactory(Module* m) : RegexFactory(m, "regex/posix") {}
-       Regex* Create(const std::string& expr)
+       Regex* Create(const std::string& expr) CXX11_OVERRIDE
        {
                return new POSIXRegex(expr, extended);
        }
@@ -95,8 +79,6 @@ class ModuleRegexPOSIX : public Module
        ModuleRegexPOSIX() : ref(this)
        {
                ServerInstance->Modules->AddService(ref);
-               Implementation eventlist[] = { I_OnRehash };
-               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
                OnRehash(NULL);
        }