From 0469427295216e36acf16114c62c53c362f2f4e5 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 1 Feb 2011 02:34:25 +0000 Subject: [PATCH] 2011-02-01 03:34 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/vm/hashfunc.c * harbour/src/vm/hashes.c * moved HB_HASH_RESORT setting to avoid potential problems when some 3-rd party code didn't set it correctly. * harbour/src/rtl/itemseri.c ! fixed restoring hash arrays with strict order - they were not resorted --- harbour/ChangeLog | 9 +++++++++ harbour/src/rtl/itemseri.c | 8 ++++---- harbour/src/vm/hashes.c | 2 ++ harbour/src/vm/hashfunc.c | 6 +++--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b42ac8e905..e487138464 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,15 @@ The license applies to all entries newer than 2009-04-28. */ +2011-02-01 03:34 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/src/vm/hashfunc.c + * harbour/src/vm/hashes.c + * moved HB_HASH_RESORT setting to avoid potential problems when some + 3-rd party code didn't set it correctly. + + * harbour/src/rtl/itemseri.c + ! fixed restoring hash arrays with strict order - they were not resorted + 2011-02-01 01:56 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbnetio/utils/hbnetio/netiosrv.prg * contrib/hbnetio/utils/hbnetio/netiocon.prg diff --git a/harbour/src/rtl/itemseri.c b/harbour/src/rtl/itemseri.c index 004f67420d..8de33def93 100644 --- a/harbour/src/rtl/itemseri.c +++ b/harbour/src/rtl/itemseri.c @@ -1057,9 +1057,9 @@ static HB_SIZE hb_deserializeItem( PHB_ITEM pItem, { int iFlags = HB_GET_LE_UINT16( &pBuffer[ nOffset ] ); nOffset = hb_deserializeItem( pItem, cdpIn, cdpOut, pBuffer, - nOffset + 2, pRef ); + nOffset + 2, pRef ); hb_hashClearFlags( pItem, HB_HASH_FLAG_MASK ); - if( ( iFlags & HB_HASH_BINARY ) == 0 ) + if( ( iFlags & ( HB_HASH_KEEPORDER | HB_HASH_BINARY ) ) != HB_HASH_BINARY ) iFlags |= HB_HASH_RESORT; hb_hashSetFlags( pItem, iFlags ); break; @@ -1069,9 +1069,9 @@ static HB_SIZE hb_deserializeItem( PHB_ITEM pItem, { PHB_ITEM pDefVal = hb_itemNew( NULL ); nOffset = hb_deserializeItem( pDefVal, cdpIn, cdpOut, pBuffer, - nOffset, pRef ); + nOffset, pRef ); nOffset = hb_deserializeItem( pItem, cdpIn, cdpOut, pBuffer, - nOffset, pRef ); + nOffset, pRef ); hb_hashSetDefault( pItem, pDefVal ); hb_itemRelease( pDefVal ); break; diff --git a/harbour/src/vm/hashes.c b/harbour/src/vm/hashes.c index aba9865b2e..b38ae2b94e 100644 --- a/harbour/src/vm/hashes.c +++ b/harbour/src/vm/hashes.c @@ -1092,6 +1092,8 @@ void hb_hashClearFlags( PHB_ITEM pHash, int iFlags ) { hb_xfree( pHash->item.asHash.value->pnPos ); pHash->item.asHash.value->pnPos = NULL; + if( pHash->item.asHash.value->nSize ) + pHash->item.asHash.value->iFlags |= HB_HASH_RESORT; } } } diff --git a/harbour/src/vm/hashfunc.c b/harbour/src/vm/hashfunc.c index d9968a709f..6b53c5c5ad 100644 --- a/harbour/src/vm/hashfunc.c +++ b/harbour/src/vm/hashfunc.c @@ -752,10 +752,10 @@ HB_FUNC( HB_HKEEPORDER ) if( ( iFlags & HB_HASH_KEEPORDER ) == 0 ) hb_hashSetFlags( pHash, HB_HASH_KEEPORDER ); } - else if( ( iFlags & HB_HASH_KEEPORDER ) != 0 ) + else { - hb_hashClearFlags( pHash, HB_HASH_KEEPORDER ); - hb_hashSetFlags( pHash, HB_HASH_RESORT ); + if( ( iFlags & HB_HASH_KEEPORDER ) != 0 ) + hb_hashClearFlags( pHash, HB_HASH_KEEPORDER ); } } }