diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 37613da4cd..1ed2dc86a6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -7,6 +7,10 @@ For example: 2002-12-01 23:12 UTC+0100 Foo Bar */ + enhanced functions, working on any bit range from 1 to 32 + + all provided by Walter Negro - FOEESITRA + * contrib/libct/Makefile * contrib/libct/makefile.bc * contrib/libct/makefile.vc diff --git a/harbour/source/rtl/typefile.prg b/harbour/source/rtl/typefile.prg index 64e207cad3..0ebd84b959 100644 --- a/harbour/source/rtl/typefile.prg +++ b/harbour/source/rtl/typefile.prg @@ -57,7 +57,7 @@ #define BUFFER_LENGTH 2048 FUNCTION __TYPEFILE( cFile, lPrint ) - LOCAL nHandle, cBuffer + LOCAL nHandle, cBuffer, nRead := 0, nHasRead := 0, nSize := 0, nBuffer LOCAL oErr, xRecover, nRetries LOCAL aSaveSet[ 2 ] LOCAL cDir, cName, cExt, cTmp, aPath, i @@ -122,14 +122,20 @@ FUNCTION __TYPEFILE( cFile, lPrint ) aSaveSet[ 2 ] := Set( _SET_PRINTER, .T. ) ENDIF + nSize := FSeek( nHandle, 0, FS_END ) + nBuffer := MIN( nSize, BUFFER_LENGTH ) + + FSeek( nHandle, 0 ) // go top // here we try to read a line at a time but I think we could just // display the whole buffer since it said: "without any headings or formating" - cbuffer := SPACE( BUFFER_LENGTH ) + cbuffer := SPACE( nBuffer ) ? // start in a new line - DO WHILE fread( nHandle, @cbuffer, BUFFER_LENGTH ) > 0 + DO WHILE ( nRead := fread( nHandle, @cbuffer, nBuffer )) > 0 + nHasRead += nRead ?? cBuffer - cbuffer := SPACE( BUFFER_LENGTH ) + nBuffer := MIN( nSize - nHasRead, nBuffer ) + cbuffer := SPACE( nBuffer ) ENDDO FCLOSE( nHandle )