From d31982310965cb23c8abb51320742420a3d168b5 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sun, 6 Oct 2019 18:30:37 -0500 Subject: hscript: Honour KeepGoing flag --- hscript/script.cc | 12 +++++++++++- hscript/script.hh | 2 +- 2 files changed, 12 insertions(+), 2 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; } diff --git a/hscript/script.hh b/hscript/script.hh index 8c0f619..5b8af95 100644 --- a/hscript/script.hh +++ b/hscript/script.hh @@ -61,7 +61,7 @@ public: static const Script *load(std::istream &stream, ScriptOptions options = 0); /*! Determines if the HorizonScript is valid. */ - bool validate(); + bool validate() const; private: struct ScriptPrivate; -- cgit v1.2.3-60-g2f50