From dd2ee1d1a58fc841a8c8d076c9d147526f7da570 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 19 May 2010 23:42:29 +0000 Subject: [PATCH] 2010-05-20 01:42 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbapi.h * harbour/src/vm/hashes.c + added new C function hb_hashGetCItemPos() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * harbour/src/rtl/hbcom.c ! fixed typo located by Bisz István --- harbour/ChangeLog | 8 ++++++++ harbour/include/hbapi.h | 1 + harbour/src/rtl/hbcom.c | 2 +- harbour/src/vm/hashes.c | 31 ++++++++++++++++++++++++++++--- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index bf8874167c..72113c852c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,14 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-05-20 01:42 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbapi.h + * harbour/src/vm/hashes.c + + added new C function hb_hashGetCItemPos() + + * harbour/src/rtl/hbcom.c + ! fixed typo located by Bisz István + 2010-05-19 10:35 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.pt_BR.po * utils/hbmk2/hbmk2.hu_HU.po diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index 6bd32113bf..08fbcfe8e2 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -869,6 +869,7 @@ extern HB_EXPORT void * hb_hashId( PHB_ITEM pHash ); /* retrieves the hash un extern HB_EXPORT PHB_ITEM hb_hashGetItemPtr( PHB_ITEM pHash, PHB_ITEM pKey, int iFlags ); extern HB_EXPORT PHB_ITEM hb_hashGetItemRefPtr( PHB_ITEM pHash, PHB_ITEM pKey ); extern HB_EXPORT PHB_ITEM hb_hashGetCItemPtr( PHB_ITEM pHash, const char * pszKey ); +extern HB_EXPORT HB_SIZE hb_hashGetCItemPos( PHB_ITEM pHash, const char * pszKey ); extern HB_EXPORT PHB_ITEM hb_hashGetKeyAt( PHB_ITEM pHash, HB_SIZE ulPos ); extern HB_EXPORT PHB_ITEM hb_hashGetValueAt( PHB_ITEM pHash, HB_SIZE ulPos ); diff --git a/harbour/src/rtl/hbcom.c b/harbour/src/rtl/hbcom.c index ab44955f75..b62b9bca45 100644 --- a/harbour/src/rtl/hbcom.c +++ b/harbour/src/rtl/hbcom.c @@ -716,7 +716,7 @@ int hb_comFlowControl( int iPort, int *piFlow, int iFlow ) if( iFlow >= 0 ) { if( iFlow & HB_COM_FLOW_DCD ) - tio.c_cflag &= CLOCAL; + tio.c_cflag &= ~CLOCAL; else tio.c_cflag |= CLOCAL; } diff --git a/harbour/src/vm/hashes.c b/harbour/src/vm/hashes.c index ba7cd2cd6c..b9d2b2d1d2 100644 --- a/harbour/src/vm/hashes.c +++ b/harbour/src/vm/hashes.c @@ -495,6 +495,30 @@ PHB_ITEM hb_hashGetCItemPtr( PHB_ITEM pHash, const char * pszKey ) return NULL; } +HB_SIZE hb_hashGetCItemPos( PHB_ITEM pHash, const char * pszKey ) +{ + HB_SIZE ulPos = 0; + + HB_TRACE(HB_TR_DEBUG, ("hb_hashGetCItemPos(%p,%s)", pHash, pszKey)); + + if( HB_IS_HASH( pHash ) ) + { + HB_STACK_TLS_PRELOAD + /* we will not make any copy of pKey (autoadd is disabled) so it's + * safe to use hb_itemPutCConst() + */ + PHB_ITEM pKey = hb_itemPutCConst( hb_stackAllocItem(), pszKey ); + + if( hb_hashFind( pHash->item.asHash.value, pKey, &ulPos ) ) + ulPos++; + else + ulPos = 0; + hb_stackPop(); + } + + return ulPos; +} + PHB_ITEM hb_hashGetItemRefPtr( PHB_ITEM pHash, PHB_ITEM pKey ) { HB_TRACE(HB_TR_DEBUG, ("hb_hashGetItemRefPtr(%p,%p)", pHash, pKey)); @@ -705,9 +729,10 @@ PHB_ITEM hb_hashGetValueAt( PHB_ITEM pHash, HB_SIZE ulPos ) HB_TRACE(HB_TR_DEBUG, ("hb_hashGetValueAt(%p,%lu)", pHash, ulPos)); if( HB_IS_HASH( pHash ) && ulPos > 0 && ulPos <= pHash->item.asHash.value->ulLen ) - return HB_IS_BYREF( &pHash->item.asHash.value->pPairs[ ulPos - 1 ].value ) ? - hb_itemUnRef( &pHash->item.asHash.value->pPairs[ ulPos - 1 ].value ) : - &pHash->item.asHash.value->pPairs[ ulPos - 1 ].value; + { + PHB_ITEM pValue = &pHash->item.asHash.value->pPairs[ ulPos - 1 ].value; + return HB_IS_BYREF( pValue ) ? hb_itemUnRef( pValue ) : pValue; + } else return NULL; }