summaryrefslogtreecommitdiff
path: root/format.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-08-02 16:23:58 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-08-02 16:32:16 -0400
commite52a6a9bd8e2bbf3a497696eed735eb00a8b9dde (patch)
tree2eb460e8512c91af08ff5884b680d1a49fe0c743 /format.cc
parent9a9e06554eb9f57be8c839fb0af49a0473614172 (diff)
downloadfork-ledger-e52a6a9bd8e2bbf3a497696eed735eb00a8b9dde.tar.gz
fork-ledger-e52a6a9bd8e2bbf3a497696eed735eb00a8b9dde.tar.bz2
fork-ledger-e52a6a9bd8e2bbf3a497696eed735eb00a8b9dde.zip
More infrastructure work toward getting journal objects to provide their own
information in an abstract manner.
Diffstat (limited to 'format.cc')
-rw-r--r--format.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/format.cc b/format.cc
index 1255d25b..772fa0bc 100644
--- a/format.cc
+++ b/format.cc
@@ -242,11 +242,24 @@ void format_t::format(std::ostream& out_str, scope_t& scope)
case element_t::EXPR:
try {
- if (elem->max_width == 0)
- elem->expr.calc(scope).dump(out, elem->min_width);
- else
- out << truncate(elem->expr.calc(scope).as_string(),
- elem->max_width);
+ elem->expr.compile(scope);
+
+ if (elem->expr.is_function()) {
+ call_scope_t args(scope);
+ args.push_back(long(elem->max_width));
+
+ if (elem->max_width == 0)
+ elem->expr.get_function()(args).dump(out, elem->min_width);
+ else
+ out << truncate(elem->expr.get_function()(args).as_string(),
+ elem->max_width);
+ } else {
+ if (elem->max_width == 0)
+ elem->expr.calc(scope).dump(out, elem->min_width);
+ else
+ out << truncate(elem->expr.calc(scope).as_string(),
+ elem->max_width);
+ }
}
catch (const calc_error&) {
out << (string("%") + elem->chars);