summaryrefslogtreecommitdiff
path: root/textual.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2006-02-24 10:14:45 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:25 -0400
commitc38119eaa063ac0e0066dd6abec8850e878ec6d3 (patch)
tree177ee8d156646b2248fca4dbf7cdfa2222655a97 /textual.cc
parent8043c794133a8de6888371f8942185e5baace0a3 (diff)
downloadfork-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.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/textual.cc b/textual.cc
index c8e5e0db..c559b694 100644
--- a/textual.cc
+++ b/textual.cc
@@ -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");