Skip to content

Commit

Permalink
fix end-of-stream behavior reading from files
Browse files Browse the repository at this point in the history
  • Loading branch information
pettyalex committed Jun 24, 2017
1 parent c57acca commit 74f828f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions HMIndividualsExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void HMIndividualsExtractor::loadInput()
ALL_SNPS.beginChromosome();
numberOfMarkers = ALL_SNPS.size();

while (!stream_sample.eof() && !stream_phased.eof()) getIndividuals();
while (!stream_sample && !stream_phased) getIndividuals();

stream_sample.close();
stream_phased.clear();
Expand Down Expand Up @@ -84,7 +84,7 @@ void HMIndividualsExtractor::getIndividuals()
streamoff offset = stream_phased.tellg(); if ( offset > 0 ) offset--;

getline ( stream_phased , discard );
if ( stream_phased.eof() ) return;
if ( stream_phased ) return;
offset_buffer = ( stream_phased.tellg() - offset);
getline ( stream_phased , discard );
stream_sample >> ID >> discard;
Expand Down
2 changes: 1 addition & 1 deletion PEDIndividualsExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void PEDIndividualsExtractor::loadInput()
int i = 0;

// The stream was getting failbit set and not eof bit
while (stream.good())
while (stream)
{
getIndividuals();
stream.seekg(numberOfMarkers*4 + 1,ios_base::cur);
Expand Down

0 comments on commit 74f828f

Please sign in to comment.