Commit 6e5ebc85 authored by Praetorius, Simon's avatar Praetorius, Simon

initfile now accepts includes with spaces in the filename

parent 087a863a
......@@ -16,8 +16,8 @@ namespace AMDiS {
{
size_t pos = line.find(':');
if (pos == string::npos) {
// throw runtime_error("cannot find the delimiter ':' in line "
// "'" + line + "'");
throw runtime_error("cannot find the delimiter ':' in line "
"'" + line + "'");
}
name = line.substr(0, pos);
value = line.substr(pos + 1, line.length() - (pos + 1));
......@@ -53,8 +53,8 @@ namespace AMDiS {
if (fn_include_list.find(fn) == fn_include_list.end() || force) {
std::ifstream inputFile;
inputFile.open(fn.c_str(), std::ios::in);
// if (!inputFile.is_open())
// throw runtime_error("init-file '" + fn + "' cannot be opened for reading");
if (!inputFile.is_open())
throw runtime_error("init-file '" + fn + "' cannot be opened for reading");
fn_include_list.insert(fn);
read(inputFile);
......@@ -70,6 +70,7 @@ namespace AMDiS {
in.getline(swap, line_length);
while (in.good() || in.gcount() > 0) {
std::string whitespaces = " \t\r\f\n";
std::string delimiter = "\r\n";
std::string sw(swap);
size_t pos0 = sw.find_first_not_of(whitespaces);
......@@ -109,18 +110,20 @@ namespace AMDiS {
case '<':
c= '>';
case '\"':
whitespaces += c;
epos = sw.find_first_of(whitespaces, pos);
delimiter += c;
epos = sw.find_first_of(delimiter, pos);
fn = sw.substr(pos, epos - pos);
if (sw[epos]!=c) {
errorMsg << "filename in #include not terminated by " << c;
// throw std::runtime_error(errorMsg.str());
throw std::runtime_error(errorMsg.str());
}
break;
// default:
// throw std::runtime_error("no filename given for #include");
default:
throw std::runtime_error("no filename given for #include");
}
read(fn, forceRead);
}
......
......@@ -415,11 +415,16 @@ namespace AMDiS {
}
std::string valStr;
try {
int error_code = singlett->checkedGet(tag, valStr);
if (error_code == 0) {
valStr = trim(valStr);
details::convert(valStr, value);
}
} catch(mu::ParserError& e) {
std::string parser_error = "Could not parse: " + tag;
throw std::runtime_error(parser_error);
}
/*
else if(error_code == TAG_NOT_FOUND_BREAK)
throw TagNotFoundBreak("required tag '" + tag + "' not found");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment