Config debugged

This commit is contained in:
Thomas 2022-01-10 14:36:38 +01:00
parent 5b7a673b6f
commit 53f0785fee
No known key found for this signature in database
GPG Key ID: E538821A6CDFDAD7
2 changed files with 6 additions and 4 deletions

View File

@ -9,8 +9,8 @@
# maxFPS: 30
#
general:
maxFPS: 30
theme: bad
maxFPS: 30
theme: bad
#############################
# #

View File

@ -45,12 +45,14 @@ void ConfigBuilder::parseFile(const string& fname) {
vector<string> keyParts;
unsigned listIndex;
unsigned lineno = 0; // for error handling purposes
while (!file.eof()) {
string line;
getline(file, line);
++lineno;
auto match = line.find('#');
if (match != string::npos)line.erase(match);
if (line.empty())continue;
if (line.find_first_not_of(' ')==string::npos)continue;
unsigned currentIndent = 0;
while (line[currentIndent] == ' ')++currentIndent;
@ -71,7 +73,7 @@ void ConfigBuilder::parseFile(const string& fname) {
}else{
match = line.find(':');
if (match == string::npos)throw config_error("Line "+ to_string(currentIndent)+" invalid : |"+line+"|");
if (match == string::npos)throw config_error("Line "+ to_string(lineno)+" invalid : |"+line+"|");
string key = line.substr(0, match);
string value = line.substr(match + 1);
trimSpaces(key);