summaryrefslogtreecommitdiff
path: root/hscript/script.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-06 18:30:37 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-06 18:30:37 -0500
commitd31982310965cb23c8abb51320742420a3d168b5 (patch)
treeed6e9c10c094737be3d38be89a9e2b24625f1e81 /hscript/script.cc
parenta8f34e5d4bf1dcd56a10790b12d23b8a7ab32b2e (diff)
downloadhorizon-d31982310965cb23c8abb51320742420a3d168b5.tar.gz
horizon-d31982310965cb23c8abb51320742420a3d168b5.tar.bz2
horizon-d31982310965cb23c8abb51320742420a3d168b5.tar.xz
horizon-d31982310965cb23c8abb51320742420a3d168b5.zip
hscript: Honour KeepGoing flag
Diffstat (limited to 'hscript/script.cc')
-rw-r--r--hscript/script.cc12
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;
}