From a3c5433fa3d0149be5b6ac7a42020f0572ea07cd Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 25 Sep 2007 16:52:16 +0000 Subject: [PATCH] 2007-09-25 18:51 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * include/hbcompat.ch * source/vm/arrayshb.c * contrib/xhb/xhb.ch * contrib/xhb/xhbfunc.c + Added HB_ASCAN() to Harbour, which does the same as the plain AScan() in xhb. I decided to do this because we already had hb_RAscan() implemented, and having hb_Ascan() is good to keep symetry. * Modified xhb lib to use the Harbour one. * Translations moved to hbcompat.ch. - Removed HB_COMPAT_XHB from Harbour level array functions. --- harbour/ChangeLog | 13 ++++++++++ harbour/contrib/xhb/xhb.ch | 1 - harbour/contrib/xhb/xhbfunc.c | 19 -------------- harbour/include/hbcompat.ch | 6 +++-- harbour/source/vm/arrayshb.c | 48 +++++++++++++++-------------------- 5 files changed, 38 insertions(+), 49 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b661fb94ff..284131e94c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,19 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-09-25 18:51 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * include/hbcompat.ch + * source/vm/arrayshb.c + * contrib/xhb/xhb.ch + * contrib/xhb/xhbfunc.c + + Added HB_ASCAN() to Harbour, which does the same as + the plain AScan() in xhb. I decided to do this + because we already had hb_RAscan() implemented, and + having hb_Ascan() is good to keep symetry. + * Modified xhb lib to use the Harbour one. + * Translations moved to hbcompat.ch. + - Removed HB_COMPAT_XHB from Harbour level array functions. + 2007-09-25 13:10 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rdd/wafunc.c ! fixed typo which broke array returned by dbStrunct() diff --git a/harbour/contrib/xhb/xhb.ch b/harbour/contrib/xhb/xhb.ch index da642d49af..2d3c2e0f18 100644 --- a/harbour/contrib/xhb/xhb.ch +++ b/harbour/contrib/xhb/xhb.ch @@ -58,6 +58,5 @@ #xtranslate AIns(,,) => xhb_AIns(,,) #xtranslate ADel(,,) => xhb_ADel(,,) - #xtranslate AScan(,,[],[],) => xhb_AScan(,,,,) #endif diff --git a/harbour/contrib/xhb/xhbfunc.c b/harbour/contrib/xhb/xhbfunc.c index fd18ced702..4663c55460 100644 --- a/harbour/contrib/xhb/xhbfunc.c +++ b/harbour/contrib/xhb/xhbfunc.c @@ -53,25 +53,6 @@ #include "hbapi.h" #include "hbapiitm.h" -HB_FUNC( XHB_ASCAN ) -{ - PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY ); - PHB_ITEM pValue = hb_param( 2, HB_IT_ANY ); - - if( pArray && pValue ) - { - ULONG ulStart = hb_parnl( 3 ); - ULONG ulCount = hb_parnl( 4 ); - - hb_retnint( hb_arrayScan( pArray, pValue, - ISNUM( 3 ) ? &ulStart : NULL, - ISNUM( 4 ) ? &ulCount : NULL, - hb_parl( 5 ) ) ); - } - else - hb_retni( 0 ); -} - HB_FUNC_EXTERN( HB_DESERIALIZE ); HB_FUNC( HB_DESERIALBEGIN ) diff --git a/harbour/include/hbcompat.ch b/harbour/include/hbcompat.ch index 7ec2cb5c4b..e7fdc205cd 100644 --- a/harbour/include/hbcompat.ch +++ b/harbour/include/hbcompat.ch @@ -81,7 +81,8 @@ #xtranslate hb_HexToStr([]) => HexToStr() #xtranslate hb_StrToHex([]) => StrToHex() - #xtranslate hb_RAScan([]) => RAScan() + #xtranslate hb_AScan(,,[],[],) => AScan(,,,,) + #xtranslate hb_RAScan([]) => RAScan() #xtranslate hb_ISPOINTER( )=> ISPOINTER( ) @@ -125,7 +126,8 @@ #xtranslate HexToStr([]) => hb_HexToStr() #xtranslate StrToHex([]) => hb_StrToHex() - #xtranslate RAScan([]) => hb_RAScan() + #xtranslate AScan(,,[],[],) => hb_AScan(,,,,) + #xtranslate RAScan([]) => hb_RAScan() #xtranslate ISPOINTER( ) => hb_ISPOINTER( ) diff --git a/harbour/source/vm/arrayshb.c b/harbour/source/vm/arrayshb.c index 8f332ab744..9cf15571be 100644 --- a/harbour/source/vm/arrayshb.c +++ b/harbour/source/vm/arrayshb.c @@ -180,19 +180,7 @@ HB_FUNC( AINS ) if( lPos == 0 ) lPos = 1; -#if defined( HB_COMPAT_XHB ) - if( hb_pcount() >= 4 && ISLOG( 4 ) && hb_parl( 4 ) && - lPos >= 1 && ( ULONG ) lPos <= pArray->item.asArray.value->ulLen + 1 ) - hb_arraySize( pArray, pArray->item.asArray.value->ulLen + 1 ); - - if( hb_arrayIns( pArray, lPos ) ) - { - if( hb_pcount() >= 3 && !ISNIL( 3 ) ) - hb_arraySet( pArray, lPos, hb_param( 3, HB_IT_ANY ) ); - } -#else hb_arrayIns( pArray, lPos ); -#endif hb_itemReturn( pArray ); /* AIns() returns the array itself */ } @@ -209,15 +197,7 @@ HB_FUNC( ADEL ) if( lPos == 0 ) lPos = 1; -#if defined( HB_COMPAT_XHB ) - if( hb_arrayDel( pArray, lPos ) ) - { - if( hb_pcount() >= 3 && ISLOG( 3 ) && hb_parl( 3 ) ) - hb_arraySize( pArray, pArray->item.asArray.value->ulLen - 1 ); - } -#else hb_arrayDel( pArray, lPos ); -#endif hb_itemReturn( pArray ); /* ADel() returns the array itself */ } @@ -285,17 +265,30 @@ HB_FUNC( ASCAN ) ULONG ulStart = hb_parnl( 3 ); ULONG ulCount = hb_parnl( 4 ); -#if defined( HB_COMPAT_XHB ) - hb_retnint( hb_arrayScan( pArray, pValue, - ISNUM( 3 ) ? &ulStart : NULL, - ISNUM( 4 ) ? &ulCount : NULL, - hb_parl( 5 ) ) ); -#else hb_retnint( hb_arrayScan( pArray, pValue, ISNUM( 3 ) ? &ulStart : NULL, ISNUM( 4 ) ? &ulCount : NULL, FALSE ) ); -#endif + } + else + hb_retni( 0 ); +} + +/* Same as ASCAN() but has an additional parameter to force exact comparison. */ +HB_FUNC( HB_ASCAN ) +{ + PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY ); + PHB_ITEM pValue = hb_param( 2, HB_IT_ANY ); + + if( pArray && pValue ) + { + ULONG ulStart = hb_parnl( 3 ); + ULONG ulCount = hb_parnl( 4 ); + + hb_retnint( hb_arrayScan( pArray, pValue, + ISNUM( 3 ) ? &ulStart : NULL, + ISNUM( 4 ) ? &ulCount : NULL, + hb_parl( 5 ) ) ); } else hb_retni( 0 ); @@ -310,6 +303,7 @@ HB_FUNC( HB_RASCAN ) { ULONG ulStart = hb_parnl( 3 ); ULONG ulCount = hb_parnl( 4 ); + hb_retnint( hb_arrayRevScan( pArray, pValue, ISNUM( 3 ) ? &ulStart : NULL, ISNUM( 4 ) ? &ulCount : NULL,