summaryrefslogtreecommitdiff
path: root/src/annotate.cc
diff options
context:
space:
mode:
authorkanreki <32443233+kanreki@users.noreply.github.com>2021-09-14 12:15:53 -0700
committerJohn Wiegley <johnw@newartisans.com>2021-12-08 16:17:17 -0800
commit586abd208221761a6c93bc4568513e9cd4dc287d (patch)
treed3d6c8da7e4584665bb705c25a91c5c66083de65 /src/annotate.cc
parented5886921bcce0d1a261a37aa83bf135259b7d21 (diff)
downloadfork-ledger-586abd208221761a6c93bc4568513e9cd4dc287d.tar.gz
fork-ledger-586abd208221761a6c93bc4568513e9cd4dc287d.tar.bz2
fork-ledger-586abd208221761a6c93bc4568513e9cd4dc287d.zip
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.
Diffstat (limited to 'src/annotate.cc')
-rw-r--r--src/annotate.cc34
1 files changed, 17 insertions, 17 deletions
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<char>(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<char>(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<char>(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<char>(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"));