From 586abd208221761a6c93bc4568513e9cd4dc287d Mon Sep 17 00:00:00 2001 From: kanreki <32443233+kanreki@users.noreply.github.com> Date: Tue, 14 Sep 2021 12:15:53 -0700 Subject: Use correct int return type for stream input operations This makes it safe to compare results to -1 to indicate EOF, regardless of whether char is considered signed or unsigned; and so eliminates compiler warnings on platforms such as ARM. Fixes bug #2058. --- src/annotate.cc | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/annotate.cc') diff --git a/src/annotate.cc b/src/annotate.cc index 27261f57..e0fb0d08 100644 --- a/src/annotate.cc +++ b/src/annotate.cc @@ -86,33 +86,33 @@ void annotation_t::parse(std::istream& in) return; char buf[256]; - char c = peek_next_nonws(in); + int c = peek_next_nonws(in); if (c == '{') { if (price) throw_(amount_error, _("Commodity specifies more than one price")); - in.get(c); - c = static_cast(in.peek()); + in.get(); + c = in.peek(); if (c == '{') { - in.get(c); + in.get(); add_flags(ANNOTATION_PRICE_NOT_PER_UNIT); } c = peek_next_nonws(in); if (c == '=') { - in.get(c); + in.get(); add_flags(ANNOTATION_PRICE_FIXATED); } READ_INTO(in, buf, 255, c, c != '}'); if (c == '}') { - in.get(c); + in.get(); if (has_flags(ANNOTATION_PRICE_NOT_PER_UNIT)) { - c = static_cast(in.peek()); + c = in.peek(); if (c != '}') throw_(amount_error, _("Commodity lot price lacks double closing brace")); else - in.get(c); + in.get(); } } else { throw_(amount_error, _("Commodity lot price lacks closing brace")); @@ -128,18 +128,18 @@ void annotation_t::parse(std::istream& in) if (date) throw_(amount_error, _("Commodity specifies more than one date")); - in.get(c); + in.get(); READ_INTO(in, buf, 255, c, c != ']'); if (c == ']') - in.get(c); + in.get(); else throw_(amount_error, _("Commodity date lacks closing bracket")); date = parse_date(buf); } else if (c == '(') { - in.get(c); - c = static_cast(in.peek()); + in.get(); + c = in.peek(); if (c == '@') { in.clear(); in.seekg(pos, std::ios::beg); @@ -150,13 +150,13 @@ void annotation_t::parse(std::istream& in) throw_(amount_error, _("Commodity specifies more than one valuation expresion")); - in.get(c); + in.get(); READ_INTO(in, buf, 255, c, c != ')'); if (c == ')') { - in.get(c); - c = static_cast(in.peek()); + in.get(); + c = in.peek(); if (c == ')') - in.get(c); + in.get(); else throw_(amount_error, _("Commodity valuation expression lacks closing parentheses")); @@ -172,7 +172,7 @@ void annotation_t::parse(std::istream& in) READ_INTO(in, buf, 255, c, c != ')'); if (c == ')') - in.get(c); + in.get(); else throw_(amount_error, _("Commodity tag lacks closing parenthesis")); -- cgit v1.2.3