Commit 3f0b6ec8 authored by Mark Olesen's avatar Mark Olesen
Browse files

Fix minor bug in ITstream

- The lineNumber of token::undefinedToken was being changed instead of
  just the lineNumber of the return token.

- use List::first() and List::last() methods as well
parent 1b45fab9
......@@ -79,7 +79,7 @@ Foam::Istream& Foam::ITstream::read(token& t)
{
FatalIOErrorIn
(
"ITstream::read(token& t)",
"ITstream::read(token&)",
*this
) << "attempt to read beyond EOF"
<< exit(FatalIOError);
......@@ -91,17 +91,16 @@ Foam::Istream& Foam::ITstream::read(token& t)
setEof();
}
t = token::undefinedToken;
if (size())
{
token::undefinedToken.lineNumber()
= operator[](size() - 1).lineNumber();
t.lineNumber() = tokenList::last().lineNumber();
}
else
{
token::undefinedToken.lineNumber() = lineNumber();
t.lineNumber() = lineNumber();
}
t = token::undefinedToken;
}
return *this;
......@@ -110,7 +109,7 @@ Foam::Istream& Foam::ITstream::read(token& t)
Foam::Istream& Foam::ITstream::read(char&)
{
notImplemented("Istream& ITstream::read(char& c)");
notImplemented("Istream& ITstream::read(char&)");
return *this;
}
......@@ -157,14 +156,13 @@ Foam::Istream& Foam::ITstream::read(char*, std::streamsize)
}
// Rewind the token stream so that it may be read again
Foam::Istream& Foam::ITstream::rewind()
{
tokenIndex_ = 0;
if (size())
{
lineNumber_ = operator[](0).lineNumber();
lineNumber_ = tokenList::first().lineNumber();
}
setGood();
......
Markdown is supported
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