Commit 12da7f38 authored by Mark Olesen's avatar Mark Olesen
Browse files

moved and fixed suspicious test in ISstream::read(word&)

parent c832d635
......@@ -42,7 +42,7 @@ char Foam::ISstream::nextValid()
while (get(c) && isspace(c))
{}
// Return if stream is bad
// Return if stream is bad - ie, previous get() failed
if (bad() || isspace(c))
{
return 0;
......@@ -335,17 +335,6 @@ Foam::Istream& Foam::ISstream::read(word& str)
while (get(c) && word::valid(c))
{
if (fail())
{
buf[errLen] = buf[nChar] = '\0';
FatalIOErrorIn("ISstream::read(word&)", *this)
<< "problem while reading word '" << buf << "'\n"
<< exit(FatalIOError);
return *this;
}
if (c == token::BEGIN_LIST)
{
listDepth++;
......@@ -376,6 +365,19 @@ Foam::Istream& Foam::ISstream::read(word& str)
}
}
// we could probably skip this check
if (bad())
{
buf[errLen] = buf[nChar] = '\0';
FatalIOErrorIn("ISstream::read(word&)", *this)
<< "problem while reading word '" << buf << "...' after "
<< nChar << " characters\n"
<< exit(FatalIOError);
return *this;
}
if (nChar == 0)
{
FatalIOErrorIn("ISstream::read(word&)", *this)
......@@ -413,7 +415,7 @@ Foam::Istream& Foam::ISstream::read(string& str)
if (c != token::BEGIN_STRING)
{
FatalIOErrorIn("ISstream::read(string&)", *this)
<< "Incorrect start of string character"
<< "Incorrect start of string character found : " << c
<< exit(FatalIOError);
return *this;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment