From 49e0b8e4e0876621f1b7b8a17e5bf7e939eae1fb Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 9 Nov 2010 09:47:51 +0000 Subject: [PATCH] 2010-11-09 10:47 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/rdd/sdf1.c ! fixed bug in SDF import procedure - many thanks to Enrico Maria Giordano for reporting the problem and to Vicente Guerra for locating the reason BTW fix committed to xHarbour may work but it's not correct, I suggest to update it. * harbour/src/rtl/hbdyn.c * harbour/src/rtl/hbsocket.c * harbour/src/rdd/dbfnsx/dbfnsx1.c * harbour/src/rdd/dbfcdx/dbfcdx1.c * harbour/src/rdd/dbffpt/dbffpt1.c * harbour/contrib/hbct/bitnum.c * harbour/contrib/hbwin/olecore.c * pacified some of MSVC6 warnings reported by Andi * harbour/utils/Makefile * added internal/developers build switch --- harbour/ChangeLog | 20 ++++++++++++++++++++ harbour/contrib/hbct/bitnum.c | 2 +- harbour/contrib/hbwin/olecore.c | 2 +- harbour/src/rdd/dbfcdx/dbfcdx1.c | 16 ++++++++-------- harbour/src/rdd/dbffpt/dbffpt1.c | 20 ++++++++++---------- harbour/src/rdd/dbfnsx/dbfnsx1.c | 6 +++--- harbour/src/rdd/sdf1.c | 10 ++++++---- harbour/src/rtl/hbsocket.c | 8 ++++---- harbour/utils/Makefile | 1 + 9 files changed, 54 insertions(+), 31 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 05ed3f47e4..53c691e448 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,26 @@ The license applies to all entries newer than 2009-04-28. */ +2010-11-09 10:47 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/src/rdd/sdf1.c + ! fixed bug in SDF import procedure - many thanks + to Enrico Maria Giordano for reporting the problem + and to Vicente Guerra for locating the reason + BTW fix committed to xHarbour may work but it's not correct, + I suggest to update it. + + * harbour/src/rtl/hbdyn.c + * harbour/src/rtl/hbsocket.c + * harbour/src/rdd/dbfnsx/dbfnsx1.c + * harbour/src/rdd/dbfcdx/dbfcdx1.c + * harbour/src/rdd/dbffpt/dbffpt1.c + * harbour/contrib/hbct/bitnum.c + * harbour/contrib/hbwin/olecore.c + * pacified some of MSVC6 warnings reported by Andi + + * harbour/utils/Makefile + * added internal/developers build switch + 2010-11-09 10:01 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/hbdyn.c ! Added casts to silence msvc6 warnings. diff --git a/harbour/contrib/hbct/bitnum.c b/harbour/contrib/hbct/bitnum.c index 358718469b..fcaf535862 100644 --- a/harbour/contrib/hbct/bitnum.c +++ b/harbour/contrib/hbct/bitnum.c @@ -179,7 +179,7 @@ HB_FUNC( NUMROL ) { if( hb_parl( 3 ) ) { - HB_USHORT us = ( HB_USHORT ) ( lValue & 0xff ) << ( lShift & 0x07 ); + HB_USHORT us = ( HB_USHORT ) ( ( lValue & 0xff ) << ( lShift & 0x07 ) ); lValue = ( lValue & 0xff00 ) | ( us & 0xff ) | ( us >> 8 ); } diff --git a/harbour/contrib/hbwin/olecore.c b/harbour/contrib/hbwin/olecore.c index e33ad0ccc4..cb868298ba 100644 --- a/harbour/contrib/hbwin/olecore.c +++ b/harbour/contrib/hbwin/olecore.c @@ -912,7 +912,7 @@ void hb_oleVariantToItemEx( PHB_ITEM pItem, VARIANT* pVariant, HB_USHORT uiClass long * plIndex = ( long * ) hb_xgrab( iDim * sizeof( long ) ); hb_oleSafeArrayToItem( pItem, pSafeArray, iDim, plIndex, - ( V_VT( pVariant ) & ~( VT_ARRAY | VT_BYREF ) ), + ( VARTYPE ) ( V_VT( pVariant ) & ~( VT_ARRAY | VT_BYREF ) ), uiClass ); hb_xfree( plIndex ); } diff --git a/harbour/src/rdd/dbfcdx/dbfcdx1.c b/harbour/src/rdd/dbfcdx/dbfcdx1.c index f782ffe7bc..477222e8d9 100644 --- a/harbour/src/rdd/dbfcdx/dbfcdx1.c +++ b/harbour/src/rdd/dbfcdx/dbfcdx1.c @@ -388,8 +388,8 @@ static LPCDXKEY hb_cdxKeyPutC( LPCDXKEY pKey, const char * szText, HB_USHORT uiR /* * compare two values using Tag conditions (len & type) */ -static int hb_cdxValCompare( LPCDXTAG pTag, HB_BYTE * val1, HB_BYTE len1, - HB_BYTE * val2, HB_BYTE len2, int iMode ) +static int hb_cdxValCompare( LPCDXTAG pTag, HB_BYTE * val1, int len1, + HB_BYTE * val2, int len2, int iMode ) { int iLimit, iResult = 0; @@ -851,7 +851,7 @@ static void hb_cdxTagSetScope( LPCDXTAG pTag, HB_USHORT nScope, PHB_ITEM pItem ) pScopeVal = ( hb_itemType( pItem ) == HB_IT_BLOCK ) ? hb_vmEvalBlock( pItem ) : pItem; - if( hb_cdxItemTypeCmp( pTag->uiType ) == hb_cdxItemTypeCmp( hb_cdxItemType( pScopeVal ) ) ) + if( hb_cdxItemTypeCmp( ( HB_BYTE ) pTag->uiType ) == hb_cdxItemTypeCmp( hb_cdxItemType( pScopeVal ) ) ) { PHB_ITEM *pScope; LPCDXKEY *pScopeKey; @@ -1570,7 +1570,7 @@ static HB_ULONG hb_cdxPageGetKeyPage( LPCDXPAGE pPage, int iKey ) /* * get number of duplicated keys from key in leaf index page */ -static HB_SHORT hb_cdxPageGetKeyTrl( LPCDXPAGE pPage, HB_SHORT iKey ) +static HB_BYTE hb_cdxPageGetKeyTrl( LPCDXPAGE pPage, HB_SHORT iKey ) { #ifdef HB_CDX_DBGCODE_EXT if( iKey < 0 || iKey >= pPage->iKeys ) @@ -1583,7 +1583,7 @@ static HB_SHORT hb_cdxPageGetKeyTrl( LPCDXPAGE pPage, HB_SHORT iKey ) else { HB_BYTE * ptr = &pPage->node.extNode.keyPool[ ( iKey + 1 ) * pPage->ReqByte - 2 ]; - return ( HB_GET_LE_UINT16( ptr ) >> ( 16 - pPage->TCBits ) ) & pPage->TCMask; + return ( HB_BYTE ) ( HB_GET_LE_UINT16( ptr ) >> ( 16 - pPage->TCBits ) ) & pPage->TCMask; } } @@ -3792,7 +3792,7 @@ static int hb_cdxPageSeekKey( LPCDXPAGE pPage, LPCDXKEY pKey, HB_ULONG ulKeyRec n = (l + r ) >> 1; k = hb_cdxValCompare( pPage->TagParent, pKey->val, pKey->len, hb_cdxPageGetKeyVal( pPage, n ), - ( HB_BYTE ) pPage->TagParent->uiLen, pKey->mode ); + pPage->TagParent->uiLen, pKey->mode ); if( k == 0 ) { if( ulKeyRec == CDX_MAX_REC_NUM ) @@ -3840,7 +3840,7 @@ static int hb_cdxPageSeekKey( LPCDXPAGE pPage, LPCDXKEY pKey, HB_ULONG ulKeyRec { k = hb_cdxValCompare( pPage->TagParent, pKey->val, pKey->len, hb_cdxPageGetKeyVal( pPage, pPage->iCurKey ), - ( HB_BYTE ) pPage->TagParent->uiLen, pKey->mode ); + pPage->TagParent->uiLen, pKey->mode ); if( k == 0 && ulKeyRec != CDX_MAX_REC_NUM && ulKeyRec != CDX_IGNORE_REC_NUM ) { @@ -3864,7 +3864,7 @@ static int hb_cdxPageSeekKey( LPCDXPAGE pPage, LPCDXKEY pKey, HB_ULONG ulKeyRec else k = hb_cdxValCompare( pPage->TagParent, pKey->val, pKey->len, hb_cdxPageGetKeyVal( pPage, pPage->iCurKey ), - ( HB_BYTE ) pPage->TagParent->uiLen, pKey->mode ); + pPage->TagParent->uiLen, pKey->mode ); } } else if( k > 0 && fLeaf ) diff --git a/harbour/src/rdd/dbffpt/dbffpt1.c b/harbour/src/rdd/dbffpt/dbffpt1.c index 931df6c7bc..faf04b0ef2 100644 --- a/harbour/src/rdd/dbffpt/dbffpt1.c +++ b/harbour/src/rdd/dbffpt/dbffpt1.c @@ -3730,7 +3730,7 @@ static HB_ERRCODE hb_fptPutVarField( FPTAREAP pArea, HB_USHORT uiIndex, PHB_ITEM if( hb_fptCountSMTDataLength( pArea, &fOffset ) != HB_SUCCESS ) ulOldSize = 0; else - ulOldSize = fOffset - FPT_BLOCK_OFFSET( ulOldBlock ); + ulOldSize = ( HB_ULONG ) ( fOffset - FPT_BLOCK_OFFSET( ulOldBlock ) ); } } } @@ -4494,7 +4494,7 @@ static HB_ERRCODE hb_fptDoPackRec( FPTAREAP pArea ) HB_ERRCODE errCode = HB_SUCCESS; HB_ULONG ulBlock, ulSize, ulType; HB_USHORT uiField; - HB_FOFFSET pos, from; + HB_FOFFSET pos, from, size; HB_TRACE(HB_TR_DEBUG, ("hb_fptDoPackRec(%p)", pArea)); @@ -4558,7 +4558,7 @@ static HB_ERRCODE hb_fptDoPackRec( FPTAREAP pArea ) ulBlock = HB_GET_LE_UINT32( pFieldBuf + pField->uiLen - 6 ); ulType = HB_GET_LE_UINT16( pFieldBuf + pField->uiLen - 2 ); - ulSize = 0; + size = 0; switch( ulType ) { @@ -4569,23 +4569,23 @@ static HB_ERRCODE hb_fptDoPackRec( FPTAREAP pArea ) FPT_BLOCK_OFFSET( ulBlock ) ) != 4 ) errCode = EDBF_READ; else - ulSize = HB_GET_LE_UINT32( buffer ) + 4; + size = HB_GET_LE_UINT32( buffer ) + 4; break; case HB_VF_ARRAY: from = FPT_BLOCK_OFFSET( ulBlock ); errCode = hb_fptCountSMTDataLength( pArea, &from ); - ulSize = from - FPT_BLOCK_OFFSET( ulBlock ); + size = from - FPT_BLOCK_OFFSET( ulBlock ); break; case HB_VF_DNUM: if( pField->uiLen <= 12 ) - ulSize = 11; + size = 11; break; default: if( ulType <= HB_VF_CHAR && ( pField->uiLen - 2 ) < ( int ) ulType ) - ulSize = ulType - ( pField->uiLen - 6 ); + size = ulType - ( pField->uiLen - 6 ); break; } - if( errCode == HB_SUCCESS && ulSize ) + if( errCode == HB_SUCCESS && size ) { /* Buffer is hot? */ if( !pArea->fRecordChanged ) @@ -4599,7 +4599,7 @@ static HB_ERRCODE hb_fptDoPackRec( FPTAREAP pArea ) pos = ( HB_FOFFSET ) ulBlock * ( HB_FOFFSET ) pArea->ulNewBlockSize; errCode = hb_fptCopyToFile( pArea->pMemoFile, from, - pArea->pMemoTmpFile, pos, ulSize ); + pArea->pMemoTmpFile, pos, size ); if( errCode == HB_SUCCESS ) HB_PUT_LE_UINT32( pFieldBuf + pField->uiLen - 6, ulBlock ); } @@ -4640,7 +4640,7 @@ static HB_ERRCODE hb_fptDoPack( FPTAREAP pArea, HB_USHORT uiBlockSize, pArea->pMemoTmpFile = hb_fileCreateTemp( NULL, NULL, FC_NORMAL, szFile ); if( pArea->pMemoTmpFile ) { - HB_USHORT ulMemoBlockSize = pArea->ulMemoBlockSize; + HB_ULONG ulMemoBlockSize = pArea->ulMemoBlockSize; PHB_FILE pFile = pArea->pMemoFile; pArea->ulMemoBlockSize = pArea->ulNewBlockSize; diff --git a/harbour/src/rdd/dbfnsx/dbfnsx1.c b/harbour/src/rdd/dbfnsx/dbfnsx1.c index 36bedeb8d9..d29258b8ea 100644 --- a/harbour/src/rdd/dbfnsx/dbfnsx1.c +++ b/harbour/src/rdd/dbfnsx/dbfnsx1.c @@ -251,7 +251,7 @@ static HB_USHORT hb_nsxLeafGetKey( LPTAGINFO pTag, LPPAGEINFO pPage, HB_USHORT u ucSize = ptr[ uiOffset++ ]; if( ucSize != ucRecLen + 1 ) /* key value is not fully duplicated */ { - HB_UCHAR len = pTag->KeyLength; + HB_UCHAR len = ( HB_UCHAR ) pTag->KeyLength; /* ucSize = 0 is a special case when RecLen is 4 and KeySize is 250 * in such case ucSize - ( ucRecLen + 2 ) gives 250 = NSX_MAXKEYLEN @@ -4191,7 +4191,7 @@ static HB_BOOL hb_nsxOrdKeyGoto( LPTAGINFO pTag, HB_ULONG ulKeyNo ) } else { - pTag->stack[ iLevel ].ikey -= ulKeyNo; + pTag->stack[ iLevel ].ikey -= ( HB_SHORT ) ulKeyNo; ulKeyNo = 0; } } @@ -4247,7 +4247,7 @@ static HB_BOOL hb_nsxOrdKeyGoto( LPTAGINFO pTag, HB_ULONG ulKeyNo ) } else { - pTag->stack[ iLevel ].ikey += ulKeyNo; + pTag->stack[ iLevel ].ikey += ( HB_SHORT ) ulKeyNo; ulKeyNo = 0; } } diff --git a/harbour/src/rdd/sdf1.c b/harbour/src/rdd/sdf1.c index ef099a5ca2..74f11e830a 100644 --- a/harbour/src/rdd/sdf1.c +++ b/harbour/src/rdd/sdf1.c @@ -121,11 +121,12 @@ static HB_ERRCODE hb_sdfReadRecord( SDFAREAP pArea ) pArea->area.fEof = HB_FALSE; pArea->fPositioned = HB_TRUE; uiEolPos = ( HB_USHORT ) hb_strAt( pArea->szEol, pArea->uiEolLen, - ( char * ) pArea->pRecord, uiRead ); + ( const char * ) pArea->pRecord, + uiRead ); if( uiEolPos ) { --uiEolPos; - if( uiRead == pArea->uiRecordLen + pArea->uiEolLen ) + if( uiRead < uiToRead && uiRead == uiEolPos + pArea->uiEolLen ) pArea->nNextOffset = ( HB_FOFFSET ) -1; else pArea->nNextOffset = pArea->nRecordOffset + uiEolPos + pArea->uiEolLen; @@ -176,11 +177,12 @@ static HB_ERRCODE hb_sdfNextRecord( SDFAREAP pArea ) --uiRead; uiEolPos = ( HB_USHORT ) hb_strAt( pArea->szEol, pArea->uiEolLen, - ( char * ) pArea->pRecord, uiRead ); + ( const char * ) pArea->pRecord, + uiRead ); if( uiEolPos ) { --uiEolPos; - if( uiRead == pArea->uiRecordLen + pArea->uiEolLen ) + if( uiRead < uiToRead && uiRead == uiEolPos + pArea->uiEolLen ) pArea->nNextOffset = ( HB_FOFFSET ) -1; else pArea->nNextOffset = ulOffset + uiEolPos + pArea->uiEolLen; diff --git a/harbour/src/rtl/hbsocket.c b/harbour/src/rtl/hbsocket.c index 58de84e2f3..a11d9ca278 100644 --- a/harbour/src/rtl/hbsocket.c +++ b/harbour/src/rtl/hbsocket.c @@ -1436,7 +1436,7 @@ static int hb_socketSelectRD( HB_SOCKET sd, HB_MAXINT timeout ) if( timeout >= 0 ) { tv.tv_sec = ( long ) ( timeout / 1000 ); - tv.tv_usec = ( timeout % 1000 ) * 1000; + tv.tv_usec = ( long ) ( timeout % 1000 ) * 1000; ptv = &tv; } else @@ -1484,7 +1484,7 @@ static int hb_socketSelectWR( HB_SOCKET sd, HB_MAXINT timeout ) if( timeout >= 0 ) { tv.tv_sec = ( long ) ( timeout / 1000 ); - tv.tv_usec = ( timeout % 1000 ) * 1000; + tv.tv_usec = ( long ) ( timeout % 1000 ) * 1000; ptv = &tv; } else @@ -1541,7 +1541,7 @@ static int hb_socketSelectWRE( HB_SOCKET sd, HB_MAXINT timeout ) if( timeout >= 0 ) { tv.tv_sec = ( long ) ( timeout / 1000 ); - tv.tv_usec = ( timeout % 1000 ) * 1000; + tv.tv_usec = ( long ) ( timeout % 1000 ) * 1000; ptv = &tv; } else @@ -2628,7 +2628,7 @@ int hb_socketSelect( PHB_ITEM pArrayRD, HB_BOOL fSetRD, if( timeout >= 0 ) { tv.tv_sec = ( long ) ( timeout / 1000 ); - tv.tv_usec = ( timeout % 1000 ) * 1000; + tv.tv_usec = ( long ) ( timeout % 1000 ) * 1000; ptv = &tv; } else diff --git a/harbour/utils/Makefile b/harbour/utils/Makefile index 0c408fbfa4..c203c93086 100644 --- a/harbour/utils/Makefile +++ b/harbour/utils/Makefile @@ -16,6 +16,7 @@ ifneq ($(HB_BUILD_PARTS),compiler) hbi18n \ hbtest \ hbformat \ + $(__HB_UTIL_ADDONS) endif