Browse Source

fix linux crashes

master
Odilitime 5 years ago
parent
commit
4b801e0c11
  1. 11
      src/CFGFileParser.cpp

11
src/CFGFileParser.cpp

@ -43,14 +43,14 @@ bool CFGFileParser::ParseText() { @@ -43,14 +43,14 @@ bool CFGFileParser::ParseText() {
// Initial buffer for pass 1. tmp holds the config file (fmr. buffer)
// token holds the actual token. pass1_length to keep track of memory,
// reallocate as needed.
char *tmp, *token;
char *tmp, *token;
size_t pass1_length = 0;
struct slre regex; // final validation before adding to second-pass buffer
// Second pass. All comments and .tags stripped out. Starts off at 512 bytes, increases if necessary.
char* directives = static_cast<char*>(tlsf_malloc(512));
char* tmp2;
token = strtok_r(buffer, "\n", &tmp);
while (tmp != nullptr) {
while (token != nullptr) {
if (token[0] == '#' || token[0] == '.' || token[0] == '\n'){ // Comment, Perl directive, or single <LF> found, skip over
token = strtok_r(nullptr, "\n", &tmp);
}
@ -80,14 +80,15 @@ bool CFGFileParser::ParseText() { @@ -80,14 +80,15 @@ bool CFGFileParser::ParseText() {
}
}
// First pass complete, second pass: break up into single directives and <key, value> pairs
token = strtok_r(directives, "\t", &tmp);
char *newScope;
token = strtok_r(directives, "\t", &newScope);
ntr::fast_string key, value;
while (tmp != nullptr){
while (token != nullptr){
key=strtok_r(token, ":", &tmp2);
value=strtok_r(nullptr, "[]", &tmp2);
// strip ending bracket
cfg->Settings.insert({key,value});
token = strtok_r(nullptr, "\t", &tmp);
token = strtok_r(nullptr, "\t", &newScope);
}
#ifdef DEBUG
std::cout << "Settings stringmap contains, in no particular order:\n";

Loading…
Cancel
Save