aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeconfigitem.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeconfigitem.cpp b/src/plugins/cmakeprojectmanager/cmakeconfigitem.cpp
index 2b09a3769c7..258803d45e7 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: