summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cc16
-rw-r--r--src/report.h10
-rw-r--r--src/scope.h2
-rw-r--r--src/value.h25
4 files changed, 26 insertions, 27 deletions
diff --git a/src/main.cc b/src/main.cc
index 0b89c9f1..b756b6e5 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -164,20 +164,16 @@ namespace ledger {
value_t operator()(call_scope_t& args)
{
- report_t& report(find_scope<report_t>(args));
- var_t<string> format(args, format_name);
+ report_t& report(find_scope<report_t>(args));
+ var_t<string> format(args, format_name);
if (! report.format_string.empty())
*format = report.format_string;
- if (args.value().is_sequence() &&
- args.value().size() > 1) {
- if (! report.predicate.empty())
- report.predicate = string("(") + report.predicate + ")&";
- report.predicate +=
- args_to_predicate(++args.value().as_sequence().begin(),
- args.value().as_sequence().end());
- }
+ if (args.value().size() > 0)
+ report.append_predicate
+ (args_to_predicate(args.value().as_sequence().begin(),
+ args.value().as_sequence().end()));
(report.*report_method)(handler_ptr(new Formatter(report, *format)));
diff --git a/src/report.h b/src/report.h
index 98b60ce1..6142a289 100644
--- a/src/report.h
+++ b/src/report.h
@@ -619,10 +619,14 @@ public:
}
#endif
- value_t option_limit_(call_scope_t& args) { // l:
+ void append_predicate(const string& str) {
if (! predicate.empty())
- predicate += "&";
- predicate += args[0].as_string();
+ predicate = string("(") + predicate + ")&";
+ predicate += str;
+ }
+
+ value_t option_limit_(call_scope_t& args) { // l:
+ append_predicate(args[0].as_string());
return true;
}
diff --git a/src/scope.h b/src/scope.h
index 88b45d84..8c98bb3d 100644
--- a/src/scope.h
+++ b/src/scope.h
@@ -157,9 +157,11 @@ public:
}
void set_args(const value_t& _args) {
+ assert(_args.is_sequence());
args = _args;
}
value_t& value() {
+ assert(args.is_null() || args.is_sequence());
return args;
}
diff --git a/src/value.h b/src/value.h
index 8d638657..9c6b5112 100644
--- a/src/value.h
+++ b/src/value.h
@@ -803,20 +803,17 @@ public:
void push_back(const value_t& val) {
if (! val.is_null()) {
- if (is_null()) {
- *this = val;
+ if (is_null())
+ *this = sequence_t();
+ if (! is_sequence())
+ in_place_cast(SEQUENCE);
+
+ if (! val.is_sequence()) {
+ as_sequence_lval().push_back(val);
} else {
- if (! is_sequence())
- in_place_cast(SEQUENCE);
-
- if (! val.is_sequence()) {
- if (! val.is_null())
- as_sequence_lval().push_back(val);
- } else {
- const value_t::sequence_t& val_seq(val.as_sequence());
- std::copy(val_seq.begin(), val_seq.end(),
- back_inserter(as_sequence_lval()));
- }
+ const sequence_t& val_seq(val.as_sequence());
+ std::copy(val_seq.begin(), val_seq.end(),
+ back_inserter(as_sequence_lval()));
}
}
}
@@ -829,7 +826,7 @@ public:
} else {
as_sequence_lval().pop_back();
- const value_t::sequence_t& seq(as_sequence());
+ const sequence_t& seq(as_sequence());
std::size_t new_size = seq.size();
if (new_size == 0)
_reset();