Changeset View
Changeset View
Standalone View
Standalone View
src/lib/rule.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 66 | if (isOctalChar(c)) { // octal encoding | |||
---|---|---|---|---|---|
72 | if (newOffset == offset + 2) | 72 | if (newOffset == offset + 2) | ||
73 | return offset; | 73 | return offset; | ||
74 | return newOffset; | 74 | return newOffset; | ||
75 | } | 75 | } | ||
76 | 76 | | |||
77 | return offset; | 77 | return offset; | ||
78 | } | 78 | } | ||
79 | 79 | | |||
80 | static QString quoteCapture(const QString &capture) | | |||
81 | { | | |||
82 | auto quoted = capture; | | |||
83 | return quoted.replace(QRegularExpression(QStringLiteral("(\\W)")), QStringLiteral("\\\\1")); | | |||
84 | } | | |||
85 | | ||||
86 | static QString replaceCaptures(const QString &pattern, const QStringList &captures, bool quote) | 80 | static QString replaceCaptures(const QString &pattern, const QStringList &captures, bool quote) | ||
87 | { | 81 | { | ||
88 | auto result = pattern; | 82 | auto result = pattern; | ||
89 | for (int i = 1; i < captures.size(); ++i) { | 83 | for (int i = captures.size() - 1; i >= 1; --i) { | ||
90 | result.replace(QLatin1Char('%') + QString::number(i), quote ? quoteCapture(captures.at(i)) : captures.at(i)); | 84 | result.replace(QLatin1Char('%') + QString::number(i), quote ? QRegularExpression::escape(captures.at(i)) : captures.at(i)); | ||
91 | } | 85 | } | ||
92 | return result; | 86 | return result; | ||
93 | } | 87 | } | ||
94 | 88 | | |||
95 | | ||||
96 | Rule::Rule() : | 89 | Rule::Rule() : | ||
97 | m_column(-1), | 90 | m_column(-1), | ||
98 | m_firstNonSpace(false), | 91 | m_firstNonSpace(false), | ||
99 | m_lookAhead(false), | 92 | m_lookAhead(false), | ||
100 | m_dynamic(false) | 93 | m_dynamic(false) | ||
101 | { | 94 | { | ||
102 | } | 95 | } | ||
103 | 96 | | |||
▲ Show 20 Lines • Show All 598 Lines • Show Last 20 Lines |