diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-10-22 22:19:28 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-10-22 22:19:28 +0200 |
commit | 63ce9414183fb094a4bc172750d46810c332e786 (patch) | |
tree | c76696c279a4cd9b363ef0b186abe91005fb667a /src/Common | |
parent | 1226366351300139f2d8b7c10fee29d744591426 (diff) | |
download | mad-63ce9414183fb094a4bc172750d46810c332e786.tar mad-63ce9414183fb094a4bc172750d46810c332e786.zip |
Korrekte Behandlung von mehrzeiligen Config-Eintr?gen
Diffstat (limited to 'src/Common')
-rw-r--r-- | src/Common/ConfigManager.cpp | 8 | ||||
-rw-r--r-- | src/Common/Tokenizer.cpp | 10 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/Common/ConfigManager.cpp b/src/Common/ConfigManager.cpp index 487e901..c119cf7 100644 --- a/src/Common/ConfigManager.cpp +++ b/src/Common/ConfigManager.cpp @@ -49,7 +49,7 @@ void ConfigManager::handleConfigEntry(const ConfigEntry &entry) { } if(!handled) - Logger::logf(Logger::WARNING, "Invalid config option '%s'.", entry[0].getKey().c_str()); + Logger::logf(Logger::WARNING, "Invalid config option '%s'.", entry[entry.getSize()-1].getKey().c_str()); } bool ConfigManager::loadFile(const std::string &filename, bool finish) { @@ -72,7 +72,7 @@ bool ConfigManager::loadFile(const std::string &filename, bool finish) { size_t pos = input.find_first_of("#{}"); if(pos == std::string::npos) { line += input; - delim = 0; + delim = '\n'; input.clear(); } else { @@ -82,9 +82,7 @@ bool ConfigManager::loadFile(const std::string &filename, bool finish) { } if(!Tokenizer::tokenize(line, splitLine)) { - if(delim) - line += delim; - + line += delim; continue; } diff --git a/src/Common/Tokenizer.cpp b/src/Common/Tokenizer.cpp index 1d7462f..8b01482 100644 --- a/src/Common/Tokenizer.cpp +++ b/src/Common/Tokenizer.cpp @@ -19,8 +19,6 @@ #include "Tokenizer.h" -#include <iostream> - namespace Mad { namespace Common { @@ -72,8 +70,16 @@ bool Tokenizer::tokenize(const std::string &str, std::vector<std::string> &out) break; for(std::string::iterator c = s->begin(); c != s->end(); ++c) { + if(*c == '\n' && escape) { + escape = false; + + if(doubleQuotes) + continue; + } + if(escape || (singleQuotes && *c != '\'')) { token += *c; + escape = false; continue; } |