From dafaea3cbe728d469639ff5be2b8cddcac3f22ae Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Sat, 6 Oct 2007 11:56:02 +0000 Subject: [PATCH] 2007-10-06 13:55 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/vm/hashes.c * set AUTOADD for assign operation by default in new arrays * removed last HB_COMPAT_XHB * harbour/source/vm/hashfunc.c * change HB_HAUTOADD( hHash, .T. ) to set AUTOADD for assign only when no default value is set Above are minimal modifications to make default Harbour behavior more similar to other languages f.e. PHP or xHarbour. Other modifications will depend on group decision. --- harbour/ChangeLog | 13 +++++++++++++ harbour/source/vm/hashes.c | 4 ---- harbour/source/vm/hashfunc.c | 3 ++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2acff06295..b68b74b743 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,19 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-10-06 13:55 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/vm/hashes.c + * set AUTOADD for assign operation by default in new arrays + * removed last HB_COMPAT_XHB + + * harbour/source/vm/hashfunc.c + * change HB_HAUTOADD( hHash, .T. ) to set AUTOADD for assign only + when no default value is set + + Above are minimal modifications to make default Harbour behavior + more similar to other languages f.e. PHP or xHarbour. Other + modifications will depend on group decision. + 2007-10-06 12:45 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbsetup.h * harbour/source/rtl/hbffind.c diff --git a/harbour/source/vm/hashes.c b/harbour/source/vm/hashes.c index 633f7a4fe5..3ecf693ec4 100644 --- a/harbour/source/vm/hashes.c +++ b/harbour/source/vm/hashes.c @@ -318,11 +318,7 @@ HB_EXPORT PHB_ITEM hb_hashNew( PHB_ITEM pItem ) pBaseHash->pPairs = NULL; pBaseHash->ulSize = 0; pBaseHash->ulLen = 0; -#ifdef HB_COMPAT_XHB pBaseHash->iFlags = HB_HASH_AUTOADD_ASSIGN; -#else - pBaseHash->iFlags = HB_HASH_AUTOADD_NEVER; -#endif pBaseHash->pDefault = NULL; pItem->type = HB_IT_HASH; diff --git a/harbour/source/vm/hashfunc.c b/harbour/source/vm/hashfunc.c index c437cf7de5..44d542fab2 100644 --- a/harbour/source/vm/hashfunc.c +++ b/harbour/source/vm/hashfunc.c @@ -631,7 +631,8 @@ HB_FUNC( HB_HAUTOADD ) if( HB_IS_LOGICAL( pValue ) ) { if( hb_itemGetL( pValue ) ) - hb_hashSetFlags( pHash, HB_HASH_AUTOADD_ALWAYS ); + hb_hashSetFlags( pHash, hb_hashGetDefault( pHash ) ? + HB_HASH_AUTOADD_ALWAYS : HB_HASH_AUTOADD_ASSIGN ); else if( iOldFlags ) hb_hashClearFlags( pHash, iOldFlags ); }