diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 36a6d6a267..9e9806d7f4 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,23 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ + + * harbour/source/vm/runner.c + * synced with xHarbour + + * harbour/utils/hbtest/rt_misc.prg + * added overloading "=" operator. Now "==" and "=" can be overloaded + with different methods + + All names I used for new functions/macros can be changed. Please look at + it and if you will some better propositions then we can use it. + hb_vmProcessSymbolsExt() is added but not used yet. + +2006-06-07 16:35 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbrddcdx.h + * harbour/include/hbrdddbf.h + * harbour/source/rdd/dbcmd.c + * harbour/source/rdd/delim1.c * harbour/source/rdd/dbffpt/dbffpt1.c * cleaned // comments and some compiler warnings diff --git a/harbour/include/dbinfo.ch b/harbour/include/dbinfo.ch index e3864160c3..0eff1c723b 100644 --- a/harbour/include/dbinfo.ch +++ b/harbour/include/dbinfo.ch @@ -316,8 +316,8 @@ #define FILEPUT_ENCRYPT BLOB_IMPORT_ENCRYPT /* DBF TYPES */ -#define DB_DBF_STD 0 -#define DB_DBF_VFP 1 +#define DB_DBF_STD 1 +#define DB_DBF_VFP 2 /* MEMO TYPES */ #define DB_MEMO_NONE 0 diff --git a/harbour/include/hbrddcdx.h b/harbour/include/hbrddcdx.h index 44427ee1fa..5c25def770 100644 --- a/harbour/include/hbrddcdx.h +++ b/harbour/include/hbrddcdx.h @@ -74,8 +74,8 @@ HB_EXTERN_BEGIN #define CDX_EXT_FREESPACE (CDX_PAGELEN-24) /* 488 */ #define CDX_DUMMYNODE 0xFFFFFFFFL -//#define CDX_LOCKOFFSET 0x7FFFFFFEL -//#define CDX_LOCKSIZE 1L +/* #define CDX_LOCKOFFSET 0x7FFFFFFEL */ +/* #define CDX_LOCKSIZE 1L */ #define CDX_STACKSIZE 64 #define CDX_PAGECACHESIZE 8 #define CDX_NODE_BRANCH 0 @@ -349,7 +349,7 @@ typedef struct _CDXTAG struct _CDXINDEX * pIndex; /* a parent index info */ struct _CDXTAG * pNext; /* pointer to next tag in index */ - //CDXSTACK PageStack[ CDX_STACKSIZE ]; /* stack with page path to current key */ + /* CDXSTACK PageStack[ CDX_STACKSIZE ]; */ /* stack with page path to current key */ LPCDXPAGE RootPage; /* pointer to root of keys tree in memory */ LPCDXKEY CurKey; /* current value of key expression */ LPCDXKEY HotKey; /* value of hot key expression */ diff --git a/harbour/include/hbrdddbf.h b/harbour/include/hbrdddbf.h index 5de03c5f88..c4575e9709 100644 --- a/harbour/include/hbrdddbf.h +++ b/harbour/include/hbrdddbf.h @@ -113,12 +113,12 @@ typedef struct _DBFDATA char szIndexExt[ HB_MAX_FILE_EXT + 1 ]; char szMemoExt[ HB_MAX_FILE_EXT + 1 ]; - BYTE bLockType; //= 0; - BYTE bTableType; //= DB_DBF_STD; - BYTE bCryptType; //= DB_CRYPT_NONE; - BYTE bMemoType; // = DB_MEMO_FPT; - BYTE bMemoExtType;// = DB_MEMOVER_FLEX; - USHORT uiMemoBlockSize; // = 0; + BYTE bLockType; /* 0 */ + BYTE bTableType; /* DB_DBF_STD */ + BYTE bCryptType; /* DB_CRYPT_NONE */ + BYTE bMemoType; /* DB_MEMO_FPT */ + BYTE bMemoExtType; /* DB_MEMOVER_FLEX */ + USHORT uiMemoBlockSize; /* 0 */ } DBFDATA; typedef DBFDATA * LPDBFDATA; diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index 5df5397fd4..00168b8474 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -133,7 +133,7 @@ static BOOL s_bNetError = FALSE; /* Error on Networked environments */ } while ( 0 ); #define HB_GET_WA( n ) ( ( (n) < s_uiWaNumMax ) ? s_WaList[ s_WaNums[ ( n ) ] ] : NULL ) -//#define HB_CURRENT_WA HB_GET_WA( s_uiCurrArea ) +/* #define HB_CURRENT_WA HB_GET_WA( s_uiCurrArea ) */ #define HB_CURRENT_WA s_pCurrArea /* @@ -4083,7 +4083,7 @@ HB_FUNC( DBEXISTS ) szDriver = hb_rddDefaultDrv( NULL ); } - pRDDNode = hb_rddFindNode( szDriver, &uiRddID ); // find the RDD + pRDDNode = hb_rddFindNode( szDriver, &uiRddID ); /* find the RDD */ if ( !pRDDNode ) { @@ -4457,14 +4457,11 @@ HB_FUNC( __DBTRANS ) if( pSrcArea && pDstArea ) { DBTRANSINFO dbTransInfo; - ERRCODE errCode; PHB_ITEM pFields = hb_param( 2, HB_IT_ARRAY ); memset( &dbTransInfo, 0, sizeof( DBTRANSINFO ) ); - errCode = hb_dbTransStruct( pSrcArea, pDstArea, &dbTransInfo, - NULL, pFields ); - - if( errCode == SUCCESS ) + if( hb_dbTransStruct( pSrcArea, pDstArea, &dbTransInfo, + NULL, pFields ) == SUCCESS ) { hb_rddSelectWorkAreaNumber( dbTransInfo.lpaSource->uiArea ); @@ -4482,7 +4479,7 @@ HB_FUNC( __DBTRANS ) dbTransInfo.dbsci.fIgnoreDuplicates = FALSE; dbTransInfo.dbsci.fBackward = FALSE; - errCode = SELF_TRANS( dbTransInfo.lpaSource, &dbTransInfo ); + SELF_TRANS( dbTransInfo.lpaSource, &dbTransInfo ); } if( dbTransInfo.lpTransItems ) @@ -4651,7 +4648,7 @@ HB_FUNC( DBSKIPPER ) -// Escaping delimited strings. Need to be cleaned/optimized/improved +/* Escaping delimited strings. Need to be cleaned/optimized/improved */ static char *hb_strescape( char *szInput, int lLen, char *cDelim ) { int lCnt = 0; @@ -4681,7 +4678,7 @@ static char *hb_strescape( char *szInput, int lLen, char *cDelim ) return szReturn; } -// Export field values to text file +/* Export field values to text file */ #ifndef HB_CDP_SUPPORT_OFF static BOOL hb_ExportVar( int handle, PHB_ITEM pValue, char *cDelim, PHB_CODEPAGE cdp ) #else @@ -4690,7 +4687,7 @@ static BOOL hb_ExportVar( int handle, PHB_ITEM pValue, char *cDelim ) { switch( hb_itemType( pValue ) ) { - // a "C" field + /* a "C" field */ case HB_IT_STRING: { char *szStrEsc; @@ -4706,15 +4703,15 @@ static BOOL hb_ExportVar( int handle, PHB_ITEM pValue, char *cDelim ) #endif szString = hb_xstrcpy( NULL,cDelim,szStrEsc,cDelim,NULL); - // FWrite( handle, szString ) + /* FWrite( handle, szString ) */ hb_fsWriteLarge( handle, (BYTE*) szString, strlen( szString ) ); - // Orphaned, get rif off it + /* Orphaned, get rif off it */ hb_xfree( szStrEsc ); hb_xfree( szString ); break; } - // a "D" field + /* a "D" field */ case HB_IT_DATE: { char *szDate = (char*) hb_xgrab( 9 ); @@ -4724,13 +4721,13 @@ static BOOL hb_ExportVar( int handle, PHB_ITEM pValue, char *cDelim ) hb_xfree( szDate ); break; } - // an "L" field + /* an "L" field */ case HB_IT_LOGICAL: { hb_fsWriteLarge( handle, (BYTE*) ( hb_itemGetL( pValue ) ? "T" : "F" ), 1 ); break; } - // an "N" field + /* an "N" field */ case HB_IT_INTEGER: case HB_IT_LONG: case HB_IT_DOUBLE: @@ -4747,9 +4744,9 @@ static BOOL hb_ExportVar( int handle, PHB_ITEM pValue, char *cDelim ) } break; } - // an "M" field or the other, might be a "V" in SixDriver + /* an "M" field or the other, might be a "V" in SixDriver */ default: - // We do not want MEMO contents + /* We do not want MEMO contents */ return FALSE; } return TRUE; @@ -4773,7 +4770,7 @@ HB_FUNC( DBF2TEXT ) AREAP pArea = HB_CURRENT_WA; - // Export DBF content to text file + /* Export DBF content to text file */ int iSepLen; USHORT uiFields = 0; @@ -4826,7 +4823,7 @@ HB_FUNC( DBF2TEXT ) while( ( nCount == -1 || nCount > 0 ) && ( !pWhile || hb_itemGetL( hb_vmEvalBlock( pWhile ) ) ) ) { - // While !BOF() .AND. !EOF() + /* While !BOF() .AND. !EOF() */ SELF_EOF( pArea, &bEof ); SELF_BOF( pArea, &bBof ); @@ -4835,11 +4832,11 @@ HB_FUNC( DBF2TEXT ) break; } - // For condition is met - // if For is NULL, hb__Eval returns TRUE + /* For condition is met */ + /* if For is NULL, hb__Eval returns TRUE */ if( !pFor || hb_itemGetL( hb_vmEvalBlock( pFor ) ) ) { - // User does not request fields, copy all fields + /* User does not request fields, copy all fields */ if( bNoFieldPassed ) { for ( ui = 1; ui <= uiFields; ui ++ ) @@ -4858,7 +4855,7 @@ HB_FUNC( DBF2TEXT ) hb_itemClear( pTmp ); } } - // Only requested fields are exported here + /* Only requested fields are exported here */ else { USHORT uiFieldCopy = ( USHORT ) hb_arrayLen( pFields ); @@ -4897,11 +4894,11 @@ HB_FUNC( DBF2TEXT ) nCount-- ; } - // DBSKIP() + /* DBSKIP() */ SELF_SKIP( pArea, 1 ); } - // Writing EOF + /* Writing EOF */ hb_fsWriteLarge( handle, (BYTE*) "\x1A", 1 ); hb_itemRelease( pTmp ); } diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index d2e896d796..75295e93b0 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -50,7 +50,6 @@ * */ -#include "hbsetup.h" #include "hbapi.h" #include "hbinit.h" #include "hbvm.h" @@ -2116,49 +2115,6 @@ static ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ) fRawBlob = SELF_RDDINFO( SELF_RDDNODE( pArea ), RDDI_BLOB_SUPPORT, 0, pItem ) == SUCCESS && hb_itemGetL( pItem ); - if( !fRawBlob ) - { - pError = NULL; - /* Try create */ - do - { - pArea->hDataFile = hb_fsExtOpen( szFileName, NULL, - FO_READWRITE | FO_EXCLUSIVE | FXO_TRUNCATE | - FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME, - NULL, pError ); - if( pArea->hDataFile == FS_ERROR ) - { - if( !pError ) - { - pError = hb_errNew(); - hb_errPutGenCode( pError, EG_CREATE ); - hb_errPutSubCode( pError, EDBF_CREATE_DBF ); - hb_errPutOsCode( pError, hb_fsError() ); - hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_CREATE ) ); - hb_errPutFileName( pError, ( char * ) szFileName ); - hb_errPutFlags( pError, EF_CANRETRY | EF_CANDEFAULT ); - } - fRetry = ( SELF_ERROR( ( AREAP ) pArea, pError ) == E_RETRY ); - } - else - fRetry = FALSE; - } while( fRetry ); - - if( pError ) - { - hb_itemRelease( pError ); - } - - if( pArea->hDataFile == FS_ERROR ) - { - if( pItem ) - hb_itemRelease( pItem ); - return FAILURE; - } - } - - pArea->szDataFileName = hb_strdup( ( char * ) szFileName ); - if( pArea->bTableType == 0 ) { pItem = hb_itemPutNI( pItem, 0 ); @@ -2208,6 +2164,47 @@ static ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ) hb_itemRelease( pItem ); } + if( !fRawBlob ) + { + pError = NULL; + /* Try create */ + do + { + pArea->hDataFile = hb_fsExtOpen( szFileName, NULL, + FO_READWRITE | FO_EXCLUSIVE | FXO_TRUNCATE | + FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME, + NULL, pError ); + if( pArea->hDataFile == FS_ERROR ) + { + if( !pError ) + { + pError = hb_errNew(); + hb_errPutGenCode( pError, EG_CREATE ); + hb_errPutSubCode( pError, EDBF_CREATE_DBF ); + hb_errPutOsCode( pError, hb_fsError() ); + hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_CREATE ) ); + hb_errPutFileName( pError, ( char * ) szFileName ); + hb_errPutFlags( pError, EF_CANRETRY | EF_CANDEFAULT ); + } + fRetry = ( SELF_ERROR( ( AREAP ) pArea, pError ) == E_RETRY ); + } + else + fRetry = FALSE; + } while( fRetry ); + + if( pError ) + { + hb_itemRelease( pError ); + } + + if( pArea->hDataFile == FS_ERROR ) + { + return FAILURE; + } + } + + pArea->szDataFileName = hb_strdup( ( char * ) szFileName ); + uiSize = pArea->uiFieldCount * sizeof( DBFFIELD ); if( pArea->uiFieldCount ) { @@ -4418,6 +4415,7 @@ static ERRCODE hb_dbfRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P case DB_DBF_VFP: /* VFP DBF file */ pData->bTableType = iType; } + break; } case RDDI_LOCKSCHEME: { diff --git a/harbour/source/rdd/dbffpt/dbffpt1.c b/harbour/source/rdd/dbffpt/dbffpt1.c index 609ec713c2..fd25b7271c 100644 --- a/harbour/source/rdd/dbffpt/dbffpt1.c +++ b/harbour/source/rdd/dbffpt/dbffpt1.c @@ -1150,10 +1150,11 @@ static char * hb_fptGetMemoType( FPTAREAP pArea, USHORT uiIndex ) return "M"; case FPTIT_SIX_ARRAY: return "A"; -// case FPTIT_SIX_BLOCK: -// case FPTIT_SIX_VREF: -// case FPTIT_SIX_MREF: - +/* + case FPTIT_SIX_BLOCK: + case FPTIT_SIX_VREF: + case FPTIT_SIX_MREF: +*/ case FPTIT_FLEX_ARRAY: case FPTIT_FLEX_VOARR: return "A"; @@ -1220,7 +1221,7 @@ static ULONG hb_fptCountSMTItemLength( FPTAREAP pArea, PHB_ITEM pItem, switch( hb_itemType( pItem ) ) { - case HB_IT_ARRAY: // HB_IT_OBJECT = HB_IT_ARRAY + case HB_IT_ARRAY: /* HB_IT_OBJECT == HB_IT_ARRAY */ (*pulArrayCount)++; ulSize = 3; ulLen = hb_arrayLen( pItem ); @@ -1626,7 +1627,7 @@ static ULONG hb_fptCountSixItemLength( FPTAREAP pArea, PHB_ITEM pItem, switch ( hb_itemType( pItem ) ) { - case HB_IT_ARRAY: // HB_IT_OBJECT = HB_IT_ARRAY + case HB_IT_ARRAY: /* HB_IT_OBJECT == HB_IT_ARRAY */ (*pulArrayCount)++; ulSize = SIX_ITEM_BUFSIZE; ulLen = hb_arrayLen( pItem ); @@ -1678,7 +1679,7 @@ static ULONG hb_fptStoreSixItem( FPTAREAP pArea, PHB_ITEM pItem, BYTE ** bBufPtr ulSize = SIX_ITEM_BUFSIZE; switch ( hb_itemType( pItem ) ) { - case HB_IT_ARRAY: // HB_IT_OBJECT = HB_IT_ARRAY + case HB_IT_ARRAY: /* HB_IT_OBJECT == HB_IT_ARRAY */ HB_PUT_LE_UINT16( &(*bBufPtr)[0], FPTIT_SIX_ARRAY ); ulLen = hb_arrayLen( pItem ); if ( pArea->uiMemoVersion == DB_MEMOVER_SIX ) @@ -1820,11 +1821,11 @@ static ERRCODE hb_fptReadSixItem( FPTAREAP pArea, BYTE ** pbMemoBuf, BYTE * bBuf errCode = EDBF_CORRUPT; } break; - -// case FPTIT_SIX_BLOCK: -// case FPTIT_SIX_VREF: -// case FPTIT_SIX_MREF: - +/* + case FPTIT_SIX_BLOCK: + case FPTIT_SIX_VREF: + case FPTIT_SIX_MREF: +*/ case FPTIT_SIX_ARRAY: ulLen = HB_GET_LE_UINT32( &(*pbMemoBuf)[2] ); if ( pArea->uiMemoVersion == DB_MEMOVER_SIX ) @@ -2683,9 +2684,11 @@ static ERRCODE hb_fptGetMemo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem, case FPTIT_SIX_LOG: case FPTIT_SIX_CHAR: case FPTIT_SIX_ARRAY: -// case FPTIT_SIX_BLOCK: -// case FPTIT_SIX_VREF: -// case FPTIT_SIX_MREF: +/* + case FPTIT_SIX_BLOCK: + case FPTIT_SIX_VREF: + case FPTIT_SIX_MREF: +*/ bMemoBuf = pBuffer; errCode = hb_fptReadSixItem( pArea, &bMemoBuf, bMemoBuf + ulSize, pItem ); break; diff --git a/harbour/source/rdd/delim1.c b/harbour/source/rdd/delim1.c index 4bf737baba..6e024a25b7 100644 --- a/harbour/source/rdd/delim1.c +++ b/harbour/source/rdd/delim1.c @@ -250,7 +250,7 @@ static ERRCODE hb_delimReadRecord( DELIMAREAP pArea ) HB_TRACE(HB_TR_DEBUG, ("hb_delimReadRecord(%p)", pArea)); if( pArea->ulBufferStart <= pArea->ulRecordOffset && - pArea->ulBufferStart + pArea->ulBufferRead > pArea->ulRecordOffset ) + pArea->ulBufferStart + ( HB_FOFFSET ) pArea->ulBufferRead > pArea->ulRecordOffset ) { pArea->ulBufferIndex = pArea->ulRecordOffset - pArea->ulBufferStart; } @@ -355,7 +355,8 @@ static ERRCODE hb_delimReadRecord( DELIMAREAP pArea ) ch = hb_delimNextChar( pArea ); if( ch == -2 && - pArea->ulRecordOffset == pArea->ulBufferStart + pArea->ulBufferIndex ) + pArea->ulRecordOffset == ( HB_FOFFSET ) ( pArea->ulBufferStart + + pArea->ulBufferIndex ) ) { pArea->fEof = TRUE; pArea->fPositioned = FALSE; diff --git a/harbour/source/vm/arrays.c b/harbour/source/vm/arrays.c index b010cad529..a61286a1aa 100644 --- a/harbour/source/vm/arrays.c +++ b/harbour/source/vm/arrays.c @@ -243,8 +243,16 @@ HB_EXPORT BOOL hb_arrayDel( PHB_ITEM pArray, ULONG ulIndex ) { PHB_BASEARRAY pBaseArray = pArray->item.asArray.value; - for( ; ulIndex < ulLen; ++ulIndex ) /* move items */ - hb_itemMove( pBaseArray->pItems + ulIndex - 1, pBaseArray->pItems + ulIndex ); + if( ulIndex == ulLen ) + { + hb_itemClear( pBaseArray->pItems + ulIndex - 1 ); + } + else + { + for( ; ulIndex < ulLen; ++ulIndex ) /* move items */ + hb_itemMove( pBaseArray->pItems + ulIndex - 1, + pBaseArray->pItems + ulIndex ); + } } return TRUE; @@ -265,12 +273,16 @@ HB_EXPORT BOOL hb_arrayIns( PHB_ITEM pArray, ULONG ulIndex ) { PHB_BASEARRAY pBaseArray = pArray->item.asArray.value; - hb_itemClear( pBaseArray->pItems + ( ulLen - 1 ) ); - - for( ulLen--; ulLen >= ulIndex; ulLen-- ) /* move items */ - hb_itemCopy( pBaseArray->pItems + ulLen, pBaseArray->pItems + ( ulLen - 1 ) ); - - hb_itemClear( pBaseArray->pItems + ulLen ); + if( ulIndex == ulLen ) + { + hb_itemClear( pBaseArray->pItems + ulIndex - 1 ); + } + else + { + while( --ulLen >= ulIndex ) /* move items */ + hb_itemMove( pBaseArray->pItems + ulLen, + pBaseArray->pItems + ulLen - 1 ); + } } return TRUE;