From 9536bad91a8ca95b4478d223dd2f0bc8cc4ebe47 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 23 Nov 2012 14:28:51 +0000 Subject: [PATCH] 2012-11-23 15:26 UTC+0100 Viktor Szakats (harbour syenar.net) * include/hbwinuni.h + new HB_WINAPI_KERNEL32_DLL() macro to get kernel32.dll regardless of UNICODE or non-UNICODE mode * contrib/hbwin/wapi_winbase.c * src/rtl/diskspac.c * src/rtl/disksphb.c % use HB_WINAPI_KERNEL32_DLL() macro ! fixed a non-UNICODE bug that slipped in previous commit * src/rtl/direct.c * made it format well using uncrustify * src/vm/asort.c * src/vm/memvars.c * cleanups --- harbour/ChangeLog | 18 ++++++++++++ harbour/contrib/hbwin/wapi_winbase.c | 7 +---- harbour/include/hbwinuni.h | 2 ++ harbour/src/rtl/direct.c | 42 ++++++++++++++-------------- harbour/src/rtl/diskspac.c | 7 +---- harbour/src/rtl/disksphb.c | 11 ++------ harbour/src/vm/asort.c | 10 ++----- harbour/src/vm/memvars.c | 8 ------ 8 files changed, 48 insertions(+), 57 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 58e8dddcae..fe510d5520 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -10,6 +10,24 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2012-11-23 15:26 UTC+0100 Viktor Szakats (harbour syenar.net) + * include/hbwinuni.h + + new HB_WINAPI_KERNEL32_DLL() macro to get kernel32.dll + regardless of UNICODE or non-UNICODE mode + + * contrib/hbwin/wapi_winbase.c + * src/rtl/diskspac.c + * src/rtl/disksphb.c + % use HB_WINAPI_KERNEL32_DLL() macro + ! fixed a non-UNICODE bug that slipped in previous commit + + * src/rtl/direct.c + * made it format well using uncrustify + + * src/vm/asort.c + * src/vm/memvars.c + * cleanups + 2012-11-23 14:07 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbfbird/firebird.c * contrib/hbmisc/hb_f.c diff --git a/harbour/contrib/hbwin/wapi_winbase.c b/harbour/contrib/hbwin/wapi_winbase.c index ec71ba16c8..d86baebdb1 100644 --- a/harbour/contrib/hbwin/wapi_winbase.c +++ b/harbour/contrib/hbwin/wapi_winbase.c @@ -385,12 +385,7 @@ HB_FUNC( WAPI_GETLONGPATHNAME ) { s_getPathNameAddr = ( _HB_GETPATHNAME ) - GetProcAddress( -#if defined( UNICODE ) - GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ), -#else - GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ), -#endif + GetProcAddress( GetModuleHandle( HB_WINAPI_KERNEL32_DLL() ), HB_WINAPI_FUNCTION_NAME( "GetLongPathName" ) ); if( ! s_getPathNameAddr ) diff --git a/harbour/include/hbwinuni.h b/harbour/include/hbwinuni.h index dab0782f65..5b5421fa80 100644 --- a/harbour/include/hbwinuni.h +++ b/harbour/include/hbwinuni.h @@ -90,6 +90,7 @@ #define HB_OSSTRDUP( str ) hb_osStrU16Decode( str ) #define HB_OSSTRDUP2( str, buf, len ) hb_osStrU16Decode2( str, buf, len ) #define HB_WINAPI_FUNCTION_NAME( a ) ( a "W" ) + #define HB_WINAPI_KERNEL32_DLL() ( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ) #else #define HB_PARSTR( n, h, len ) hb_parstr( n, hb_setGetOSCP(), h, len ) #define HB_PARSTRDEF( n, h, len ) hb_strnull( hb_parstr( n, hb_setGetOSCP(), h, len ) ) @@ -121,6 +122,7 @@ #define HB_OSSTRDUP( str ) hb_osStrDecode( str ) #define HB_OSSTRDUP2( str, buf, len ) hb_osStrDecode2( str, buf, len ) #define HB_WINAPI_FUNCTION_NAME( a ) ( a "A" ) + #define HB_WINAPI_KERNEL32_DLL() ( TEXT( "kernel32.dll" ) ) #endif #endif /* HB_OS_WIN */ diff --git a/harbour/src/rtl/direct.c b/harbour/src/rtl/direct.c index aefcf7f544..5a7f4ef9d0 100644 --- a/harbour/src/rtl/direct.c +++ b/harbour/src/rtl/direct.c @@ -105,27 +105,27 @@ HB_FUNC( DIRECTORY ) { - const char * szDirSpec = hb_parc( 1 ); - const char * szAttributes = hb_parc( 2 ); - char * pszFree = NULL; - HB_FATTR ulMask; + const char * szDirSpec = hb_parc( 1 ); + const char * szAttributes = hb_parc( 2 ); + char * pszFree = NULL; + HB_FATTR ulMask; PHB_ITEM pDir = hb_itemArrayNew( 0 ); PHB_FFIND ffind; /* Get the passed attributes and convert them to Harbour Flags */ - ulMask = HB_FA_ARCHIVE - | HB_FA_READONLY - | HB_FA_DEVICE - | HB_FA_TEMPORARY - | HB_FA_SPARSE - | HB_FA_REPARSE - | HB_FA_COMPRESSED - | HB_FA_OFFLINE - | HB_FA_NOTINDEXED - | HB_FA_ENCRYPTED - | HB_FA_VOLCOMP; + ulMask = HB_FA_ARCHIVE | + HB_FA_READONLY | + HB_FA_DEVICE | + HB_FA_TEMPORARY | + HB_FA_SPARSE | + HB_FA_REPARSE | + HB_FA_COMPRESSED | + HB_FA_OFFLINE | + HB_FA_NOTINDEXED | + HB_FA_ENCRYPTED | + HB_FA_VOLCOMP; if( szAttributes && *szAttributes ) ulMask |= hb_fsAttrEncode( szAttributes ); @@ -145,7 +145,7 @@ HB_FUNC( DIRECTORY ) if( szDirSpec[ nLen ] == HB_OS_PATH_DELIM_CHR ) #endif szDirSpec = pszFree = - hb_xstrcpy( NULL, szDirSpec, HB_OS_ALLFILE_MASK, NULL ); + hb_xstrcpy( NULL, szDirSpec, HB_OS_ALLFILE_MASK, NULL ); } } else @@ -161,12 +161,12 @@ HB_FUNC( DIRECTORY ) { char buffer[ 32 ]; - hb_arrayNew( pSubarray, F_LEN ); - hb_arraySetC ( pSubarray, F_NAME, ffind->szName ); + hb_arrayNew( pSubarray, F_LEN ); + hb_arraySetC( pSubarray, F_NAME, ffind->szName ); hb_arraySetNInt( pSubarray, F_SIZE, ffind->size ); - hb_arraySetDL ( pSubarray, F_DATE, ffind->lDate ); - hb_arraySetC ( pSubarray, F_TIME, ffind->szTime ); - hb_arraySetC ( pSubarray, F_ATTR, hb_fsAttrDecode( ffind->attr, buffer ) ); + hb_arraySetDL( pSubarray, F_DATE, ffind->lDate ); + hb_arraySetC( pSubarray, F_TIME, ffind->szTime ); + hb_arraySetC( pSubarray, F_ATTR, hb_fsAttrDecode( ffind->attr, buffer ) ); /* Don't exit when array limit is reached */ hb_arrayAddForward( pDir, pSubarray ); diff --git a/harbour/src/rtl/diskspac.c b/harbour/src/rtl/diskspac.c index 24df5466b8..a7c472ec64 100644 --- a/harbour/src/rtl/diskspac.c +++ b/harbour/src/rtl/diskspac.c @@ -169,12 +169,7 @@ HB_FUNC( DISKSPACE ) { s_pGetDiskFreeSpaceEx = ( P_GDFSE ) - GetProcAddress( -#if defined( UNICODE ) - GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ), -#else - GetModuleHandle( TEXT( "kernel32.dll" ) ), -#endif + GetProcAddress( GetModuleHandle( HB_WINAPI_KERNEL32_DLL() ), HB_WINAPI_FUNCTION_NAME( "GetDiskFreeSpaceEx" ) ); s_fInit = HB_TRUE; } diff --git a/harbour/src/rtl/disksphb.c b/harbour/src/rtl/disksphb.c index 276b41ffb6..4c1838ef55 100644 --- a/harbour/src/rtl/disksphb.c +++ b/harbour/src/rtl/disksphb.c @@ -66,8 +66,8 @@ #include #endif #elif defined( HB_OS_WIN ) - #include "hbwinuni.h" #include + #include "hbwinuni.h" #if defined( HB_OS_WIN_CE ) #include "hbwince.h" #endif @@ -128,13 +128,8 @@ HB_FUNC( HB_DISKSPACE ) { s_pGetDiskFreeSpaceEx = ( P_GDFSE ) - GetProcAddress( -#if defined( UNICODE ) - GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ), -#else - GetModuleHandle( TEXT( "kernel32.dll" ) ), -#endif - HB_WINAPI_FUNCTION_NAME( "GetDiskFreeSpaceEx" ) ); + GetProcAddress( GetModuleHandle( HB_WINAPI_KERNEL32_DLL() ), + HB_WINAPI_FUNCTION_NAME( "GetDiskFreeSpaceEx" ) ); s_fInit = HB_TRUE; } diff --git a/harbour/src/vm/asort.c b/harbour/src/vm/asort.c index d0c97917f1..5dc20e49bf 100644 --- a/harbour/src/vm/asort.c +++ b/harbour/src/vm/asort.c @@ -151,19 +151,13 @@ static HB_ISIZ hb_arraySortQuickPartition( PHB_BASEARRAY pBaseArray, HB_ISIZ lb, for( ;; ) { while( j >= i && ! hb_itemIsLess( pBaseArray->pItems + j, pBaseArray->pItems + lb, pBlock, pBaseArray, j ) ) - { j--; - } while( i < j && ! hb_itemIsLess( pBaseArray->pItems + lb, pBaseArray->pItems + i, pBlock, pBaseArray, i ) ) - { i++; - } if( i >= j ) - { break; - } /* Swap the items */ hb_itemSwap( pBaseArray->pItems + i, pBaseArray->pItems + j ); @@ -171,7 +165,7 @@ static HB_ISIZ hb_arraySortQuickPartition( PHB_BASEARRAY pBaseArray, HB_ISIZ lb, i++; } - /* pivot belongs in pBaseArray->pItems[j] */ + /* pivot belongs in pBaseArray->pItems[ j ] */ if( j > lb && pBaseArray->nLen > ( HB_SIZE ) j ) hb_itemSwap( pBaseArray->pItems + lb, pBaseArray->pItems + j ); @@ -222,7 +216,7 @@ HB_BOOL hb_arraySort( PHB_ITEM pArray, HB_SIZE * pnStart, HB_SIZE * pnCount, PHB HB_SIZE nCount; HB_SIZE nEnd; - if( pnStart && ( *pnStart >= 1 ) ) + if( pnStart && *pnStart >= 1 ) nStart = *pnStart; else nStart = 1; diff --git a/harbour/src/vm/memvars.c b/harbour/src/vm/memvars.c index fd24feb0e6..e7b592f1fa 100644 --- a/harbour/src/vm/memvars.c +++ b/harbour/src/vm/memvars.c @@ -389,7 +389,6 @@ void hb_memvarSetValue( PHB_SYMB pMemvarSymb, PHB_ITEM pItem ) /* assignment to undeclared memvar - PRIVATE is assumed */ hb_memvarCreateFromDynSymbol( pDyn, VS_PRIVATE, pItem ); } - } else hb_errInternal( HB_EI_MVBADSYMBOL, NULL, pMemvarSymb->szName, NULL ); @@ -407,7 +406,6 @@ HB_ERRCODE hb_memvarGet( PHB_ITEM pItem, PHB_SYMB pMemvarSymb ) { PHB_ITEM pMemvar; - pMemvar = hb_dynsymGetMemvar( pDyn ); HB_TRACE( HB_TR_INFO, ( "Memvar item (%p)(%s) queried", pMemvar, pMemvarSymb->szName ) ); @@ -558,22 +556,16 @@ static PHB_DYNS hb_memvarFindSymbol( const char * szArg, HB_SIZE nLen ) char cChar = *szArg++; if( cChar >= 'a' && cChar <= 'z' ) - { szUprName[ iSize++ ] = cChar - ( 'a' - 'A' ); - } else if( cChar == ' ' || cChar == '\t' || cChar == '\n' ) { if( iSize ) break; } else if( ! cChar ) - { break; - } else - { szUprName[ iSize++ ] = cChar; - } } while( --nLen && iSize < HB_SYMBOL_NAME_LEN );