diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 1c331f3b36..3bc3cd866a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,15 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-11-01 12:02 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * include/hbextern.ch + * source/rtl/memofile.c + + Added HB_MEMOREAD() which is identical to MEMOREAD() + except it won't truncate the last byte (on non-UNIX + compatible systems) if it's a EOF char. + See also existing HB_MEMOWRIT(). + [TOMERGE 1.0] + 2008-11-01 11:24 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * source/rtl/hbi18n.c * Minor change in header to separate it visually from comment diff --git a/harbour/include/hbextern.ch b/harbour/include/hbextern.ch index f8a3d3716c..1454535a14 100644 --- a/harbour/include/hbextern.ch +++ b/harbour/include/hbextern.ch @@ -1130,6 +1130,7 @@ EXTERNAL HB_TOKENGET EXTERNAL HB_TOKENPTR EXTERNAL HB_ATOKENS EXTERNAL HB_STRSHRINK +EXTERNAL HB_MEMOREAD EXTERNAL HB_MEMOWRIT EXTERNAL HB_NTOS diff --git a/harbour/source/rtl/memofile.c b/harbour/source/rtl/memofile.c index c16ab9f4d0..fd1b039d8a 100644 --- a/harbour/source/rtl/memofile.c +++ b/harbour/source/rtl/memofile.c @@ -58,7 +58,7 @@ this limit is extended, so we are not *strictly* compatible here. [vszakats] */ -HB_FUNC( MEMOREAD ) +static void hb_memoread( BOOL bHandleEOF ) { PHB_ITEM pFileName = hb_param( 1, HB_IT_STRING ); @@ -76,7 +76,8 @@ HB_FUNC( MEMOREAD ) /* Don't read the file terminating EOF character */ - #if ! defined(HB_OS_UNIX_COMPATIBLE) +#if ! defined(HB_OS_UNIX_COMPATIBLE) + if( bHandleEOF ) { BYTE byEOF = HB_CHAR_NUL; @@ -86,7 +87,9 @@ HB_FUNC( MEMOREAD ) if( byEOF == HB_CHAR_EOF ) ulSize--; } - #endif +#else + HB_SYMBOL_UNUSED( bHandleEOF ); +#endif pbyBuffer = ( BYTE * ) hb_xgrab( ulSize + sizeof( char ) ); @@ -107,7 +110,17 @@ HB_FUNC( MEMOREAD ) hb_retc( NULL ); } -static BOOL hb_memowrit( BOOL bWriteEOF ) +HB_FUNC( HB_MEMOREAD ) +{ + hb_memoread( FALSE ); +} + +HB_FUNC( MEMOREAD ) +{ + hb_memoread( TRUE ); +} + +static BOOL hb_memowrit( BOOL bHandleEOF ) { PHB_ITEM pFileName = hb_param( 1, HB_IT_STRING ); PHB_ITEM pString = hb_param( 2, HB_IT_STRING ); @@ -126,13 +139,13 @@ static BOOL hb_memowrit( BOOL bWriteEOF ) /* NOTE: CA-Cl*pper will add the EOF even if the write failed. [vszakats] */ /* NOTE: CA-Cl*pper will not return .F. when the EOF could not be written. [vszakats] */ #if ! defined(HB_OS_UNIX_COMPATIBLE) - if( bWriteEOF ) /* if true, then write EOF */ + if( bHandleEOF ) /* if true, then write EOF */ { BYTE byEOF = HB_CHAR_EOF; hb_fsWrite( fhnd, &byEOF, sizeof( BYTE ) ); } #else - HB_SYMBOL_UNUSED( bWriteEOF ); + HB_SYMBOL_UNUSED( bHandleEOF ); #endif hb_fsClose( fhnd );