diff options
Diffstat (limited to 'hscript/script.cc')
-rw-r--r-- | hscript/script.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/hscript/script.cc b/hscript/script.cc index a9c39ab..ffa7552 100644 --- a/hscript/script.cc +++ b/hscript/script.cc @@ -58,6 +58,7 @@ const Script *Script::load(std::istream &sstream, ScriptOptions opts) { int lineno = 0; char nextline[LINE_MAX]; const std::string delim(" \t"); + bool any_error = false; while(sstream.getline(nextline, sizeof(nextline))) { lineno++; @@ -77,12 +78,21 @@ const Script *Script::load(std::istream &sstream, ScriptOptions opts) { key_end = line.find_first_of(delim, start); if(key_end == std::string::npos) { /* Key without value */ + any_error = true; output_error("installfile:" + std::to_string(lineno), "key '" + line.substr(start) + "' has no value", "", (opts.test(Pretty))); + if(!opts.test(ScriptOptionFlags::KeepGoing)) { + break; + } } } + if(any_error) { + delete the_script; + return nullptr; + } + if(sstream.fail() && !sstream.eof()) { output_error("installfile:" + std::to_string(lineno + 1), "line exceeds maximum length", @@ -101,7 +111,7 @@ const Script *Script::load(std::istream &sstream, ScriptOptions opts) { return the_script; } -bool Script::validate() { +bool Script::validate() const { return false; } |