From 5289be42682b6d80bc54b3667e3e4d8530119f16 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 14 Apr 2007 11:54:20 +0000 Subject: 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 --- src/modules/extra/m_filter_pcre.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/modules/extra') 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::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; -- cgit v1.2.3