[Scummvm-cvs-logs] CVS: scummvm/common config-manager.cpp,1.2,1.3
Max Horn
fingolfin at users.sourceforge.net
Fri Oct 10 04:14:02 CEST 2003
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv31003/common
Modified Files:
config-manager.cpp
Log Message:
modified version of patch #821018; fix for bug #821083
Index: config-manager.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/config-manager.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- config-manager.cpp 9 Oct 2003 11:42:59 -0000 1.2
+++ config-manager.cpp 10 Oct 2003 11:13:25 -0000 1.3
@@ -51,7 +51,6 @@
return t;
}
-
namespace Common {
const String ConfigManager::kApplicationDomain("scummvm");
@@ -98,16 +97,18 @@
void ConfigManager::loadFile(const String &filename) {
FILE *cfg_file;
- char t[MAXLINELEN];
+ char buf[MAXLINELEN];
+ char *t;
String domain;
if (!(cfg_file = fopen(filename.c_str(), "r"))) {
debug(1, "Unable to open configuration file: %s.\n", filename.c_str());
} else {
while (!feof(cfg_file)) {
+ t = buf;
if (!fgets(t, MAXLINELEN, cfg_file))
continue;
- if (t[0] != '#') {
+ if (t[0] && t[0] != '#') {
if (t[0] == '[') {
// It's a new domain which begins here.
char *p = strchr(t, ']');
@@ -120,10 +121,20 @@
domain = t + 1;
}
} else {
- // It's a new key in the domain.
+ // Skip leading whitespaces
+ while (*t && isspace(*t)) {
+ t++;
+ }
+ // Skip empty lines
+ if (*t == 0)
+ continue;
+
+ // If no domain has been set, this config file is invalid!
if (domain.isEmpty()) {
error("Config file buggy: we have a key without a domain first.\n");
}
+
+ // It's a new key in the domain.
char *p = strchr(t, '\n');
if (p)
*p = 0;
@@ -299,8 +310,10 @@
}
void ConfigManager::set(const String &key, const String &value, const String &dom) {
- if (dom.isEmpty())
+ if (dom.isEmpty()) {
set(key, value);
+ return;
+ }
if (_globalDomains.contains(dom))
_globalDomains[dom][key] = value;
More information about the Scummvm-git-logs
mailing list