diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-04-14 11:54:20 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-04-14 11:54:20 +0000 |
commit | 5289be42682b6d80bc54b3667e3e4d8530119f16 (patch) | |
tree | ff4980fee767b713883d9f5c2e7d05e9be590772 /src/modules | |
parent | 35521473bbca1574a81b7d3e9aac3392fbcd2d50 (diff) |
Add move-match-to-head-of-queue stuff to pcre filter
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6793 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/extra/m_filter_pcre.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp index 19ff1b48c..e35094ac0 100644 --- a/src/modules/extra/m_filter_pcre.cpp +++ b/src/modules/extra/m_filter_pcre.cpp @@ -6,7 +6,7 @@ * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see - * the file COPYING for details. + * the file COPYING for details. * * --------------------------------------------------- */ @@ -56,13 +56,18 @@ class ModuleFilterPCRE : public FilterBase virtual FilterResult* FilterMatch(const std::string &text) { - for (unsigned int index = 0; index < filters.size(); index++) + for (std::vector<PCREFilter>::iterator index = filters.begin(); index != filters.end(); index++) { - PCREFilter& filt = filters[index]; - - if (pcre_exec(filt.regexp,NULL,text.c_str(),text.length(),0,0,NULL,0) > -1) + if (pcre_exec(index->regexp, NULL, text.c_str(), text.length(), 0, 0, NULL, 0) > -1) { - return &filt; + PCREFilter* fr = &(*index); + if (index != filters.begin()) + { + filters.erase(index); + filters.insert(filters.begin(), *fr); + index = filters.begin(); + } + return &(*index); } } return NULL; |