From c318d82f013d13c02ae0494614f6c4dac480dced Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 24 Apr 2005 03:41:57 +0000 Subject: The last section of config file was not saved, when loading config file. Fix all string compares. svn-id: r17781 --- common/config-file.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/config-file.cpp b/common/config-file.cpp index f8d31b783b..877beafce7 100644 --- a/common/config-file.cpp +++ b/common/config-file.cpp @@ -150,6 +150,10 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) { } } + // Save last section + if (!section.name.isEmpty()) + _sections.push_back(section); + return !stream.ioFailed(); } @@ -195,7 +199,7 @@ bool ConfigFile::saveToStream(WriteStream &stream) { void ConfigFile::removeSection(const String §ion) { assert(isValidName(section)); for (List
::iterator i = _sections.begin(); i != _sections.end(); ++i) { - if (scumm_stricmp(section.c_str(), i->name.c_str())) { + if (!scumm_stricmp(section.c_str(), i->name.c_str())) { _sections.erase(i); return; } @@ -282,7 +286,7 @@ void ConfigFile::setKey(const String &key, const String §ion, const String & ConfigFile::Section *ConfigFile::getSection(const String §ion) { for (List
::iterator i = _sections.begin(); i != _sections.end(); ++i) { - if (scumm_stricmp(section.c_str(), i->name.c_str())) { + if (!scumm_stricmp(section.c_str(), i->name.c_str())) { return &(*i); } } @@ -291,7 +295,7 @@ ConfigFile::Section *ConfigFile::getSection(const String §ion) { const ConfigFile::Section *ConfigFile::getSection(const String §ion) const { for (List
::const_iterator i = _sections.begin(); i != _sections.end(); ++i) { - if (scumm_stricmp(section.c_str(), i->name.c_str())) { + if (!scumm_stricmp(section.c_str(), i->name.c_str())) { return &(*i); } } @@ -304,7 +308,7 @@ bool ConfigFile::Section::hasKey(const String &key) const { const ConfigFile::KeyValue* ConfigFile::Section::getKey(const String &key) const { for (List::const_iterator i = keys.begin(); i != keys.end(); ++i) { - if (scumm_stricmp(key.c_str(), i->key.c_str())) { + if (!scumm_stricmp(key.c_str(), i->key.c_str())) { return &(*i); } } @@ -313,7 +317,7 @@ const ConfigFile::KeyValue* ConfigFile::Section::getKey(const String &key) const void ConfigFile::Section::setKey(const String &key, const String &value) { for (List::iterator i = keys.begin(); i != keys.end(); ++i) { - if (scumm_stricmp(key.c_str(), i->key.c_str())) { + if (!scumm_stricmp(key.c_str(), i->key.c_str())) { i->value = value; return; } @@ -327,7 +331,7 @@ void ConfigFile::Section::setKey(const String &key, const String &value) { void ConfigFile::Section::removeKey(const String &key) { for (List::iterator i = keys.begin(); i != keys.end(); ++i) { - if (scumm_stricmp(key.c_str(), i->key.c_str())) { + if (!scumm_stricmp(key.c_str(), i->key.c_str())) { keys.erase(i); return; } -- cgit v1.2.3