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

initfile now accepts includes with spaces in the filename

parent 087a863a
...@@ -16,8 +16,8 @@ namespace AMDiS { ...@@ -16,8 +16,8 @@ namespace AMDiS {
{ {
size_t pos = line.find(':'); size_t pos = line.find(':');
if (pos == string::npos) { if (pos == string::npos) {
// throw runtime_error("cannot find the delimiter ':' in line " throw runtime_error("cannot find the delimiter ':' in line "
// "'" + line + "'"); "'" + line + "'");
} }
name = line.substr(0, pos); name = line.substr(0, pos);
value = line.substr(pos + 1, line.length() - (pos + 1)); value = line.substr(pos + 1, line.length() - (pos + 1));
...@@ -53,8 +53,8 @@ namespace AMDiS { ...@@ -53,8 +53,8 @@ namespace AMDiS {
if (fn_include_list.find(fn) == fn_include_list.end() || force) { if (fn_include_list.find(fn) == fn_include_list.end() || force) {
std::ifstream inputFile; std::ifstream inputFile;
inputFile.open(fn.c_str(), std::ios::in); inputFile.open(fn.c_str(), std::ios::in);
// if (!inputFile.is_open()) if (!inputFile.is_open())
// throw runtime_error("init-file '" + fn + "' cannot be opened for reading"); throw runtime_error("init-file '" + fn + "' cannot be opened for reading");
fn_include_list.insert(fn); fn_include_list.insert(fn);
read(inputFile); read(inputFile);
...@@ -70,6 +70,7 @@ namespace AMDiS { ...@@ -70,6 +70,7 @@ namespace AMDiS {
in.getline(swap, line_length); in.getline(swap, line_length);
while (in.good() || in.gcount() > 0) { while (in.good() || in.gcount() > 0) {
std::string whitespaces = " \t\r\f\n"; std::string whitespaces = " \t\r\f\n";
std::string delimiter = "\r\n";
std::string sw(swap); std::string sw(swap);
size_t pos0 = sw.find_first_not_of(whitespaces); size_t pos0 = sw.find_first_not_of(whitespaces);
...@@ -109,18 +110,20 @@ namespace AMDiS { ...@@ -109,18 +110,20 @@ namespace AMDiS {
case '<': case '<':
c= '>'; c= '>';
case '\"': case '\"':
whitespaces += c; delimiter += c;
epos = sw.find_first_of(whitespaces, pos); epos = sw.find_first_of(delimiter, pos);
fn = sw.substr(pos, epos - pos); fn = sw.substr(pos, epos - pos);
if (sw[epos]!=c) { if (sw[epos]!=c) {
errorMsg << "filename in #include not terminated by " << c; errorMsg << "filename in #include not terminated by " << c;
// throw std::runtime_error(errorMsg.str()); throw std::runtime_error(errorMsg.str());
} }
break; break;
// default: default:
// throw std::runtime_error("no filename given for #include"); throw std::runtime_error("no filename given for #include");
} }
read(fn, forceRead); read(fn, forceRead);
} }
......
...@@ -415,11 +415,16 @@ namespace AMDiS { ...@@ -415,11 +415,16 @@ namespace AMDiS {
} }
std::string valStr; std::string valStr;
try {
int error_code = singlett->checkedGet(tag, valStr); int error_code = singlett->checkedGet(tag, valStr);
if (error_code == 0) { if (error_code == 0) {
valStr = trim(valStr); valStr = trim(valStr);
details::convert(valStr, value); 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) else if(error_code == TAG_NOT_FOUND_BREAK)
throw TagNotFoundBreak("required tag '" + tag + "' not found"); throw TagNotFoundBreak("required tag '" + tag + "' not found");
......
Supports Markdown
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