[Scummvm-git-logs] scummvm master -> f30ab9b70f8b818c19bce32f6fc4308a7efd24f2
bluegr
noreply at scummvm.org
Wed May 10 21:22:19 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e219e4e04e COMMON: Strip whitespace before checking if an INI line is a comment.
f30ab9b70f TEST: Add test for comment prefixed by whitespace.
Commit: e219e4e04e7727fd997eb18b85ffd3bec622059c
https://github.com/scummvm/scummvm/commit/e219e4e04e7727fd997eb18b85ffd3bec622059c
Author: elasota (ejlasota at gmail.com)
Date: 2023-05-11T00:22:14+03:00
Commit Message:
COMMON: Strip whitespace before checking if an INI line is a comment.
Fixes some versions of Reah failing to parse subtitle data.
Changed paths:
common/formats/ini-file.cpp
diff --git a/common/formats/ini-file.cpp b/common/formats/ini-file.cpp
index 0beb9e1e2a7..2cbbe421baf 100644
--- a/common/formats/ini-file.cpp
+++ b/common/formats/ini-file.cpp
@@ -105,6 +105,8 @@ bool INIFile::loadFromStream(SeekableReadStream &stream) {
// Read a line
String line = stream.readLine();
+ line.trim();
+
if (line.size() == 0) {
// Do nothing
} else if (line[0] == '#' || line[0] == ';' || line.hasPrefix("//")) {
@@ -156,30 +158,21 @@ bool INIFile::loadFromStream(SeekableReadStream &stream) {
} else {
// This line should be a line with a 'key=value' pair, or an empty one.
- // Skip leading whitespaces
- const char *t = line.c_str();
- while (isSpace(*t))
- t++;
-
- // Skip empty lines / lines with only whitespace
- if (*t == 0)
- continue;
-
// If no section has been set, this config file is invalid!
if (section.name.empty()) {
error("INIFile::loadFromStream: Key/value pair found outside a section in line %d", lineno);
}
// Split string at '=' into 'key' and 'value'. First, find the "=" delimeter.
- const char *p = strchr(t, '=');
+ const char *p = strchr(line.c_str(), '=');
if (!p) {
if (!_suppressValuelessLineWarning)
- warning("Config file buggy: Junk found in line %d: '%s'", lineno, t);
- kv.key = String(t);
+ warning("Config file buggy: Junk found in line %d: '%s'", lineno, line.c_str());
+ kv.key = line;
kv.value.clear();
} else {
// Extract the key/value pair
- kv.key = String(t, p);
+ kv.key = String(line.c_str(), p);
kv.value = String(p + 1);
}
Commit: f30ab9b70f8b818c19bce32f6fc4308a7efd24f2
https://github.com/scummvm/scummvm/commit/f30ab9b70f8b818c19bce32f6fc4308a7efd24f2
Author: elasota (ejlasota at gmail.com)
Date: 2023-05-11T00:22:14+03:00
Commit Message:
TEST: Add test for comment prefixed by whitespace.
Changed paths:
test/common/ini-file.h
diff --git a/test/common/ini-file.h b/test/common/ini-file.h
index 17eca67132d..eaad9c21fd0 100644
--- a/test/common/ini-file.h
+++ b/test/common/ini-file.h
@@ -39,7 +39,7 @@ class IniFileTestSuite : public CxxTest::TestSuite {
}
void test_multisection_ini_file() {
- static const unsigned char inistr[] = "[s]\nabc=1\ndef=xyz\n#comment=no\n[empty]\n\n[s2]\n abc = 2 ";
+ static const unsigned char inistr[] = "[s]\nabc=1\ndef=xyz\n#comment=no\n[empty]\n\n[s2]\n abc = 2 \n ; comment=no";
Common::MemoryReadStream ms(inistr, sizeof(inistr));
Common::INIFile inifile;
bool result = inifile.loadFromStream(ms);
More information about the Scummvm-git-logs
mailing list