[Scummvm-git-logs] scummvm master -> c2054682f0f20ad284582b0717d0298df401a228
bluegr
bluegr at gmail.com
Tue Aug 20 12:53:05 CEST 2019
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c2054682f0 COMMON: added support for ini files with non english characters
Commit: c2054682f0f20ad284582b0717d0298df401a228
https://github.com/scummvm/scummvm/commit/c2054682f0f20ad284582b0717d0298df401a228
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2019-08-20T13:53:01+03:00
Commit Message:
COMMON: added support for ini files with non english characters
Changed paths:
common/ini-file.cpp
common/ini-file.h
diff --git a/common/ini-file.cpp b/common/ini-file.cpp
index 90d40b7..4c4acc9 100644
--- a/common/ini-file.cpp
+++ b/common/ini-file.cpp
@@ -29,12 +29,18 @@
namespace Common {
bool INIFile::isValidName(const String &name) const {
+ if (_allowNonEnglishCharacters)
+ return true;
const char *p = name.c_str();
while (*p && (isAlnum(*p) || *p == '-' || *p == '_' || *p == '.' || *p == ' '))
p++;
return *p == 0;
}
+INIFile::INIFile() {
+ _allowNonEnglishCharacters = false;
+}
+
void INIFile::clear() {
_sections.clear();
}
@@ -102,7 +108,7 @@ bool INIFile::loadFromStream(SeekableReadStream &stream) {
// is, verify that it only consists of alphanumerics,
// periods, dashes and underscores). Mohawk Living Books games
// can have periods in their section names.
- while (*p && (isAlnum(*p) || *p == '-' || *p == '_' || *p == '.' || *p == ' '))
+ while (*p && ((_allowNonEnglishCharacters && *p != ']') || isAlnum(*p) || *p == '-' || *p == '_' || *p == '.' || *p == ' '))
p++;
if (*p == '\0')
@@ -435,4 +441,8 @@ void INIFile::Section::removeKey(const String &key) {
}
}
+void INIFile::allowNonEnglishCharacters() {
+ _allowNonEnglishCharacters = true;
+}
+
} // End of namespace Common
diff --git a/common/ini-file.h b/common/ini-file.h
index 98be1e0..5d72f23 100644
--- a/common/ini-file.h
+++ b/common/ini-file.h
@@ -77,7 +77,7 @@ public:
typedef List<Section> SectionList;
public:
- INIFile() {}
+ INIFile();
~INIFile() {}
// TODO: Maybe add a copy constructor etc.?
@@ -115,8 +115,11 @@ public:
void listKeyValues(StringMap &kv);
+ void allowNonEnglishCharacters();
+
private:
SectionList _sections;
+ bool _allowNonEnglishCharacters;
Section *getSection(const String §ion);
const Section *getSection(const String §ion) const;
More information about the Scummvm-git-logs
mailing list