Explorar o código

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 %!s(int64=9) %!d(string=hai) anos
pai
achega
f5cda9ea65
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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))
   {