config: trim only surrounding whitespace

pull/58/head
jackun 4 years ago
parent 58c7831d5c
commit 417b1aac8d
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -5,35 +5,27 @@
#include "config.h"
#include "overlay_params.h"
#include "file_utils.h"
#include "string_utils.h"
std::unordered_map<std::string,std::string> options;
void parseConfigLine(std::string line){
if(line.find("#")!=std::string::npos)
{
line = line.erase(line.find("#"),std::string::npos);
}
size_t space = line.find(" ");
while(space!=std::string::npos)
{
line = line.erase(space,1);
space = line.find(" ");
}
space = line.find("\t");
while(space!=std::string::npos)
{
line = line.erase(space,1);
space = line.find("\t");
}
void parseConfigLine(std::string line) {
std::string param, value;
if (line.find("#") != std::string::npos)
line = line.erase(line.find("#"), std::string::npos);
size_t equal = line.find("=");
if(equal==std::string::npos)
{
if (!line.empty())
options[line] = "1";
return;
}
options[line.substr(0, equal)] = line.substr(equal+1);
if (equal == std::string::npos)
value = "1";
else
value = line.substr(equal+1);
param = line.substr(0, equal);
trim(param);
trim(value);
if (!param.empty())
options[param] = value;
}
void parseConfigFile() {

Loading…
Cancel
Save