소스 검색

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))
   {