diff options
author | John Wiegley <johnw@newartisans.com> | 2003-09-30 00:09:43 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2003-09-30 00:09:43 +0000 |
commit | 7bf86bc48a564ffffa46461c15ae2ab34b258fe8 (patch) | |
tree | a33b8365b8dc834413997170e2200f818f5fb894 /parse.cc | |
parent | 3667f06594a99dd6f0080747732e7eff639343b1 (diff) | |
download | fork-ledger-7bf86bc48a564ffffa46461c15ae2ab34b258fe8.tar.gz fork-ledger-7bf86bc48a564ffffa46461c15ae2ab34b258fe8.tar.bz2 fork-ledger-7bf86bc48a564ffffa46461c15ae2ab34b258fe8.zip |
*** empty log message ***
Diffstat (limited to 'parse.cc')
-rw-r--r-- | parse.cc | 21 |
1 files changed, 6 insertions, 15 deletions
@@ -1,14 +1,11 @@ -#include <iostream> -#include <vector> #include <cstring> #include <ctime> #include <cctype> -#include <cassert> - -#include <pcre.h> // Perl regular expression library #include "ledger.h" +#include <pcre.h> // 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<entry *>& 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<entry *>& ledger) } } -bool parse_ledger(std::istream& in, std::vector<entry *>& 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<entry *>& 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<entry *>& 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<entry *>& ledger) } if (curr) - finalize_entry(curr, ledger); + finalize_entry(curr); return true; } |