Regular expressions supplied after 'reg' or 'bal' are working again.

This commit is contained in:
John Wiegley 2008-08-10 02:54:36 -04:00
parent 7ffb6c472c
commit 548a03e725
4 changed files with 26 additions and 27 deletions

View file

@ -164,20 +164,16 @@ namespace ledger {
value_t operator()(call_scope_t& args) value_t operator()(call_scope_t& args)
{ {
report_t& report(find_scope<report_t>(args)); report_t& report(find_scope<report_t>(args));
var_t<string> format(args, format_name); var_t<string> format(args, format_name);
if (! report.format_string.empty()) if (! report.format_string.empty())
*format = report.format_string; *format = report.format_string;
if (args.value().is_sequence() && if (args.value().size() > 0)
args.value().size() > 1) { report.append_predicate
if (! report.predicate.empty()) (args_to_predicate(args.value().as_sequence().begin(),
report.predicate = string("(") + report.predicate + ")&"; args.value().as_sequence().end()));
report.predicate +=
args_to_predicate(++args.value().as_sequence().begin(),
args.value().as_sequence().end());
}
(report.*report_method)(handler_ptr(new Formatter(report, *format))); (report.*report_method)(handler_ptr(new Formatter(report, *format)));

View file

@ -619,10 +619,14 @@ public:
} }
#endif #endif
value_t option_limit_(call_scope_t& args) { // l: void append_predicate(const string& str) {
if (! predicate.empty()) if (! predicate.empty())
predicate += "&"; predicate = string("(") + predicate + ")&";
predicate += args[0].as_string(); predicate += str;
}
value_t option_limit_(call_scope_t& args) { // l:
append_predicate(args[0].as_string());
return true; return true;
} }

View file

@ -157,9 +157,11 @@ public:
} }
void set_args(const value_t& _args) { void set_args(const value_t& _args) {
assert(_args.is_sequence());
args = _args; args = _args;
} }
value_t& value() { value_t& value() {
assert(args.is_null() || args.is_sequence());
return args; return args;
} }

View file

@ -803,20 +803,17 @@ public:
void push_back(const value_t& val) { void push_back(const value_t& val) {
if (! val.is_null()) { if (! val.is_null()) {
if (is_null()) { if (is_null())
*this = val; *this = sequence_t();
} else { if (! is_sequence())
if (! is_sequence()) in_place_cast(SEQUENCE);
in_place_cast(SEQUENCE);
if (! val.is_sequence()) { if (! val.is_sequence()) {
if (! val.is_null()) as_sequence_lval().push_back(val);
as_sequence_lval().push_back(val); } else {
} else { const sequence_t& val_seq(val.as_sequence());
const value_t::sequence_t& val_seq(val.as_sequence()); std::copy(val_seq.begin(), val_seq.end(),
std::copy(val_seq.begin(), val_seq.end(), back_inserter(as_sequence_lval()));
back_inserter(as_sequence_lval()));
}
} }
} }
} }
@ -829,7 +826,7 @@ public:
} else { } else {
as_sequence_lval().pop_back(); 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(); std::size_t new_size = seq.size();
if (new_size == 0) if (new_size == 0)
_reset(); _reset();