summaryrefslogtreecommitdiff
path: root/hscript/script.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-06 18:50:29 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-06 18:50:29 -0500
commitc05569d223d5bda4390f1c501dc5915149617c93 (patch)
tree5a96790a7b13f8b9460042fec4fca11b3aa9957d /hscript/script.cc
parentefc18bc3a4116c606e1c546877f2d5d9e6b9fbda (diff)
downloadhorizon-c05569d223d5bda4390f1c501dc5915149617c93.tar.gz
horizon-c05569d223d5bda4390f1c501dc5915149617c93.tar.bz2
horizon-c05569d223d5bda4390f1c501dc5915149617c93.tar.xz
horizon-c05569d223d5bda4390f1c501dc5915149617c93.zip
hscript: If no value present after delim, key has no value
Diffstat (limited to 'hscript/script.cc')
-rw-r--r--hscript/script.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/hscript/script.cc b/hscript/script.cc
index ffa7552..e7746bc 100644
--- a/hscript/script.cc
+++ b/hscript/script.cc
@@ -68,7 +68,7 @@ const Script *Script::load(std::istream &sstream, ScriptOptions opts) {
}
const std::string line(nextline);
- std::string::size_type start, key_end;
+ std::string::size_type start, key_end, value_begin;
start = line.find_first_not_of(delim);
if(start == std::string::npos) {
/* This is a blank line; ignore it. */
@@ -76,11 +76,13 @@ const Script *Script::load(std::istream &sstream, ScriptOptions opts) {
}
key_end = line.find_first_of(delim, start);
- if(key_end == std::string::npos) {
+ value_begin = line.find_first_not_of(delim, key_end);
+ if(key_end == std::string::npos || value_begin == std::string::npos) {
/* Key without value */
any_error = true;
output_error("installfile:" + std::to_string(lineno),
- "key '" + line.substr(start) + "' has no value",
+ "key '" + line.substr(start, key_end) +
+ "' has no value",
"", (opts.test(Pretty)));
if(!opts.test(ScriptOptionFlags::KeepGoing)) {
break;