File indexing completed on 2025-02-02 03:54:47
0001 <!DOCTYPE html> 0002 <html><head> 0003 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 0004 <title>test.diff</title> 0005 <meta name="generator" content="KF5::SyntaxHighlighting - Definition (Diff) - Theme (Breeze Light)"/> 0006 </head><body style="background-color:#ffffff;color:#1f1c1b"><pre> 0007 commit 2b16665838c8afeaa0f065cafc747438de35876b 0008 Author: Volker Krause <vkrause@kde.org> 0009 Date: Sat Oct 8 13:31:51 2016 +0200 0010 0011 Implement dynamic DetectChar rules 0012 0013 Needed for Perl highlighting. 0014 0015 <span style="font-weight:bold">diff --git a/src/lib/rule.cpp b/src/lib/rule.cpp</span> 0016 index f588985..c4c3b92 100644 0017 <span style="color:#0057ae">--- a/src/lib/rule.cpp</span> 0018 <span style="color:#0057ae">+++ b/src/lib/rule.cpp</span> 0019 <span style="color:#0057ae">@@ -308,12 +308,22 @@ bool DetectChar::doLoad(QXmlStreamReader& reader)</span> 0020 if (s.isEmpty()) 0021 return false; 0022 m_char = s.at(0); 0023 <span style="color:#0057ae">+ if (isDynamic()) {</span> 0024 <span style="color:#0057ae">+ m_captureIndex = m_char.digitValue();</span> 0025 <span style="color:#0057ae">+ }</span> 0026 return true; 0027 } 0028 0029 MatchResult DetectChar::doMatch(const QString& text, int offset, const QStringList &captures) 0030 { 0031 <span style="color:#bf0303">- Q_UNUSED(captures); // TODO</span> 0032 <span style="color:#0057ae">+ if (isDynamic()) {</span> 0033 <span style="color:#0057ae">+ if (captures.size() <= m_captureIndex || captures.at(m_captureIndex).isEmpty())</span> 0034 <span style="color:#0057ae">+ return offset;</span> 0035 <span style="color:#0057ae">+ if (text.at(offset) == captures.at(m_captureIndex).at(0))</span> 0036 <span style="color:#0057ae">+ return offset + 1;</span> 0037 <span style="color:#0057ae">+ return offset;</span> 0038 <span style="color:#0057ae">+ }</span> 0039 <span style="color:#0057ae">+</span> 0040 if (text.at(offset) == m_char) 0041 return offset + 1; 0042 return offset; 0043 <span style="font-weight:bold">diff --git a/src/lib/rule_p.h b/src/lib/rule_p.h</span> 0044 index d8862ae..d9cedbf 100644 0045 <span style="color:#0057ae">--- a/src/lib/rule_p.h</span> 0046 <span style="color:#0057ae">+++ b/src/lib/rule_p.h</span> 0047 <span style="color:#0057ae">@@ -103,6 +103,7 @@ protected:</span> 0048 0049 private: 0050 QChar m_char; 0051 <span style="color:#0057ae">+ int m_captureIndex;</span> 0052 }; 0053 0054 class Detect2Char : public Rule 0055 </pre></body></html>