Avoid comparing filepos with integers

The filepos type is not necessarily an integer type, because it also needs
to save the multibyte character state in case we're reading from a stream
with shift states.

The convention of using -1 as a special value is from Unix ftell(), and not
portable. Instead, the stream's failbit needs to be examined after the call
to tellg().
This commit is contained in:
Simon Richter 2016-01-17 10:59:08 -05:00 committed by Chris Pavlina
parent 05ee63fe39
commit ba66f0360a
1 changed files with 1 additions and 1 deletions

View File

@ -37,7 +37,7 @@ bool IDF3::FetchIDFLine( std::ifstream& aModel, std::string& aLine, bool& isComm
aLine = ""; aLine = "";
aFilePos = aModel.tellg(); aFilePos = aModel.tellg();
if( aFilePos == -1 ) if( aModel.fail() )
return false; return false;
std::getline( aModel, aLine ); std::getline( aModel, aLine );