summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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");