From 17a63cd22678372972d87d02b3054a1f00b81047 Mon Sep 17 00:00:00 2001 From: Luis Krause Date: Fri, 20 Feb 2004 16:56:17 +0000 Subject: [PATCH] 2004-02-20 8:55 UTC-0800 Luis Krause Mantilla --- harbour/ChangeLog | 9 +++++++++ harbour/contrib/mysql/mysql.c | 14 +++++++------- harbour/source/rtl/memofile.c | 9 ++++++--- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 198271a316..10a4bda15f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,15 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2004-02-20 8:55 UTC-0800 Luis Krause Mantilla + * contrib/mysql/mysql.c + ! Fixed declaration for filelength() from int to long to match io.h + * source/rtl/memofile.c + ! Changed return values for empty or failed calles to MemoRead() to return an + empty string instead of a NULL + ! Close file when MemoRead() was successful, but file was empty (was being left open) + Above solutions reported and provided by David Arturo Macías Corona. Thanks! + 2004-02-19 12:48 UTC-0800 Luis Krause Mantilla * contrib/rdd_ads/adsfunc.c ! fixed casting in adsShowError() diff --git a/harbour/contrib/mysql/mysql.c b/harbour/contrib/mysql/mysql.c index 966c3e83b3..2891e2a47c 100644 --- a/harbour/contrib/mysql/mysql.c +++ b/harbour/contrib/mysql/mysql.c @@ -344,13 +344,13 @@ HB_FUNC(SQLSRVINFO) } #ifdef __GNUC__ -int filelength( int handle ) +long filelength( int handle ) { int nEnd = hb_fsSeek( handle, 0 , 2 ); int nStart = hb_fsSeek( handle , 0 , 0 ); return nEnd - nStart; } -#endif +#endif char *filetoBuff(char *f,char *s) { @@ -369,11 +369,11 @@ HB_FUNC(DATATOSQL) int iSize; char *buffer; from=hb_parc(1); - iSize= hb_parclen(1) ; + iSize= hb_parclen(1) ; buffer=(char*)hb_xgrab((iSize*2)+1); - iSize = mysql_escape_string(buffer,from,iSize); - hb_retclen((char*)buffer,iSize) ; + iSize = mysql_escape_string(buffer,from,iSize); + hb_retclen((char*)buffer,iSize) ; hb_xfree(buffer); } @@ -393,8 +393,8 @@ HB_FUNC(FILETOSQLBINARY) hb_fsClose(fh); from=(char*)filetoBuff(FromBuffer,szFile); buffer=(char*)hb_xgrab(iLen+1); - iSize = mysql_escape_string(buffer,from,iSize); - hb_retclen((char*)buffer, iSize); + iSize = mysql_escape_string(buffer,from,iSize); + hb_retclen((char*)buffer, iSize); hb_xfree(buffer); hb_xfree(FromBuffer); } diff --git a/harbour/source/rtl/memofile.c b/harbour/source/rtl/memofile.c index 176ce471ec..6e0bfb4b67 100644 --- a/harbour/source/rtl/memofile.c +++ b/harbour/source/rtl/memofile.c @@ -98,13 +98,16 @@ HB_FUNC( MEMOREAD ) hb_retclen_buffer( ( char * ) pbyBuffer, ulSize ); } else - hb_retc( NULL ); + { + hb_fsClose( fhnd ); + hb_retc( "" ); + } } else - hb_retc( NULL ); + hb_retc( "" ); } else - hb_retc( NULL ); + hb_retc( "" ); } HB_FUNC( MEMOWRIT )