diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2017-06-20 11:47:36 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2017-06-20 13:38:28 +0000 |
commit | a027f1cfcede0c404991416f831c57dd5cd9bed3 (patch) | |
tree | c68fb73aca2811a93e3bdb0a308915476a60d60a /src/plugins/cmakeprojectmanager | |
parent | 8542ebcd5dd312aa3038d0b70c861dc05c71333a (diff) | |
download | qt-creator-a027f1cfcede0c404991416f831c57dd5cd9bed3.tar.gz |
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>
Diffstat (limited to 'src/plugins/cmakeprojectmanager')
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeconfigitem.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeconfigitem.cpp b/src/plugins/cmakeprojectmanager/cmakeconfigitem.cpp index 2b09a3769c..258803d45e 100644 --- a/src/plugins/cmakeprojectmanager/cmakeconfigitem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeconfigitem.cpp @@ -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: |