Prechádzať zdrojové kódy

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 rokov pred
rodič
commit
f5cda9ea65
1 zmenil súbory, kde vykonal 1 pridanie a 1 odobranie
  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))
   {