(parse_transaction): Improved the @ check (scanning for a transaction
cost) so that it skips quoted symbol names and value expressions.
This commit is contained in:
parent
f86e81732c
commit
7cf2a41755
1 changed files with 18 additions and 1 deletions
19
textual.cc
19
textual.cc
|
|
@ -232,7 +232,24 @@ transaction_t * parse_transaction(char * line, account_t * account)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount) {
|
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) {
|
||||||
if (price == amount)
|
if (price == amount)
|
||||||
throw parse_error(path, linenum, "Cost specified without amount");
|
throw parse_error(path, linenum, "Cost specified without amount");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue