فهرست منبع

Utils: simplify comment skipping regexp

We have low-effort support for skipping comments in JSON (since neither
JSON nor Qt's JSON parser has support for comments). Unfortunately, it
was dropping lines that merely contained "//" within strings.

Simplify the regexp, so that only lines are skipped that consist of
whitespace between line start and comment begin. That's all we need.

This fixes some cases of storage.json loading failures.
Vincent Lang 9 سال پیش
والد
کامیت
f5cda9ea65
1فایلهای تغییر یافته به همراه1 افزوده شده و 1 حذف شده
  1. 1 1
      src/utils/Utils.cpp

+ 1 - 1
src/utils/Utils.cpp

@@ -32,7 +32,7 @@ QJsonDocument Utils::OpenJsonDocument(const QString& path, QJsonParseError* err)
 {
   QFile fp(path);
   QByteArray fdata;
-  QRegExp commentMatch("^\\s*(\\S+\\s*=([^\\//]|\\//?)*)?(//.*)?$");
+  QRegExp commentMatch("^\\s*//");
 
   if (fp.open(QFile::ReadOnly))
   {