diff options
author | Donald Lam <brainy.runt@gmail.com> | 2021-04-11 11:06:44 -0700 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2021-05-02 11:35:33 -0700 |
commit | 4ba80c37c068dd1839101c6c1f8ceed49f696d5f (patch) | |
tree | 2de0e7cb110ba95986f069b5424289a4a82651ee /src/amount.cc | |
parent | 763a958094c6333bdd247e828300a3cff3c5d4de (diff) | |
download | fork-ledger-4ba80c37c068dd1839101c6c1f8ceed49f696d5f.tar.gz fork-ledger-4ba80c37c068dd1839101c6c1f8ceed49f696d5f.tar.bz2 fork-ledger-4ba80c37c068dd1839101c6c1f8ceed49f696d5f.zip |
Fix amount tokenizer re: embedded minus sign.
An amount may have a (single) leading minus sign, but none after that.
Bug #2001 (and #1809).
Diffstat (limited to 'src/amount.cc')
-rw-r--r-- | src/amount.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/amount.cc b/src/amount.cc index 788a140c..6baa903c 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -975,8 +975,15 @@ namespace { { char buf[256]; char c = peek_next_nonws(in); - READ_INTO(in, buf, 255, c, - std::isdigit(c) || c == '-' || c == '.' || c == ','); + int max = 255; + char *p = buf; + if (c == '-') { + *p++ = c; + max--; + in.get(c); + } + READ_INTO(in, p, max, c, + std::isdigit(c) || c == '.' || c == ','); string::size_type len = std::strlen(buf); while (len > 0 && ! std::isdigit(buf[len - 1])) { |