diff options
author | John Wiegley <johnw@newartisans.com> | 2006-02-24 10:14:45 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:41:25 -0400 |
commit | c38119eaa063ac0e0066dd6abec8850e878ec6d3 (patch) | |
tree | 177ee8d156646b2248fca4dbf7cdfa2222655a97 /textual.cc | |
parent | 8043c794133a8de6888371f8942185e5baace0a3 (diff) | |
download | fork-ledger-c38119eaa063ac0e0066dd6abec8850e878ec6d3.tar.gz fork-ledger-c38119eaa063ac0e0066dd6abec8850e878ec6d3.tar.bz2 fork-ledger-c38119eaa063ac0e0066dd6abec8850e878ec6d3.zip |
(parse_transaction): Improved the @ check (scanning for a transaction
cost) so that it skips quoted symbol names and value expressions.
Diffstat (limited to 'textual.cc')
-rw-r--r-- | textual.cc | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -232,7 +232,24 @@ transaction_t * parse_transaction(char * line, account_t * account) } if (amount) { - price = std::strchr(amount, '@'); + bool in_quote = false; + int paren_depth = 0; + for (char * q = amount; *q; q++) { + if (*q == '"') { + in_quote = ! in_quote; + } + else if (! in_quote) { + if (*q == '(') + paren_depth++; + else if (*q == ')') + paren_depth--; + else if (paren_depth == 0 && *q == '@') { + price = q; + break; + } + } + } + if (price) { if (price == amount) throw parse_error(path, linenum, "Cost specified without amount"); |