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)
|
||||
{
|
||||
// Strip comments:
|
||||
// Strip comments (only at start of line!):
|
||||
int commentStart = s.count();
|
||||
int pos = s.indexOf(QLatin1Char('#'));
|
||||
if (pos >= 0)
|
||||
commentStart = pos;
|
||||
pos = s.indexOf(QLatin1String("//"));
|
||||
if (pos >= 0 && pos < commentStart)
|
||||
commentStart = pos;
|
||||
|
||||
for (int i = 0; i < s.count(); ++i) {
|
||||
const QChar c = s.at(i);
|
||||
if (c == ' ' || c == '\t')
|
||||
continue;
|
||||
else if ((c == '#')
|
||||
|| (c == '/' && i < s.count() - 1 && s.at(i + 1) == '/')) {
|
||||
commentStart = i;
|
||||
break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
const QString line = s.mid(0, commentStart);
|
||||
|
||||
// Split up line:
|
||||
|
Reference in New Issue
Block a user