forked from qt-creator/qt-creator
CMake: Only handle strings at start of line
Allow comments at the start of line only (or after only space characters) in CMakeCache.txt-style lines. Task-number: QTCREATORBUG-18385 Change-Id: I8b69144ea4f6a667ae1df382c8c4c1e88eca799b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -170,15 +170,20 @@ std::function<bool (const CMakeConfigItem &a, const CMakeConfigItem &b)> CMakeCo
|
|||||||
|
|
||||||
CMakeConfigItem CMakeConfigItem::fromString(const QString &s)
|
CMakeConfigItem CMakeConfigItem::fromString(const QString &s)
|
||||||
{
|
{
|
||||||
// Strip comments:
|
// Strip comments (only at start of line!):
|
||||||
int commentStart = s.count();
|
int commentStart = s.count();
|
||||||
int pos = s.indexOf(QLatin1Char('#'));
|
for (int i = 0; i < s.count(); ++i) {
|
||||||
if (pos >= 0)
|
const QChar c = s.at(i);
|
||||||
commentStart = pos;
|
if (c == ' ' || c == '\t')
|
||||||
pos = s.indexOf(QLatin1String("//"));
|
continue;
|
||||||
if (pos >= 0 && pos < commentStart)
|
else if ((c == '#')
|
||||||
commentStart = pos;
|
|| (c == '/' && i < s.count() - 1 && s.at(i + 1) == '/')) {
|
||||||
|
commentStart = i;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
const QString line = s.mid(0, commentStart);
|
const QString line = s.mid(0, commentStart);
|
||||||
|
|
||||||
// Split up line:
|
// Split up line:
|
||||||
|
Reference in New Issue
Block a user