diff options
Diffstat (limited to 'src/libs/utils/templateengine.cpp')
-rw-r--r-- | src/libs/utils/templateengine.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/libs/utils/templateengine.cpp b/src/libs/utils/templateengine.cpp index e78af8bc36..2030e62237 100644 --- a/src/libs/utils/templateengine.cpp +++ b/src/libs/utils/templateengine.cpp @@ -28,7 +28,7 @@ #include "qtcassert.h" #include <QJSEngine> -#include <QRegExp> +#include <QRegularExpression> #include <QStack> namespace Utils { @@ -73,10 +73,10 @@ private: void reset(); PreprocessorSection preprocessorLine(const QString & in, QString *ifExpression) const; - mutable QRegExp m_ifPattern; - mutable QRegExp m_elsifPattern; - mutable QRegExp m_elsePattern; - mutable QRegExp m_endifPattern; + mutable QRegularExpression m_ifPattern; + mutable QRegularExpression m_elsifPattern; + mutable QRegularExpression m_elsePattern; + mutable QRegularExpression m_endifPattern; QStack<PreprocessStackEntry> m_sectionStack; QJSEngine m_scriptEngine; @@ -105,20 +105,24 @@ void PreprocessContext::reset() PreprocessorSection PreprocessContext::preprocessorLine(const QString &in, QString *ifExpression) const { - if (m_ifPattern.exactMatch(in)) { - *ifExpression = m_ifPattern.cap(2).trimmed(); + QRegularExpressionMatch match = m_ifPattern.match(in); + if (match.hasMatch()) { + *ifExpression = match.captured(2).trimmed(); return IfSection; } - if (m_elsifPattern.exactMatch(in)) { - *ifExpression = m_elsifPattern.cap(2).trimmed(); + match = m_elsifPattern.match(in); + if (match.hasMatch()) { + *ifExpression = match.captured(2).trimmed(); return ElsifSection; } ifExpression->clear(); - if (m_elsePattern.exactMatch(in)) + match = m_elsePattern.match(in); + if (match.hasMatch()) return ElseSection; - if (m_endifPattern.exactMatch(in)) + match = m_endifPattern.match(in); + if (match.hasMatch()) return EndifSection; return OtherSection; } @@ -138,7 +142,7 @@ bool PreprocessContext::process(const QString &in, QString *out, QString *errorM reset(); const QChar newLine = QLatin1Char('\n'); - const QStringList lines = in.split(newLine, QString::KeepEmptyParts); + const QStringList lines = in.split(newLine); const int lineCount = lines.size(); bool first = true; for (int l = 0; l < lineCount; l++) { |