From 40e7f5faf9c265577d66d6a5b91ed347a54c99cd Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 18 Mar 2010 13:10:17 +0000 Subject: [PATCH] 2010-03-18 14:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbwin/axcore.c * use hb_parstr_u16() instead of hb_mbtowc(hb_parc(n)) * harbour/src/rtl/hbzlib.c * modified HB_ZUNCOMPRESSLEN(), current syntax is: HB_ZUNCOMPRESSLEN( , [<@nResult>] ) -> or -1 on error * harbour/contrib/hbbzip2/hbbzip2.c * modified HB_BZ2_UNCOMPRESSLEN(), current syntax is: HB_BZ2_UNCOMPRESSLEN( , [<@nResult>] ) -> or -1 on error --- harbour/ChangeLog | 14 ++++++++ harbour/contrib/hbbzip2/hbbzip2.c | 26 ++++++++++---- harbour/contrib/hbwin/axcore.c | 14 ++++---- harbour/src/rtl/hbzlib.c | 59 ++++++++++++++++++++++--------- 4 files changed, 83 insertions(+), 30 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 7b22651fa7..86010a9639 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,20 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-03-18 14:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/hbwin/axcore.c + * use hb_parstr_u16() instead of hb_mbtowc(hb_parc(n)) + + * harbour/src/rtl/hbzlib.c + * modified HB_ZUNCOMPRESSLEN(), current syntax is: + HB_ZUNCOMPRESSLEN( , [<@nResult>] ) + -> or -1 on error + + * harbour/contrib/hbbzip2/hbbzip2.c + * modified HB_BZ2_UNCOMPRESSLEN(), current syntax is: + HB_BZ2_UNCOMPRESSLEN( , [<@nResult>] ) + -> or -1 on error + 2010-03-18 13:29 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * INSTALL ! Fixed Debian bzip2 package name. diff --git a/harbour/contrib/hbbzip2/hbbzip2.c b/harbour/contrib/hbbzip2/hbbzip2.c index 71c4e8a0d8..ff77c471b2 100644 --- a/harbour/contrib/hbbzip2/hbbzip2.c +++ b/harbour/contrib/hbbzip2/hbbzip2.c @@ -206,16 +206,30 @@ HB_FUNC( HB_BZ2_COMPRESSBOUND ) } /* - * HB_BZ2_UNCOMPRESSLEN( , [<@nResult>] ) -> or 0 on error + * HB_BZ2_UNCOMPRESSLEN( , [<@nResult>] ) + * -> or -1 on error */ HB_FUNC( HB_BZ2_UNCOMPRESSLEN ) { - HB_SIZE ulLen = hb_parclen( 1 ); - int iResult = 0; + const char * szData = hb_parc( 1 ); - hb_retnint( ulLen ? - hb_bz2UncompressedSize( hb_parc( 1 ), ulLen, &iResult ) : 0 ); - hb_storni( iResult, 2 ); + if( szData ) + { + HB_SIZE nLen = hb_parclen( 1 ); + int iResult = BZ_OK; + + if( nLen ) + nLen = hb_bz2UncompressedSize( szData, nLen, &iResult ); + + if( iResult == BZ_OK ) + hb_retni( -1 ); + else + hb_retnint( nLen ); + + hb_storni( iResult, 2 ); + } + else + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } /* diff --git a/harbour/contrib/hbwin/axcore.c b/harbour/contrib/hbwin/axcore.c index 47b07e8589..debc0a166f 100644 --- a/harbour/contrib/hbwin/axcore.c +++ b/harbour/contrib/hbwin/axcore.c @@ -51,6 +51,7 @@ */ #include "hbwinole.h" +#include "hbapistr.h" #if defined( HB_OS_WIN_CE ) #include "hbwince.h" #endif @@ -426,14 +427,13 @@ HB_FUNC( __AXREGISTERHANDLER ) /* ( pDisp, bHandler [, cID] ) --> pSink */ IConnectionPoint* pCP = NULL; HRESULT lOleError = S_OK; IID rriid = IID_IDispatch; - const char* cID = hb_parc( 3 ); + void* hCLSID; + const wchar_t* wCLSID; - if( cID ) - { - wchar_t* wCLSID = hb_mbtowc( cID ); - lOleError = CLSIDFromString( wCLSID, &rriid ); - hb_xfree( wCLSID ); - } + wCLSID = hb_parstr_u16( 3, HB_CDP_ENDIAN_NATIVE, &hCLSID, NULL ); + if( wCLSID ) + lOleError = CLSIDFromString( ( wchar_t * ) wCLSID, &rriid ); + hb_strfree( hCLSID ); if( lOleError == S_OK ) { diff --git a/harbour/src/rtl/hbzlib.c b/harbour/src/rtl/hbzlib.c index 9f08163de0..a1be3723a6 100644 --- a/harbour/src/rtl/hbzlib.c +++ b/harbour/src/rtl/hbzlib.c @@ -56,7 +56,8 @@ #include -static HB_SIZE hb_zlibUncompressedSize( const char * szSrc, HB_SIZE ulLen ) +static HB_SIZE hb_zlibUncompressedSize( const char * szSrc, HB_SIZE ulLen, + int * piResult ) { Byte buffer[ 1024 ]; z_stream stream; @@ -71,18 +72,23 @@ static HB_SIZE hb_zlibUncompressedSize( const char * szSrc, HB_SIZE ulLen ) stream.zfree = Z_NULL; stream.opaque = NULL; */ - if( inflateInit( &stream ) == Z_OK ) + + *piResult = inflateInit( &stream ); + if( *piResult == Z_OK ) { - int iStatus; do { stream.next_out = buffer; stream.avail_out = sizeof( buffer ); - iStatus = inflate( &stream, Z_NO_FLUSH ); + *piResult = inflate( &stream, Z_NO_FLUSH ); } - while( iStatus == Z_OK ); - if( iStatus == Z_STREAM_END ) + while( *piResult == Z_OK ); + + if( *piResult == Z_STREAM_END ) + { ulDest = stream.total_out; + *piResult = Z_OK; + } inflateEnd( &stream ); } @@ -114,13 +120,30 @@ HB_FUNC( HB_ZCOMPRESSBOUND ) } /* - * HB_ZUNCOMPRESSLEN( ) -> or 0 on error + * HB_ZUNCOMPRESSLEN( , [<@nResult>] ) + * -> or -1 on error */ HB_FUNC( HB_ZUNCOMPRESSLEN ) { - HB_SIZE ulLen = hb_parclen( 1 ); + const char * szData = hb_parc( 1 ); - hb_retnint( ulLen ? hb_zlibUncompressedSize( hb_parc( 1 ), ulLen ) : 0 ); + if( szData ) + { + HB_SIZE ulLen = hb_parclen( 1 ); + int iResult = Z_OK; + + if( ulLen ) + ulLen = hb_zlibUncompressedSize( szData, ulLen, &iResult ); + + if( iResult == Z_OK ) + hb_retni( -1 ); + else + hb_retnint( ulLen ); + + hb_storni( iResult, 2 ); + } + else + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } /* @@ -202,21 +225,26 @@ HB_FUNC( HB_ZUNCOMPRESS ) { uLong ulDstLen; char * pDest; - int iResult; + int iResult = Z_OK; if( pBuffer ) { if( !hb_itemGetWriteCL( pBuffer, &pDest, &ulDstLen ) ) - pDest = NULL; + iResult = Z_MEM_ERROR; } else { ulDstLen = HB_ISNUM( 2 ) ? ( uLong ) hb_parnint( 2 ) : - hb_zlibUncompressedSize( szData, ulLen ); - pDest = ( char * ) hb_xalloc( ulDstLen + 1 ); + hb_zlibUncompressedSize( szData, ulLen, &iResult ); + if( iResult == Z_OK ) + { + pDest = ( char * ) hb_xalloc( ulDstLen + 1 ); + if( !pDest ) + iResult = Z_MEM_ERROR; + } } - if( pDest ) + if( iResult == Z_OK ) { iResult = uncompress( ( Bytef * ) pDest, &ulDstLen, ( Bytef * ) szData, ulLen ); @@ -230,9 +258,6 @@ HB_FUNC( HB_ZUNCOMPRESS ) else if( iResult == Z_OK ) hb_retclen( pDest, ulDstLen ); } - else - iResult = Z_MEM_ERROR; - hb_storni( iResult, 3 ); } else