From 7bf86bc48a564ffffa46461c15ae2ab34b258fe8 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 30 Sep 2003 00:09:43 +0000 Subject: *** empty log message *** --- parse.cc | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'parse.cc') diff --git a/parse.cc b/parse.cc index 3f18b8f6..5e134dc2 100644 --- a/parse.cc +++ b/parse.cc @@ -1,14 +1,11 @@ -#include -#include #include #include #include -#include - -#include // Perl regular expression library #include "ledger.h" +#include // Perl regular expression library + namespace ledger { ////////////////////////////////////////////////////////////////////// @@ -37,8 +34,7 @@ char * next_element(char * buf, bool variable = false) static int linenum = 0; -void finalize_entry(entry * curr, std::vector& ledger) -{ +inline void finalize_entry(entry * curr) { if (curr) { if (! curr->validate()) { std::cerr << "Failed to balance the following transaction, " @@ -50,7 +46,7 @@ void finalize_entry(entry * curr, std::vector& ledger) } } -bool parse_ledger(std::istream& in, std::vector& ledger) +bool parse_ledger(std::istream& in) { static std::time_t now = std::time(NULL); static struct std::tm * now_tm = std::localtime(&now); @@ -94,7 +90,7 @@ bool parse_ledger(std::istream& in, std::vector& ledger) } if (curr) - finalize_entry(curr, ledger); + finalize_entry(curr); curr = new entry; // Parse the date @@ -165,11 +161,6 @@ bool parse_ledger(std::istream& in, std::vector& ledger) current = (*i).second; } } - - // Apply transaction to account (and all parent accounts) - - assert(current); - current->credit(curr, xact->cost); } xact->acct = current; @@ -181,7 +172,7 @@ bool parse_ledger(std::istream& in, std::vector& ledger) } if (curr) - finalize_entry(curr, ledger); + finalize_entry(curr); return true; } -- cgit v1.2.3