summaryrefslogtreecommitdiff
path: root/parse.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2003-09-30 23:17:18 +0000
committerJohn Wiegley <johnw@newartisans.com>2003-09-30 23:17:18 +0000
commitabe98b8f8932038f9dcd671014a5d51a8b0fa0b8 (patch)
tree2cc61a019fa066d4eeda4a8116c5b146ed2fc9c2 /parse.cc
parent487ea6a2171ec70b8ee0ff147a44abb6d89679dc (diff)
downloadfork-ledger-abe98b8f8932038f9dcd671014a5d51a8b0fa0b8.tar.gz
fork-ledger-abe98b8f8932038f9dcd671014a5d51a8b0fa0b8.tar.bz2
fork-ledger-abe98b8f8932038f9dcd671014a5d51a8b0fa0b8.zip
*** empty log message ***
Diffstat (limited to 'parse.cc')
-rw-r--r--parse.cc41
1 files changed, 4 insertions, 37 deletions
diff --git a/parse.cc b/parse.cc
index 3a6430bb..07d7f6ce 100644
--- a/parse.cc
+++ b/parse.cc
@@ -40,44 +40,11 @@ static inline void finalize_entry(entry * curr)
<< "ending on line " << (linenum - 1) << std::endl;
curr->print(std::cerr);
} else {
- ledger.push_back(curr);
+ main_ledger.entries.push_back(curr);
}
}
}
-static account * find_account(const char * name)
-{
- char * buf = new char[std::strlen(name) + 1];
- std::strcpy(buf, name);
-
- account * current = NULL;
- for (char * tok = std::strtok(buf, ":");
- tok;
- tok = std::strtok(NULL, ":")) {
- if (! current) {
- accounts_iterator i = accounts.find(tok);
- if (i == accounts.end()) {
- current = new account(tok);
- accounts.insert(accounts_entry(tok, current));
- } else {
- current = (*i).second;
- }
- } else {
- account::iterator i = current->children.find(tok);
- if (i == current->children.end()) {
- current = new account(tok, current);
- current->parent->children.insert(accounts_entry(tok, current));
- } else {
- current = (*i).second;
- }
- }
- }
-
- delete[] buf;
-
- return current;
-}
-
//////////////////////////////////////////////////////////////////////
//
// Ledger parser
@@ -230,7 +197,7 @@ bool parse_ledger(std::istream& in)
}
#endif
- xact->acct = find_account(p);
+ xact->acct = main_ledger.find_account(p);
xact->acct->balance.credit(xact->cost);
curr->xacts.push_back(xact);
@@ -241,14 +208,14 @@ bool parse_ledger(std::istream& in)
amount * temp;
transaction * t = new transaction();
- t->acct = find_account("Huququ'llah");
+ t->acct = main_ledger.find_account("Huququ'llah");
temp = xact->cost->value();
t->cost = temp->value(huquq);
delete temp;
curr->xacts.push_back(t);
t = new transaction();
- t->acct = find_account("Expenses:Huququ'llah");
+ t->acct = main_ledger.find_account("Expenses:Huququ'llah");
temp = xact->cost->value();
t->cost = temp->value(huquq);
delete temp;