summaryrefslogtreecommitdiff
path: root/main.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-07-19 21:36:34 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-07-19 21:36:34 -0400
commitd568319495a0695582797de0be4b85e1e06e73b2 (patch)
treecda7e94b2da52b32006c6a83b335d72ff2ccc165 /main.cc
parent150abce0dbd11863e4a8309fd306a4c2667501f8 (diff)
parent2aeee0bb64b56959ebcf86165c0b31630e0f92ac (diff)
downloadfork-ledger-d568319495a0695582797de0be4b85e1e06e73b2.tar.gz
fork-ledger-d568319495a0695582797de0be4b85e1e06e73b2.tar.bz2
fork-ledger-d568319495a0695582797de0be4b85e1e06e73b2.zip
Merged in bug fixes from master (done for 2.6.1b)
Diffstat (limited to 'main.cc')
-rw-r--r--main.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/main.cc b/main.cc
index 19e3b868..3c378861 100644
--- a/main.cc
+++ b/main.cc
@@ -22,8 +22,8 @@
using namespace ledger;
-int parse_and_report(config_t& config, report_t& report,
- int argc, char * argv[], char * envp[])
+int parse_and_report(config_t& config, std::auto_ptr<journal_t>& journal,
+ report_t& report, int argc, char * argv[], char * envp[])
{
// Configure the terminus for value expressions
@@ -148,7 +148,7 @@ int parse_and_report(config_t& config, report_t& report,
// Parse initialization files, ledger data, price database, etc.
- std::auto_ptr<journal_t> journal(new journal_t);
+ journal.reset(new journal_t);
#if 0
{ TRACE_PUSH(parser, "Parsing journal file");
@@ -481,6 +481,12 @@ appending the output of this command to your Ledger file if you so choose."
int main(int argc, char * argv[], char * envp[])
{
+ // This variable must be defined here so that any memory it holds is still
+ // available should the subsequent exception handlers catch an inner
+ // exception and need to report something on the invalid state of the
+ // journal (such as an unbalanced entry).
+ std::auto_ptr<journal_t> journal;
+
try {
#if DEBUG_LEVEL < BETA
ledger::do_cleanup = false;
@@ -492,7 +498,7 @@ int main(int argc, char * argv[], char * envp[])
#if 0
TRACE_PUSH(main, "Ledger starting");
#endif
- int status = parse_and_report(config, report, argc, argv, envp);
+ int status = parse_and_report(config, journal, report, argc, argv, envp);
#if 0
TRACE_POP(main, "Ledger done");
#endif