From aebf9460d9960ab10ae239faccfe00a0cebaec0f Mon Sep 17 00:00:00 2001 From: Naine Date: Wed, 17 Feb 2016 13:01:01 +1100 Subject: [PATCH 1/2] Fix negative matching/filtering Previously, the highlight function returned true immediately upon finding any match, without checking whether any negative matches should be preventing the match. --- push.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/push.cpp b/push.cpp index f2697bd..0cf9b51 100755 --- a/push.cpp +++ b/push.cpp @@ -880,6 +880,9 @@ class CPushMod : public CModule char prefix = value[0]; bool push = true; + bool matched = false; + bool negated = false; + if (prefix == '-') { push = false; @@ -904,11 +907,18 @@ class CPushMod : public CModule if (msg.WildCmp(value)) { - return push; + if (push) + { + matched = true; + } + else + { + negated = true; + } } } - return false; + return (matched && !negated); } /** From 9361dd7a234b8eb2cb17aa63f12746ebf4e8b777 Mon Sep 17 00:00:00 2001 From: Naine Date: Thu, 18 Feb 2016 15:36:40 +1100 Subject: [PATCH 2/2] Rename variable in highlight() Rename "push" to "negate_match" and reverse its values to better reflect its new purpose. --- push.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/push.cpp b/push.cpp index 0cf9b51..61b8328 100755 --- a/push.cpp +++ b/push.cpp @@ -878,14 +878,14 @@ class CPushMod : public CModule { CString value = i->AsLower(); char prefix = value[0]; - bool push = true; + bool negate_match = false; bool matched = false; bool negated = false; if (prefix == '-') { - push = false; + negate_match = true; value.LeftChomp(1); } else if (prefix == '_') @@ -907,13 +907,13 @@ class CPushMod : public CModule if (msg.WildCmp(value)) { - if (push) + if (negate_match) { - matched = true; + negated = true; } else { - negated = true; + matched = true; } } }