diff options
author | Taylor R Campbell <campbell+ledger@mumble.net> | 2024-04-27 19:54:23 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2024-08-06 14:51:38 -1000 |
commit | d9967c2638052730c6eeb1624586d633d6482003 (patch) | |
tree | f6dd9d0a94cc633f4e1a4f0588c2cb613e0100e2 /src/amount.cc | |
parent | 762353945a744ae4b89970b9e08c2c22a52ddbff (diff) | |
download | fork-ledger-d9967c2638052730c6eeb1624586d633d6482003.tar.gz fork-ledger-d9967c2638052730c6eeb1624586d633d6482003.tar.bz2 fork-ledger-d9967c2638052730c6eeb1624586d633d6482003.zip |
Avoid ctype abuse.
fix https://github.com/ledger/ledger/issues/2338
fix https://github.com/ledger/ledger/issues/2340
Diffstat (limited to 'src/amount.cc')
-rw-r--r-- | src/amount.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/amount.cc b/src/amount.cc index da8cd6fc..22282150 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -1013,7 +1013,8 @@ namespace { std::isdigit(c) || c == '.' || c == ','); string::size_type len = std::strlen(buf); - while (len > 0 && ! std::isdigit(buf[len - 1])) { + while (len > 0 && + ! std::isdigit(static_cast<unsigned char>(buf[len - 1]))) { buf[--len] = '\0'; in.unget(); } @@ -1048,7 +1049,7 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags) parse_quantity(in, quant); if (! in.eof() && ((n = static_cast<char>(in.peek())) != '\n')) { - if (std::isspace(n)) + if (std::isspace(static_cast<unsigned char>(n))) comm_flags |= COMMODITY_STYLE_SEPARATED; commodity_t::parse_symbol(in, symbol); @@ -1064,7 +1065,7 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags) commodity_t::parse_symbol(in, symbol); if (! in.eof() && ((n = static_cast<char>(in.peek())) != '\n')) { - if (std::isspace(static_cast<char>(in.peek()))) + if (std::isspace(in.peek())) comm_flags |= COMMODITY_STYLE_SEPARATED; parse_quantity(in, quant); |