diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-22 18:34:18 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-22 18:34:18 -0400 |
commit | 6365b8b7a807351209330ba65b05e612c5901908 (patch) | |
tree | e60f618e847d12c55c129aa3b534b5d495b2d313 /format.cc | |
parent | 02168c782364a1a8641b4bed7ebf4a84cb6b3560 (diff) | |
download | fork-ledger-6365b8b7a807351209330ba65b05e612c5901908.tar.gz fork-ledger-6365b8b7a807351209330ba65b05e612c5901908.tar.bz2 fork-ledger-6365b8b7a807351209330ba65b05e612c5901908.zip |
simplified some code
Diffstat (limited to 'format.cc')
-rw-r--r-- | format.cc | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -33,14 +33,19 @@ std::string partial_account_name(const account_t * account) return name; } -std::string format_t::date_format = "%Y/%m/%d"; +std::string format_t::date_format = "%Y/%m/%d"; +value_expr_t * format_t::value_expr = NULL; +value_expr_t * format_t::total_expr = NULL; #ifdef DO_CLEANUP -std::auto_ptr<value_expr_t> format_t::value_expr; -std::auto_ptr<value_expr_t> format_t::total_expr; -#else -value_expr_t * format_t::value_expr = NULL; -value_expr_t * format_t::total_expr = NULL; +static struct cleanup_t { + ~cleanup_t() { + if (format_t::value_expr) + delete format_t::value_expr; + if (format_t::total_expr) + delete format_t::total_expr; + } +} _cleanup; #endif element_t * format_t::parse_elements(const std::string& fmt) @@ -200,13 +205,8 @@ void format_t::format_elements(std::ostream& out, case element_t::VALUE_EXPR: { value_expr_t * expr = NULL; switch (elem->type) { -#ifdef DO_CLEANUP - case element_t::VALUE: expr = value_expr.get(); break; - case element_t::TOTAL: expr = total_expr.get(); break; -#else case element_t::VALUE: expr = value_expr; break; case element_t::TOTAL: expr = total_expr; break; -#endif case element_t::VALUE_EXPR: expr = elem->val_expr; break; default: |