(parse): Allow "-$100.00" as the equivalent of "$-100.00".
This commit is contained in:
parent
a2015ee510
commit
a10f3f02e7
1 changed files with 12 additions and 2 deletions
14
amount.cc
14
amount.cc
|
|
@ -858,10 +858,17 @@ void amount_t::parse(std::istream& in, unsigned short flags)
|
||||||
|
|
||||||
std::string symbol;
|
std::string symbol;
|
||||||
std::string quant;
|
std::string quant;
|
||||||
unsigned int comm_flags = COMMODITY_STYLE_DEFAULTS;;
|
unsigned int comm_flags = COMMODITY_STYLE_DEFAULTS;
|
||||||
|
bool negative = false;
|
||||||
|
|
||||||
char c = peek_next_nonws(in);
|
char c = peek_next_nonws(in);
|
||||||
if (std::isdigit(c) || c == '.' || c == '-') {
|
if (c == '-') {
|
||||||
|
negative = true;
|
||||||
|
in.get(c);
|
||||||
|
c = peek_next_nonws(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::isdigit(c) || c == '.') {
|
||||||
parse_quantity(in, quant);
|
parse_quantity(in, quant);
|
||||||
|
|
||||||
char n;
|
char n;
|
||||||
|
|
@ -955,6 +962,9 @@ void amount_t::parse(std::istream& in, unsigned short flags)
|
||||||
mpz_set_str(MPZ(quantity), quant.c_str(), 10);
|
mpz_set_str(MPZ(quantity), quant.c_str(), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (negative)
|
||||||
|
negate();
|
||||||
|
|
||||||
if (! (flags & AMOUNT_PARSE_NO_REDUCE))
|
if (! (flags & AMOUNT_PARSE_NO_REDUCE))
|
||||||
reduce();
|
reduce();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue