diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-08 04:32:46 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-08 04:32:46 -0400 |
commit | d6d0b75bf0e80bd8402540bc98caec35d8bc0a53 (patch) | |
tree | 73044b269116e0c0eba5adfc8adcdafd05b04df3 /src/precmd.cc | |
parent | 2d5ad7dee89ebe9c014270882e44d3a7a8a626fd (diff) | |
download | fork-ledger-d6d0b75bf0e80bd8402540bc98caec35d8bc0a53.tar.gz fork-ledger-d6d0b75bf0e80bd8402540bc98caec35d8bc0a53.tar.bz2 fork-ledger-d6d0b75bf0e80bd8402540bc98caec35d8bc0a53.zip |
Repaired the output of the "eval" command.
Diffstat (limited to 'src/precmd.cc')
-rw-r--r-- | src/precmd.cc | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/precmd.cc b/src/precmd.cc index e8f48b6a..173ca517 100644 --- a/src/precmd.cc +++ b/src/precmd.cc @@ -71,19 +71,26 @@ value_t parse_command(call_scope_t& args) value_t eval_command(call_scope_t& args) { - var_t<string> arg(args, 0); - - if (! arg) { - throw std::logic_error("Usage: eval TEXT"); - return 1L; + std::ostringstream buf; + bool first = true; + + for (std::size_t i = 0; i < args.size(); i++) { + if (first) { + buf << args[i]; + first = false; + } else { + buf << ' ' << args[i]; + } } report_t& report(find_scope<report_t>(args)); - std::ostream& out(report.output_stream); - expr_t expr(*arg); - out << expr.calc(args).strip_annotations(report.what_to_keep()) - << std::endl; + expr_t expr(buf.str()); + value_t result(expr.calc(args).strip_annotations(report.what_to_keep())); + + if (! result.is_null()) + report.output_stream << result << std::endl; + return 0L; } |