forked from qt-creator/qt-creator
IOutputParser: Make sure to not cut too much output
Introduce a method to cut away whitespaces from the end of a string and use it consistently. This avoids a chain of parsers to repeatedly cut away the last character, assuming that will be the line-break. Task-number: QTCREATORBUG-9032 Change-Id: I68261c10873535faf94c885c914cd00510ed75d8 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -33,10 +33,8 @@
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace {
|
||||
// opt. drive letter + filename: (2 brackets)
|
||||
const char * const FILE_PATTERN = "(<command line>|([A-Za-z]:)?[^:]+\\.[^:]+)";
|
||||
}
|
||||
// opt. drive letter + filename: (2 brackets)
|
||||
static const char * const FILE_PATTERN = "(<command line>|([A-Za-z]:)?[^:]+\\.[^:]+)";
|
||||
|
||||
ClangParser::ClangParser() :
|
||||
m_commandRegExp(QLatin1String("^clang(\\+\\+)?: +(fatal +)?(warning|error|note): (.*)$")),
|
||||
@@ -57,7 +55,7 @@ ClangParser::~ClangParser()
|
||||
|
||||
void ClangParser::stdError(const QString &line)
|
||||
{
|
||||
const QString lne = line.left(line.count() - 1);
|
||||
const QString lne = rightTrimmed(line);
|
||||
if (m_summaryRegExp.indexIn(lne) > -1) {
|
||||
emitTask();
|
||||
m_expectSnippet = false;
|
||||
|
||||
@@ -62,7 +62,7 @@ GccParser::GccParser()
|
||||
|
||||
void GccParser::stdError(const QString &line)
|
||||
{
|
||||
QString lne = line.trimmed();
|
||||
QString lne = rightTrimmed(line);
|
||||
|
||||
// Blacklist some lines to not handle them:
|
||||
if (lne.startsWith(QLatin1String("TeamBuilder ")) ||
|
||||
@@ -117,7 +117,7 @@ void GccParser::stdError(const QString &line)
|
||||
return;
|
||||
} else if (m_regExpIncluded.indexIn(lne) > -1) {
|
||||
emit addTask(Task(Task::Unknown,
|
||||
lne /* description */,
|
||||
lne.trimmed() /* description */,
|
||||
Utils::FileName::fromUserInput(m_regExpIncluded.cap(1)) /* filename */,
|
||||
m_regExpIncluded.cap(3).toInt() /* linenumber */,
|
||||
Core::Id(Constants::TASK_CATEGORY_COMPILE)));
|
||||
|
||||
@@ -69,7 +69,7 @@ bool GnuMakeParser::hasFatalErrors() const
|
||||
|
||||
void GnuMakeParser::stdOutput(const QString &line)
|
||||
{
|
||||
QString lne = line.trimmed();
|
||||
const QString lne = rightTrimmed(line);
|
||||
|
||||
if (m_makeDir.indexIn(lne) > -1) {
|
||||
if (m_makeDir.cap(7) == QLatin1String("Leaving"))
|
||||
@@ -84,7 +84,7 @@ void GnuMakeParser::stdOutput(const QString &line)
|
||||
|
||||
void GnuMakeParser::stdError(const QString &line)
|
||||
{
|
||||
QString lne = line.trimmed();
|
||||
const QString lne = rightTrimmed(line);
|
||||
|
||||
if (m_makefileError.indexIn(lne) > -1) {
|
||||
++m_fatalErrorCount;
|
||||
|
||||
@@ -191,4 +191,14 @@ void IOutputParser::setWorkingDirectory(const QString &workingDirectory)
|
||||
m_parser->setWorkingDirectory(workingDirectory);
|
||||
}
|
||||
|
||||
QString IOutputParser::rightTrimmed(const QString &in)
|
||||
{
|
||||
int pos = in.length();
|
||||
for (; pos > 0; --pos) {
|
||||
if (!in.at(pos - 1).isSpace())
|
||||
break;
|
||||
}
|
||||
return in.mid(0, pos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
// For GnuMakeParser
|
||||
virtual void setWorkingDirectory(const QString &workingDirectory);
|
||||
|
||||
static QString rightTrimmed(const QString &in);
|
||||
|
||||
signals:
|
||||
void addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat format);
|
||||
void addTask(const ProjectExplorer::Task &task);
|
||||
|
||||
@@ -57,7 +57,7 @@ LdParser::LdParser()
|
||||
|
||||
void LdParser::stdError(const QString &line)
|
||||
{
|
||||
QString lne = line.trimmed();
|
||||
QString lne = rightTrimmed(line);
|
||||
if (lne.startsWith(QLatin1String("TeamBuilder "))
|
||||
|| lne.startsWith(QLatin1String("distcc["))
|
||||
|| lne.contains(QLatin1String("ar: creating "))) {
|
||||
|
||||
@@ -44,7 +44,7 @@ QMakeParser::QMakeParser() : m_error(QLatin1String("^(.+):(\\d+):\\s(.+)$"))
|
||||
|
||||
void QMakeParser::stdError(const QString &line)
|
||||
{
|
||||
QString lne(line.trimmed());
|
||||
QString lne = rightTrimmed(line);
|
||||
if (lne.startsWith(QLatin1String("Project ERROR:"))) {
|
||||
const QString description = lne.mid(15);
|
||||
emit addTask(Task(Task::Error,
|
||||
|
||||
@@ -47,7 +47,7 @@ QtParser::QtParser() :
|
||||
|
||||
void QtParser::stdError(const QString &line)
|
||||
{
|
||||
QString lne(line.trimmed());
|
||||
QString lne = rightTrimmed(line);
|
||||
if (m_mocRegExp.indexIn(lne) > -1) {
|
||||
bool ok;
|
||||
int lineno = m_mocRegExp.cap(3).toInt(&ok);
|
||||
|
||||
Reference in New Issue
Block a user