When parsing commodities, if there is no symbol or annotations, reset the
stream pointer in order to give more accurate error reporting.
This commit is contained in:
parent
7b76ea5cbc
commit
d9e97cfede
1 changed files with 11 additions and 0 deletions
|
|
@ -508,6 +508,8 @@ void commodity_t::parse_symbol(std::istream& in, string& symbol)
|
||||||
/* f0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
/* f0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
istream_pos_type pos = in.tellg();
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
char c = peek_next_nonws(in);
|
char c = peek_next_nonws(in);
|
||||||
if (c == '"') {
|
if (c == '"') {
|
||||||
|
|
@ -521,6 +523,11 @@ void commodity_t::parse_symbol(std::istream& in, string& symbol)
|
||||||
READ_INTO(in, buf, 255, c, ! invalid_chars[static_cast<unsigned char>(c)]);
|
READ_INTO(in, buf, 255, c, ! invalid_chars[static_cast<unsigned char>(c)]);
|
||||||
}
|
}
|
||||||
symbol = buf;
|
symbol = buf;
|
||||||
|
|
||||||
|
if (symbol.length() == 0) {
|
||||||
|
in.clear();
|
||||||
|
in.seekg(pos, std::ios::beg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void commodity_t::parse_symbol(char *& p, string& symbol)
|
void commodity_t::parse_symbol(char *& p, string& symbol)
|
||||||
|
|
@ -567,6 +574,8 @@ bool commodity_t::valid() const
|
||||||
void annotation_t::parse(std::istream& in)
|
void annotation_t::parse(std::istream& in)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
|
istream_pos_type pos = in.tellg();
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
char c = peek_next_nonws(in);
|
char c = peek_next_nonws(in);
|
||||||
if (c == '{') {
|
if (c == '{') {
|
||||||
|
|
@ -621,6 +630,8 @@ void annotation_t::parse(std::istream& in)
|
||||||
tag = buf;
|
tag = buf;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
in.clear();
|
||||||
|
in.seekg(pos, std::ios::beg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue