diff options
author | John Wiegley <johnw@newartisans.com> | 2005-06-20 00:31:48 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:41:11 -0400 |
commit | fdf73faff715eb031dbbffcc4ac936d3e3471396 (patch) | |
tree | 4dbff15a23127edf301df782a7daf8016f360446 | |
parent | 6d14952e1ea85ea316f00cb84eaa377beef33014 (diff) | |
download | fork-ledger-fdf73faff715eb031dbbffcc4ac936d3e3471396.tar.gz fork-ledger-fdf73faff715eb031dbbffcc4ac936d3e3471396.tar.bz2 fork-ledger-fdf73faff715eb031dbbffcc4ac936d3e3471396.zip |
(parse): Accept CX as well as C*. Also, general improvements to Bank
type parser.
-rw-r--r-- | qif.cc | 67 |
1 files changed, 35 insertions, 32 deletions
@@ -113,7 +113,8 @@ unsigned int qif_parser_t::parse(std::istream& in, } case 'C': - if (in.peek() == '*') { + c = in.peek(); + if (c == '*' || c == 'X') { in.get(c); entry->state = entry_t::CLEARED; } @@ -131,34 +132,30 @@ unsigned int qif_parser_t::parse(std::istream& in, case 'L': case 'S': case 'E': { - char b = c; - int len; - c = in.peek(); - if (! std::isspace(c) && c != '\n') { - get_line(in); + get_line(in); - switch (b) { - case 'P': - entry->payee = line; - break; - - case 'S': - xact = new transaction_t(NULL); - entry->add_transaction(xact); - // fall through... - case 'L': - len = std::strlen(line); - if (line[len - 1] == ']') - line[len - 1] = '\0'; - xact->account = journal->find_account(line[0] == '[' ? - line + 1 : line); - break; - - case 'M': - case 'E': - xact->note = line; - break; - } + switch (c) { + case 'P': + entry->payee = line; + break; + + case 'S': + xact = new transaction_t(NULL); + entry->add_transaction(xact); + // fall through... + case 'L': { + int len = std::strlen(line); + if (line[len - 1] == ']') + line[len - 1] = '\0'; + xact->account = journal->find_account(line[0] == '[' ? + line + 1 : line); + break; + } + + case 'M': + case 'E': + xact->note = line; + break; } break; } @@ -168,15 +165,20 @@ unsigned int qif_parser_t::parse(std::istream& in, get_line(in); break; - case '^': + case '^': { + account_t * other; if (xact->account == master) { if (! misc) misc = journal->find_account("Miscellaneous"); - transaction_t * nxact = new transaction_t(misc); - entry->add_transaction(nxact); - nxact->amount.negate(); + other = misc; + } else { + other = master; } + transaction_t * nxact = new transaction_t(other); + entry->add_transaction(nxact); + nxact->amount.negate(); + if (journal->add_entry(entry.get())) { entry.release(); count++; @@ -187,6 +189,7 @@ unsigned int qif_parser_t::parse(std::istream& in, entry->add_transaction(xact); break; } + } } return count; |