From c3f2ef56f92554c70abf39420586acd34e80253e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 18 Oct 2008 19:18:17 +0000 Subject: [PATCH] 2008-10-18 21:16 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * source/common/hbgete.c ! Fixed recent warning on Win32 platforms. * contrib/xhb/hbcrypt.c * Changed to just work instead of RTE-in if any of the params are empty on non-strings. If non-string is passed, it's considered as empty string. --- harbour/ChangeLog | 10 ++++++++ harbour/contrib/xhb/hbcrypt.c | 46 +++++++++++----------------------- harbour/source/common/hbgete.c | 6 ++++- 3 files changed, 29 insertions(+), 33 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b423801664..67a8c1581a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-10-18 21:16 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * source/common/hbgete.c + ! Fixed recent warning on Win32 platforms. + + * contrib/xhb/hbcrypt.c + * Changed to just work instead of RTE-in if any + of the params are empty on non-strings. If + non-string is passed, it's considered as + empty string. + 2008-10-18 16:15 UTC+0200 Viktor Szakats (harbour.01 syenar hu) - bin/bld.bat + bin/hbmk.bat diff --git a/harbour/contrib/xhb/hbcrypt.c b/harbour/contrib/xhb/hbcrypt.c index 60ac70050e..3ce863d917 100644 --- a/harbour/contrib/xhb/hbcrypt.c +++ b/harbour/contrib/xhb/hbcrypt.c @@ -417,26 +417,17 @@ void nxs_make_scramble( int *scramble, const unsigned char *key, ULONG keylen ) HB_FUNC( HB_CRYPT ) { - PHB_ITEM pSource = hb_param( 1, HB_IT_STRING ); - PHB_ITEM pKey = hb_param( 2, HB_IT_STRING ); - BYTE *cRes; + PHB_ITEM pSource = hb_param( 1, HB_IT_ANY ); + PHB_ITEM pKey = hb_param( 2, HB_IT_ANY ); - if ( pSource == NULL || hb_itemGetCLen( pSource ) == 0 || - pKey == NULL || hb_itemGetCLen( pKey ) == 0 ) - { - hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 2, - hb_param(1,HB_IT_ANY), hb_param(2,HB_IT_ANY) ); - return; - } - - cRes = (BYTE *) hb_xgrab( hb_itemGetCLen( pSource ) + 8 ); + BYTE * cRes = ( BYTE * ) hb_xgrab( hb_itemGetCLen( pSource ) + 8 ); nxs_crypt( - (BYTE *) hb_itemGetCPtr( pSource ), hb_itemGetCLen( pSource ), - (BYTE *) hb_itemGetCPtr( pKey ), hb_itemGetCLen( pKey ), - cRes); + ( BYTE * ) hb_itemGetCPtr( pSource ), hb_itemGetCLen( pSource ), + ( BYTE * ) hb_itemGetCPtr( pKey ), hb_itemGetCLen( pKey ), + cRes ); - hb_retclenAdopt( (char *)cRes, hb_itemGetCLen( pSource ) ); + hb_retclenAdopt( ( char * ) cRes, hb_itemGetCLen( pSource ) ); } /***** @@ -447,24 +438,15 @@ HB_FUNC( HB_CRYPT ) HB_FUNC( HB_DECRYPT ) { - PHB_ITEM pSource = hb_param( 1, HB_IT_STRING ); - PHB_ITEM pKey = hb_param( 2, HB_IT_STRING ); - BYTE *cRes; + PHB_ITEM pSource = hb_param( 1, HB_IT_ANY ); + PHB_ITEM pKey = hb_param( 2, HB_IT_ANY ); - if ( pSource == NULL || hb_itemGetCLen( pSource ) == 0 || - pKey == NULL || hb_itemGetCLen( pKey ) == 0 ) - { - hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 2, - hb_param(1,HB_IT_ANY), hb_param(2,HB_IT_ANY) ); - return; - } - - cRes = ( BYTE * ) hb_xgrab( hb_itemGetCLen( pSource ) + 8 ); + BYTE * cRes = ( BYTE * ) hb_xgrab( hb_itemGetCLen( pSource ) + 8 ); nxs_decrypt( - (BYTE *) hb_itemGetCPtr( pSource ), hb_itemGetCLen( pSource ), - (BYTE *) hb_itemGetCPtr( pKey ), hb_itemGetCLen( pKey ), - cRes); + ( BYTE * ) hb_itemGetCPtr( pSource ), hb_itemGetCLen( pSource ), + ( BYTE * ) hb_itemGetCPtr( pKey ), hb_itemGetCLen( pKey ), + cRes ); - hb_retclenAdopt( (char *)cRes, hb_itemGetCLen( pSource ) ); + hb_retclenAdopt( ( char * ) cRes, hb_itemGetCLen( pSource ) ); } diff --git a/harbour/source/common/hbgete.c b/harbour/source/common/hbgete.c index babfc27fee..69f8eabafa 100644 --- a/harbour/source/common/hbgete.c +++ b/harbour/source/common/hbgete.c @@ -115,7 +115,7 @@ char * hb_getenv( const char * szName ) BOOL hb_getenv_buffer( const char * szName, char * szBuffer, int nSize ) { - BOOL bRetVal = FALSE; + BOOL bRetVal; #if defined(HB_OS_WIN_32) @@ -135,6 +135,8 @@ BOOL hb_getenv_buffer( const char * szName, char * szBuffer, int nSize ) if( szBuffer != NULL && nSize != 0 ) hb_strncpy( szBuffer, EnvValue, nSize - 1 ); } + else + bRetVal = FALSE; } #else { @@ -146,6 +148,8 @@ BOOL hb_getenv_buffer( const char * szName, char * szBuffer, int nSize ) if( szBuffer != NULL && nSize != 0 ) hb_strncpy( szBuffer, pszTemp, nSize - 1 ); } + else + bRetVal = FALSE; } #endif