From 637d53c649abe2b7c2d288e240d49dd47407d427 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Mon, 22 Sep 2014 16:42:36 +0200 Subject: [PATCH] GnuMakeParser: Use QRegularExpression Change-Id: I54813888af9203214b3d48732dab71bbc279c220 Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/gnumakeparser.cpp | 30 +++++++++---------- src/plugins/projectexplorer/gnumakeparser.h | 10 +++---- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/plugins/projectexplorer/gnumakeparser.cpp b/src/plugins/projectexplorer/gnumakeparser.cpp index 115a8e296da..b6036fdd1e7 100644 --- a/src/plugins/projectexplorer/gnumakeparser.cpp +++ b/src/plugins/projectexplorer/gnumakeparser.cpp @@ -41,8 +41,8 @@ using namespace ProjectExplorer; namespace { // optional full path, make executable name, optional exe extension, optional number in square brackets, colon space - const char * const MAKEEXEC_PATTERN("^(.*[/\\\\])?(mingw(32|64)-|g)?make(.exe)?(\\[\\d+\\])?:\\s"); - const char * const MAKEFILE_PATTERN("^((.*[/\\\\])?[Mm]akefile(\\.[a-zA-Z]+)?):(\\d+):\\s"); + const char * const MAKEEXEC_PATTERN("^(.*?[/\\\\])?(mingw(32|64)-|g)?make(.exe)?(\\[\\d+\\])?:\\s"); + const char * const MAKEFILE_PATTERN("^((.*?[/\\\\])?[Mm]akefile(\\.[a-zA-Z]+)?):(\\d+):\\s"); } GnuMakeParser::GnuMakeParser() : @@ -52,13 +52,10 @@ GnuMakeParser::GnuMakeParser() : setObjectName(QLatin1String("GnuMakeParser")); m_makeDir.setPattern(QLatin1String(MAKEEXEC_PATTERN) + QLatin1String("(\\w+) directory .(.+).$")); - m_makeDir.setMinimal(true); QTC_CHECK(m_makeDir.isValid()); m_makeLine.setPattern(QLatin1String(MAKEEXEC_PATTERN) + QLatin1String("(.*)$")); - m_makeLine.setMinimal(true); QTC_CHECK(m_makeLine.isValid()); m_errorInMakefile.setPattern(QLatin1String(MAKEFILE_PATTERN) + QLatin1String("(.*)$")); - m_errorInMakefile.setMinimal(true); QTC_CHECK(m_errorInMakefile.isValid()); } @@ -77,11 +74,12 @@ void GnuMakeParser::stdOutput(const QString &line) { const QString lne = rightTrimmed(line); - if (m_makeDir.indexIn(lne) > -1) { - if (m_makeDir.cap(6) == QLatin1String("Leaving")) - removeDirectory(m_makeDir.cap(7)); + QRegularExpressionMatch match = m_makeDir.match(lne); + if (match.hasMatch()) { + if (match.captured(6) == QLatin1String("Leaving")) + removeDirectory(match.captured(7)); else - addDirectory(m_makeDir.cap(7)); + addDirectory(match.captured(7)); return; } @@ -120,20 +118,22 @@ void GnuMakeParser::stdError(const QString &line) { const QString lne = rightTrimmed(line); - if (m_errorInMakefile.indexIn(lne) > -1) { - Result res = parseDescription(m_errorInMakefile.cap(5)); + QRegularExpressionMatch match = m_errorInMakefile.match(lne); + if (match.hasMatch()) { + Result res = parseDescription(match.captured(5)); if (res.isFatal) ++m_fatalErrorCount; if (!m_suppressIssues) { taskAdded(Task(res.type, res.description, - Utils::FileName::fromUserInput(m_errorInMakefile.cap(1)) /* filename */, - m_errorInMakefile.cap(4).toInt(), /* line */ + Utils::FileName::fromUserInput(match.captured(1)) /* filename */, + match.captured(4).toInt(), /* line */ Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM))); } return; } - if (m_makeLine.indexIn(lne) > -1) { - Result res = parseDescription(m_makeLine.cap(6)); + match = m_makeLine.match(lne); + if (match.hasMatch()) { + Result res = parseDescription(match.captured(6)); if (res.isFatal) ++m_fatalErrorCount; if (!m_suppressIssues) { diff --git a/src/plugins/projectexplorer/gnumakeparser.h b/src/plugins/projectexplorer/gnumakeparser.h index 99ddc781522..c8fd6391c66 100644 --- a/src/plugins/projectexplorer/gnumakeparser.h +++ b/src/plugins/projectexplorer/gnumakeparser.h @@ -32,7 +32,7 @@ #include "ioutputparser.h" -#include +#include #include namespace ProjectExplorer { @@ -60,10 +60,10 @@ private: void addDirectory(const QString &dir); void removeDirectory(const QString &dir); - QRegExp m_makeDir; - QRegExp m_makeLine; - QRegExp m_threeStarError; - QRegExp m_errorInMakefile; + QRegularExpression m_makeDir; + QRegularExpression m_makeLine; + QRegularExpression m_threeStarError; + QRegularExpression m_errorInMakefile; QStringList m_directories;