| 1 |
<!DOCTYPE html> |
| 2 |
<html><head> |
| 3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
| 4 |
<title>test.diff</title> |
| 5 |
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (Diff) - Theme (Breeze Dark)"/> |
| 6 |
</head><body style="background-color:#232629;color:#cfcfc2"><pre> |
| 7 |
commit 2b16665838c8afeaa0f065cafc747438de35876b |
| 8 |
Author: Volker Krause <[email protected]> |
| 9 |
Date: Sat Oct 8 13:31:51 2016 +0200 |
| 10 |
|
| 11 |
Implement dynamic DetectChar rules |
| 12 |
|
| 13 |
Needed for Perl highlighting. |
| 14 |
|
| 15 |
<span style="font-weight:bold;">diff --git a/src/lib/rule.cpp b/src/lib/rule.cpp</span> |
| 16 |
index f588985..c4c3b92 100644 |
| 17 |
<span style="color:#2980b9;">--- a/src/lib/rule.cpp</span> |
| 18 |
<span style="color:#2980b9;">+++ b/src/lib/rule.cpp</span> |
| 19 |
<span style="color:#2980b9;">@@ -308,12 +308,22 @@ bool DetectChar::doLoad(QXmlStreamReader& reader)</span> |
| 20 |
if (s.isEmpty()) |
| 21 |
return false; |
| 22 |
m_char = s.at(0); |
| 23 |
<span style="color:#27aeae;">+ if (isDynamic()) {</span> |
| 24 |
<span style="color:#27aeae;">+ m_captureIndex = m_char.digitValue();</span> |
| 25 |
<span style="color:#27aeae;">+ }</span> |
| 26 |
return true; |
| 27 |
} |
| 28 |
|
| 29 |
MatchResult DetectChar::doMatch(const QString& text, int offset, const QStringList &captures) |
| 30 |
{ |
| 31 |
<span style="color:#f44f4f;">- Q_UNUSED(captures); // TODO</span> |
| 32 |
<span style="color:#27aeae;">+ if (isDynamic()) {</span> |
| 33 |
<span style="color:#27aeae;">+ if (captures.size() <= m_captureIndex || captures.at(m_captureIndex).isEmpty())</span> |
| 34 |
<span style="color:#27aeae;">+ return offset;</span> |
| 35 |
<span style="color:#27aeae;">+ if (text.at(offset) == captures.at(m_captureIndex).at(0))</span> |
| 36 |
<span style="color:#27aeae;">+ return offset + 1;</span> |
| 37 |
<span style="color:#27aeae;">+ return offset;</span> |
| 38 |
<span style="color:#27aeae;">+ }</span> |
| 39 |
<span style="color:#27aeae;">+</span> |
| 40 |
if (text.at(offset) == m_char) |
| 41 |
return offset + 1; |
| 42 |
return offset; |
| 43 |
<span style="font-weight:bold;">diff --git a/src/lib/rule_p.h b/src/lib/rule_p.h</span> |
| 44 |
index d8862ae..d9cedbf 100644 |
| 45 |
<span style="color:#2980b9;">--- a/src/lib/rule_p.h</span> |
| 46 |
<span style="color:#2980b9;">+++ b/src/lib/rule_p.h</span> |
| 47 |
<span style="color:#2980b9;">@@ -103,6 +103,7 @@ protected:</span> |
| 48 |
|
| 49 |
private: |
| 50 |
QChar m_char; |
| 51 |
<span style="color:#27aeae;">+ int m_captureIndex;</span> |
| 52 |
}; |
| 53 |
|
| 54 |
class Detect2Char : public Rule |
| 55 |
</pre></body></html> |