From: <mie...@us...> - 2008-06-19 18:16:38
|
Revision: 2551 http://oorexx.svn.sourceforge.net/oorexx/?rev=2551&view=rev Author: miesfeld Date: 2008-06-19 11:15:43 -0700 (Thu, 19 Jun 2008) Log Message: ----------- Ensure SysFile::read() only returns true when some bytes are actually read. Modified Paths: -------------- sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp Modified: sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp =================================================================== --- sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-19 18:04:04 UTC (rev 2550) +++ sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-19 18:15:43 UTC (rev 2551) @@ -1182,6 +1182,7 @@ // hit end of file reading this? This will be the entire line then if (fileInfo.atEof()) { + lineReadIncrement(); return context->NewString(bufferAddress, currentLength + bytesRead); } @@ -1190,6 +1191,7 @@ // single lf characters. if (buffer[bytesRead - 1] == '\n') { + lineReadIncrement(); return context->NewString(buffer, currentLength + bytesRead - 1); } currentLength += bytesRead; @@ -1198,6 +1200,24 @@ } /** + * Increments the read positions, including the line-orientated positions, after + * a single line has been read. Assumes one line has actually been read. + */ +void StreamInfo::lineReadIncrement() +{ + if ( !fileInfo.getPosition(charReadPosition) ) + { + notreadyError(); + } + // Keep this 1-based. + charReadPosition++; + + lineReadPosition++; + lineReadCharPosition = charReadPosition; + last_op_was_read = true; +} + +/** * Reset all line-oriented position information after an * operation that will invalidate the values (for example, a * charin() or charout() operation). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |