Commit fdc7e9a8 authored by Dick Hollenbeck's avatar Dick Hollenbeck Committed by Wayne Stambaugh

Commit Dick's INPUTSTREAM_LINE_READER patch.

parent 1468a4ae
......@@ -195,9 +195,8 @@ INPUTSTREAM_LINE_READER::INPUTSTREAM_LINE_READER( wxInputStream* aStream ) :
unsigned INPUTSTREAM_LINE_READER::ReadLine() throw( IO_ERROR )
{
length = 0;
line[0] = 0;
while( !m_stream->Eof() )
for(;;)
{
if( length >= maxLineLength )
THROW_IO_ERROR( _( "Maximum line length exceeded" ) );
......@@ -205,15 +204,19 @@ unsigned INPUTSTREAM_LINE_READER::ReadLine() throw( IO_ERROR )
if( length + 1 > capacity )
expandCapacity( capacity * 2 );
line[ length ] = m_stream->GetC();
length++;
// this read may fail, docs say to test LastRead() before trusting cc.
char cc = m_stream->GetC();
if( !m_stream->LastRead() )
break;
line[ length++ ] = cc;
if( line[ length - 1 ] == '\n' )
if( cc == '\n' )
break;
}
line[ length ] = 0;
length -= 1;
// lineNum is incremented even if there was no line read, because this
// leads to better error reporting when we hit an end of file.
......
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