diff options
author | Sergey Shambir <sergey.shambir.auto@gmail.com> | 2013-02-03 20:47:45 +0400 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2013-02-08 13:16:08 +0100 |
commit | 68aeaa5fc40abd39ddd55f4530b9d6b4daaf95a8 (patch) | |
tree | 2b5cf0c7fd5617c794d87578959e293940a6ef24 /src/plugins/autotoolsprojectmanager/makefileparser.cpp | |
parent | c7ca78afd096b69122adf67e23115170fe56bbf6 (diff) | |
download | qt-creator-68aeaa5fc40abd39ddd55f4530b9d6b4daaf95a8.tar.gz |
Autotools: fixed parsing var assignment without space before =
Parser worked correctly with 'bin_PROGRAMS =', but failed on
'bin_PROGRAMS='. To reproduce problem on Ubuntu, perform 'apt-get source
gentoo' and open Makefile.am in downloaded folder as project: it will be
empty before this change.
Change-Id: I71d0866a2b9d8228ad5ac9237fa34be14b9e9b38
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
Diffstat (limited to 'src/plugins/autotoolsprojectmanager/makefileparser.cpp')
-rw-r--r-- | src/plugins/autotoolsprojectmanager/makefileparser.cpp | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/src/plugins/autotoolsprojectmanager/makefileparser.cpp b/src/plugins/autotoolsprojectmanager/makefileparser.cpp index 1f1dfdc299..a6fc4c266d 100644 --- a/src/plugins/autotoolsprojectmanager/makefileparser.cpp +++ b/src/plugins/autotoolsprojectmanager/makefileparser.cpp @@ -137,26 +137,27 @@ bool MakefileParser::isCanceled() const MakefileParser::TopTarget MakefileParser::topTarget() const { - TopTarget topTarget = Undefined; - const QString line = m_line.simplified(); - if (!line.isEmpty() && !line.startsWith(QLatin1Char('#'))) { - // TODO: Check how many fixed strings like AM_DEFAULT_SOURCE_EXT will - // be needed vs. variable strings like _SOURCES. Dependent on this a - // more clever way than this (expensive) if-cascading might be done. - if (line.startsWith(QLatin1String("AM_DEFAULT_SOURCE_EXT ="))) - topTarget = AmDefaultSourceExt; - else if (line.startsWith(QLatin1String("bin_PROGRAMS ="))) - topTarget = BinPrograms; - else if (line.startsWith(QLatin1String("BUILT_SOURCES ="))) - topTarget = BuiltSources; - else if (line.contains(QLatin1String("SUBDIRS ="))) - topTarget = SubDirs; - else if (line.contains(QLatin1String("_SOURCES ="))) - topTarget = Sources; - } - return topTarget; + if (line.isEmpty() || line.startsWith(QLatin1Char('#'))) + return Undefined; + + const QString id = parseIdentifierBeforeAssign(line); + if (id.isEmpty()) + return Undefined; + + if (id == QLatin1String("AM_DEFAULT_SOURCE_EXT")) + return AmDefaultSourceExt; + if (id == QLatin1String("bin_PROGRAMS")) + return BinPrograms; + if (id == QLatin1String("BUILT_SOURCES")) + return BuiltSources; + if (id == QLatin1String("SUBDIRS") || id == QLatin1String("DIST_SUBDIRS")) + return SubDirs; + if (id.endsWith(QLatin1String("_SOURCES"))) + return Sources; + + return Undefined; } void MakefileParser::parseBinPrograms() @@ -410,6 +411,19 @@ void MakefileParser::appendHeader(QStringList &list, const QDir &dir, const QSt } } +QString MakefileParser::parseIdentifierBeforeAssign(const QString &line) +{ + int end = 0; + for (; end < line.size(); ++end) + if (!line[end].isLetterOrNumber() && line[end] != QLatin1Char('_')) + break; + + QString ret = line.left(end); + while (end < line.size() && line[end].isSpace()) + ++end; + return (line[end] == QLatin1Char('=')) ? ret : QString(); +} + void MakefileParser::addAllSources() { QStringList extensions; |