diff options
author | Petr Mrázek <peterix@users.noreply.github.com> | 2019-06-23 21:19:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-23 21:19:10 +0200 |
commit | 2f1d31cf43df796a267c2ae32c8ce16be269f698 (patch) | |
tree | 513df43a17e3675b6c75ddd43d64e50b09e91232 /api/logic/settings/INIFile.cpp | |
parent | e7c5b266c86cb24cf3c1fc92ef34ad6726ac5df1 (diff) | |
parent | 7b52b8689be4243f287966ae9c9a50a8a614e49e (diff) | |
download | PrismLauncher-2f1d31cf43df796a267c2ae32c8ce16be269f698.tar.gz PrismLauncher-2f1d31cf43df796a267c2ae32c8ce16be269f698.tar.bz2 PrismLauncher-2f1d31cf43df796a267c2ae32c8ce16be269f698.zip |
Merge pull request #2706 from Janrupf/feature/fix_hashtag_in_notes
Feature/fix hashtag in notes
Diffstat (limited to 'api/logic/settings/INIFile.cpp')
-rw-r--r-- | api/logic/settings/INIFile.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/api/logic/settings/INIFile.cpp b/api/logic/settings/INIFile.cpp index 42244131..ff6d5cf3 100644 --- a/api/logic/settings/INIFile.cpp +++ b/api/logic/settings/INIFile.cpp @@ -36,8 +36,10 @@ QString INIFile::unescape(QString orig) { if(c == 'n') out += '\n'; - else if (c == 't') + else if(c == 't') out += '\t'; + else if(c == '#') + out += '#'; else out += c; prev = 0; @@ -67,6 +69,8 @@ QString INIFile::escape(QString orig) out += "\\t"; else if(c == '\\') out += "\\\\"; + else if(c == '#') + out += "\\#"; else out += c; } @@ -120,7 +124,15 @@ bool INIFile::loadFile(QByteArray file) { QString &lineRaw = lines[i]; // Ignore comments. - QString line = lineRaw.left(lineRaw.indexOf('#')).trimmed(); + int commentIndex = 0; + QString line = lineRaw; + // Search for comments until no more escaped # are available + while((commentIndex = line.indexOf('#', commentIndex + 1)) != -1) { + if(commentIndex > 0 && line.at(commentIndex - 1) == '\\') { + continue; + } + line = line.left(lineRaw.indexOf('#')).trimmed(); + } int eqPos = line.indexOf('='); if (eqPos == -1) |