Repaired the output of the "eval" command.
This commit is contained in:
parent
2d5ad7dee8
commit
d6d0b75bf0
1 changed files with 15 additions and 8 deletions
|
|
@ -71,19 +71,26 @@ value_t parse_command(call_scope_t& args)
|
||||||
|
|
||||||
value_t eval_command(call_scope_t& args)
|
value_t eval_command(call_scope_t& args)
|
||||||
{
|
{
|
||||||
var_t<string> arg(args, 0);
|
std::ostringstream buf;
|
||||||
|
bool first = true;
|
||||||
|
|
||||||
if (! arg) {
|
for (std::size_t i = 0; i < args.size(); i++) {
|
||||||
throw std::logic_error("Usage: eval TEXT");
|
if (first) {
|
||||||
return 1L;
|
buf << args[i];
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
buf << ' ' << args[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
report_t& report(find_scope<report_t>(args));
|
report_t& report(find_scope<report_t>(args));
|
||||||
std::ostream& out(report.output_stream);
|
|
||||||
|
|
||||||
expr_t expr(*arg);
|
expr_t expr(buf.str());
|
||||||
out << expr.calc(args).strip_annotations(report.what_to_keep())
|
value_t result(expr.calc(args).strip_annotations(report.what_to_keep()));
|
||||||
<< std::endl;
|
|
||||||
|
if (! result.is_null())
|
||||||
|
report.output_stream << result << std::endl;
|
||||||
|
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue