diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c02b43e6b7..4e8d729118 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,15 @@ +2000-07-12 10:25 UTC+0100 Ryszard Glab + + *source/common/hash.c + * items can be removed from the hash table + + *source/compiler/harbour.l + * fixed handling of 'with()' and '( with )' syntax + + *tests/keywords.prg + * updated with few additional tests + + 2000-07-12 08:46 UTC+0100 Victor Szakats * doc/whatsnew.txt diff --git a/harbour/source/common/hash.c b/harbour/source/common/hash.c index 50f126c102..b91235b6be 100644 --- a/harbour/source/common/hash.c +++ b/harbour/source/common/hash.c @@ -4,7 +4,7 @@ /* * Harbour Project source code: - * Harbour common hash table implementation + * Harbour simple hash table implementation * * Copyright 1999 Ryszard Glab * www - http://www.harbour-project.org @@ -35,6 +35,10 @@ #include "hbhash.h" +/* TODO: + * 1) add resize function + * 2) add better method of conflicts resolving +*/ static HB_HASH_ITEM_PTR hb_hashItemNew( ULONG ulKey, void * pValue ) { HB_HASH_ITEM_PTR pItem = (HB_HASH_ITEM_PTR) hb_xgrab( sizeof( HB_HASH_ITEM ) ); @@ -46,6 +50,11 @@ static HB_HASH_ITEM_PTR hb_hashItemNew( ULONG ulKey, void * pValue ) return pItem; } +static void hb_hashItemDelete( HB_HASH_ITEM_PTR pItem ) +{ + hb_xfree( (void *) pItem ); +} + /* create a new hash table * ulSize = initial numer of items in the table * pHashTable = a function that calculates a hash key value @@ -144,6 +153,41 @@ void * hb_hashTableFind( HB_HASH_TABLE_PTR pTable, void *pValue ) return pFound; } +/* Delete an item from the table +* Returns TRUE if item was found and returns FALSE when passed item +* is not stored in the table +*/ +BOOL hb_hashTableDel( HB_HASH_TABLE_PTR pTable, void *pValue ) +{ + ULONG ulKey; + HB_HASH_ITEM_PTR pItem; + HB_HASH_ITEM_PTR pPrev = NULL; + BOOL bFound = FALSE; + + ulKey = ( pTable->pKeyFunc )( pValue, NULL ); + pItem = pTable->pItems[ ulKey ]; + while( pItem && !bFound ) + { + if( ( pTable->pCompFunc )( pItem->cargo, pValue ) == 0 ) + { + if( pPrev ) + pPrev->next = pItem->next; + else + pTable->pItems[ ulKey ] = pItem->next; + + hb_hashItemDelete( pItem ); + bFound = TRUE; + } + else + { + pPrev = pItem; + pItem = pItem->next; + } + } + + return bFound; +} + /* return the hash table size */ ULONG hb_hashTableBucket( HB_HASH_TABLE_PTR pTable ) { diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index ca04e6a1c8..be9be1c44f 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -1527,6 +1527,13 @@ Separator {SpaceTab} return WITH; } } +{Separator}*[\)\(] { /* ( with ) or with() */ + if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; + unput( yytext[ yyleng-1 ] ); + hb_comp_iState =IDENTIFIER; + yylval.string = hb_compIdentifierNew( "WITH", TRUE ); + return IDENTIFIER; + } {Separator}*[\[] { /* array */ /* Clipper does not like with[] at all */ hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, yytext, NULL );