From 2a41efa0d43b573e1c8851086268b8a64d51c511 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 31 May 2008 11:43:46 +0000 Subject: fixes zlib compression, infi file parser updates --- src/filesystem/inifile.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/filesystem') diff --git a/src/filesystem/inifile.cc b/src/filesystem/inifile.cc index 337cf45..0cc690f 100644 --- a/src/filesystem/inifile.cc +++ b/src/filesystem/inifile.cc @@ -4,6 +4,7 @@ the terms of the GNU General Public License version 2 */ +#include "auxiliary/functions.h" #include "math/mathlib.h" #include "filesystem/filesystem.h" #include "filesystem/inifile.h" @@ -83,21 +84,27 @@ bool IniFile::getline() { if (s.size() > 2 && s[0] == '[' && s[s.size()-1] == ']') { // condebug << "Inifile got section header " << s << std::endl; section_current = s.substr(1, s.size()-2); + + aux::trim(section_current); + aux::to_lowercase(section_current); + last_read_was_section = true; return true; } else { // key=value pair size_t found = s.find('='); - if (found != std::string::npos) { - // make lowercase + if (found != std::string::npos && found > 0) { + // make lowercase and strip spaces key_current = s.substr(0, found); - while (key_current.size() && key_current[key_current.size()-1] == ' ') - key_current.erase(key_current.size()-1, 1); + aux::trim(key_current); + aux::to_lowercase(key_current); if (key_current.size()) { value_current = s.substr(found+1, s.size() - found - 1); - last_read_was_key = true; + aux::trim (value_current); + last_read_was_key = true; + //con_debug << "IniFile got " << key_current << "=" << value_current << std::endl; return true; } -- cgit v1.2.3