Added in.clear() before resetting I/Os streams. Again, thanks to the

list.
This commit is contained in:
John Wiegley 2006-02-15 20:46:07 +00:00
parent 56b2234809
commit 6cee916e04
6 changed files with 11 additions and 0 deletions

View file

@ -489,6 +489,7 @@ bool binary_parser_t::test(std::istream& in) const
read_binary_number<unsigned long>(in) == format_version)
return true;
in.clear();
in.seekg(0, std::ios::beg);
return false;
}

View file

@ -345,6 +345,7 @@ bool gnucash_parser_t::test(std::istream& in) const
{
char buf[5];
in.read(buf, 5);
in.clear();
in.seekg(0, std::ios::beg);
return std::strncmp(buf, "<?xml", 5) == 0;

4
ofx.cc
View file

@ -172,10 +172,12 @@ bool ofx_parser_t::test(std::istream& in) const
in.getline(buf, 79);
if (std::strncmp(buf, "OFXHEADER", 9) == 0) {
in.clear();
in.seekg(0, std::ios::beg);
return true;
}
else if (std::strncmp(buf, "<?xml", 5) != 0) {
in.clear();
in.seekg(0, std::ios::beg);
return false;
}
@ -183,10 +185,12 @@ bool ofx_parser_t::test(std::istream& in) const
in.getline(buf, 79);
if (std::strncmp(buf, "<?OFX", 5) != 0 &&
std::strncmp(buf, "<?ofx", 5) != 0) {
in.clear();
in.seekg(0, std::ios::beg);
return false;
}
in.clear();
in.seekg(0, std::ios::beg);
return true;
}

1
qif.cc
View file

@ -30,6 +30,7 @@ bool qif_parser_t::test(std::istream& in) const
char magic[sizeof(unsigned int) + 1];
in.read(magic, sizeof(unsigned int));
magic[sizeof(unsigned int)] = '\0';
in.clear();
in.seekg(0, std::ios::beg);
return (std::strcmp(magic, "!Typ") == 0 ||

View file

@ -457,6 +457,7 @@ bool textual_parser_t::test(std::istream& in) const
#endif
}
in.clear();
in.seekg(0, std::ios::beg);
assert(in.good());
return true;

3
xml.cc
View file

@ -158,16 +158,19 @@ bool xml_parser_t::test(std::istream& in) const
in.getline(buf, 79);
if (std::strncmp(buf, "<?xml", 5) != 0) {
in.clear();
in.seekg(0, std::ios::beg);
return false;
}
in.getline(buf, 79);
if (! std::strstr(buf, "<ledger")) {
in.clear();
in.seekg(0, std::ios::beg);
return false;
}
in.clear();
in.seekg(0, std::ios::beg);
return true;
}