Skip to content

Commit

Permalink
Allow multi-line config file options
Browse files Browse the repository at this point in the history
This commit represents another difference found in the final release
of iwamatsu's slim-1.3.6 that I cannot trace the origins of.  This
code extends Cfg::readConf() to allow for the proper parsing of
multi-line configuration options when lines termiate with '\'.
  • Loading branch information
axs-gentoo committed Feb 24, 2017
1 parent 565f07d commit 4fc0fe7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,26 @@ Cfg::~Cfg() {
*/
bool Cfg::readConf(string configfile) {
int n = -1;
string line, fn(configfile);
size_t pos = 0;
string line, next, op, fn(configfile);
map<string,string>::iterator it;
string op;
ifstream cfgfile( fn.c_str() );
if (cfgfile) {
while (getline( cfgfile, line )) {
// Allow multi-line options when line terminated with '\'
if ((pos = line.find('\\')) != string::npos) {
if (line.length() == pos + 1) {
line.replace(pos,1," ");
next = next + line;
continue;
} else
line.replace(pos, line.length() - pos, " ");
}
if (!next.empty()) {
line = next + line;
next = "";
}

it = options.begin();
while (it != options.end()) {
op = it->first;
Expand Down

0 comments on commit 4fc0fe7

Please sign in to comment.