diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 647cd2f006..991e621f09 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,4 +1,9 @@ -19990902--01:44 GMT+1 Victor Szel +19990901-21:24 EDT Paul Tucker + * source/rtl/filesys.c + hb_fsReadLarge() -> drop out on eof + hb_fsWriteLarge() -> drop out on disk full + +19990902-01:44 GMT+1 Victor Szel * source/rtl/filesys.c include/filesys.h - For speed reasons the hb_fsRead/Write() functions were set back to use diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index 2f9d66abb9..8e11d24443 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -293,7 +293,7 @@ static void hb_outerr( char * pStr, ULONG len ) /* Output an item to the screen and/or printer and/or alternate */ static void hb_altout( char * pStr, ULONG len ) { - char * pPtr = pStr; + char *pPtr = pStr; if( hb_set.HB_SET_CONSOLE ) { @@ -327,7 +327,7 @@ static void hb_altout( char * pStr, ULONG len ) write_len = count; count = 0; } - hb_fsWrite( hb_set_althan, pPtr, write_len ); + hb_fsWrite( hb_set_althan, (BYTE *)pPtr, write_len ); pPtr += write_len; } } @@ -349,7 +349,7 @@ static void hb_altout( char * pStr, ULONG len ) write_len = count; count = 0; } - hb_fsWrite( hb_set_extrahan, pPtr, write_len ); + hb_fsWrite( hb_set_extrahan, (BYTE *)pPtr, write_len ); pPtr += write_len; } } @@ -371,7 +371,7 @@ static void hb_altout( char * pStr, ULONG len ) write_len = count; count = 0; } - hb_fsWrite( hb_set_printhan, pPtr, write_len ); + hb_fsWrite( hb_set_printhan, (BYTE *)pPtr, write_len ); pPtr += write_len; } if( len + s_uiPCol > USHRT_MAX ) s_uiPCol = USHRT_MAX; @@ -400,7 +400,7 @@ static void hb_devout( char * pStr, ULONG len ) write_len = count; count = 0; } - hb_fsWrite( hb_set_printhan, pPtr, write_len ); + hb_fsWrite( hb_set_printhan, (BYTE *)pPtr, write_len ); pPtr += write_len; } if( len + s_uiPCol > USHRT_MAX ) s_uiPCol = USHRT_MAX; @@ -473,18 +473,18 @@ void hb_devpos( WORD row, WORD col ) { if( row < s_uiPRow ) { - hb_fsWrite( hb_set_printhan, "\x0C", 1 ); + hb_fsWrite( hb_set_printhan, (BYTE *)"\x0C", 1 ); s_uiPRow = s_uiPCol = 0; } for( count = s_uiPRow; count < row; count++ ) - hb_fsWrite( hb_set_printhan, s_szCrLf, CRLF_BUFFER_LEN-1 ); + hb_fsWrite( hb_set_printhan, (BYTE *)s_szCrLf, CRLF_BUFFER_LEN-1 ); if( row > s_uiPRow ) s_uiPCol = 0; col += hb_set.HB_SET_MARGIN; for( count = s_uiPCol; count < col; count++ ) - hb_fsWrite( hb_set_printhan, " ", 1 ); + hb_fsWrite( hb_set_printhan, (BYTE *)" ", 1 ); s_uiPRow = row; s_uiPCol = col; @@ -540,7 +540,7 @@ HARBOUR HB_QOUT( void ) s_uiPCol = hb_set.HB_SET_MARGIN; count = s_uiPCol; while( count-- > 0 ) - hb_fsWrite( hb_set_printhan, " ", 1 ); + hb_fsWrite( hb_set_printhan, (BYTE *)" ", 1 ); } HB_QQOUT(); @@ -654,7 +654,7 @@ HARBOUR HB___EJECT( void ) /* Ejects the current page from the printer */ { if( hb_stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set_printhan >= 0 ) { - hb_fsWrite( hb_set_printhan, "\x0C\x0D", 2 ); + hb_fsWrite( hb_set_printhan, (BYTE *)"\x0C\x0D", 2 ); s_uiPRow = s_uiPCol = 0; } } diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 22cd9e17ff..b654f9b482 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -444,13 +444,14 @@ ULONG hb_fsReadLarge( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount ) { USHORT uiRead = read( hFileHandle, pBuff, ( USHORT ) ( ulCount - ulReadTotal ) ); - if( uiRead == ( USHORT )-1 ) + /* -1 for bad hFileHandle or file is WriteOnly + 0 for EOF + */ + if( uiRead == ( USHORT )-1 || uiRead == 0 ) break; ulReadTotal += ( ULONG ) uiRead; - if( uiRead < ( USHORT ) ( ulCount - ulReadTotal ) ) - break; } s_uiErrorLast = errno; @@ -474,13 +475,14 @@ ULONG hb_fsWriteLarge( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount ) { USHORT uiWritten = write( hFileHandle, pBuff, ( USHORT ) ( ulCount - ulWrittenTotal ) ); - if( uiWritten == ( USHORT )-1 ) + /* -1 on bad hFileHandle + 0 on disk full + */ + if( uiWritten == ( USHORT )-1 || uiWritten == 0 ) break; ulWrittenTotal += ( ULONG ) uiWritten; - if( uiWritten < ( USHORT ) ( ulCount - ulWrittenTotal ) ) - break; } s_uiErrorLast = errno; diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index ab318c9e3d..a02a266eea 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -234,7 +234,7 @@ static void close_text( FHANDLE handle ) if( handle != FS_ERROR ) { #if ! defined(OS_UNIX_COMPATIBLE) - hb_fsWrite( handle, "\x1A", 1 ); + hb_fsWrite( handle, (BYTE *)"\x1A", 1 ); #endif hb_fsClose( handle ); } @@ -263,8 +263,8 @@ static FHANDLE open_handle( char * file_name, BOOL bMode, char * def_ext, HB_set /* QUESTION: What sharing mode does Clipper use ? [vszel] */ - while( ( handle = ( bMode ? hb_fsOpen( path, FO_WRITE | FO_DENYWRITE ) : - hb_fsCreate( path, FC_NORMAL ) ) ) == FS_ERROR ) + while( ( handle = ( bMode ? hb_fsOpen( (BYTE *)path, FO_WRITE | FO_DENYWRITE ) : + hb_fsCreate( (BYTE *)path, FC_NORMAL ) ) ) == FS_ERROR ) { WORD wResult;