diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a57f6b509f..a7949e25ac 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,30 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-04 00:23 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/rddads/ads1.c + * added support for dynamic descend flag switching by + ordDescend( [], [], ) -> + It needs ADS 9.00 or higher and it's ignored in earlier ADS versions. + Based on Brian Hayes modification in xHarbour ADS RDD. + + * harbour/src/rdd/dbfntx/dbfntx1.c + * harbour/src/rdd/dbfnsx/dbfnsx1.c + * harbour/src/rdd/dbfcdx/dbfcdx1.c + * harbour/contrib/rddads/ads1.c + * modified ordSkipUnique() to be compatible with CL53 - it means + that the passed parameter has a little bit different meaning when + table has active index and it hasn't. + If no index is active (natural order) then passed parameter is number + of records to skip just like in dbSkip() function otherwise it's only + direction choice so negative value means backward skipping and + zero or positive means forward skipping. + We may decide to change this behavior anyhow please remember that + it's not such clear what number of records to skip should mean during + skipping with active order having repeated key values and with working + filters which also can exclude some records. It's possible to create + few algorithms giving different results for some conditions. + 2009-12-04 00:18 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg ! Added -debug linker option when building .dll for msvc and compatible targets. diff --git a/harbour/contrib/rddads/ads1.c b/harbour/contrib/rddads/ads1.c index ee5760ddcd..f73d21eb26 100644 --- a/harbour/contrib/rddads/ads1.c +++ b/harbour/contrib/rddads/ads1.c @@ -4100,7 +4100,6 @@ static HB_ERRCODE adsOrderInfo( ADSAREAP pArea, USHORT uiIndex, LPDBORDERINFO pO hb_itemPutCL( pOrderInfo->itmResult, ( char* ) aucBuffer, u16len ); else hb_itemPutC( pOrderInfo->itmResult, NULL ); - break; case DBOI_ISCOND: @@ -4113,7 +4112,17 @@ static HB_ERRCODE adsOrderInfo( ADSAREAP pArea, USHORT uiIndex, LPDBORDERINFO pO case DBOI_ISDESC: if( hIndex ) + { AdsIsIndexDescending( hIndex, &u16 ); + +#if ADS_LIB_VERSION >= 900 + if( pOrderInfo->itmNewVal && HB_IS_NUMERIC( pOrderInfo->itmNewVal ) ) + { + if( hb_itemGetL( pOrderInfo->itmNewVal ) ? u16 == 0 : u16 != 0 ) + AdsSetIndexDirection( hIndex, TRUE ); + } +#endif + } else u16 = 0; hb_itemPutL( pOrderInfo->itmResult, u16 != 0 ); @@ -4152,7 +4161,6 @@ static HB_ERRCODE adsOrderInfo( ADSAREAP pArea, USHORT uiIndex, LPDBORDERINFO pO } else hb_itemPutC( pOrderInfo->itmResult, NULL ); - break; case DBOI_KEYSIZE: @@ -4349,7 +4357,6 @@ static HB_ERRCODE adsOrderInfo( ADSAREAP pArea, USHORT uiIndex, LPDBORDERINFO pO if( u16 ) break; u32++; - u32RetVal = AdsSkip( hIndex, 1 ); if( u32RetVal != AE_SUCCESS ) break; @@ -4458,13 +4465,18 @@ static HB_ERRCODE adsOrderInfo( ADSAREAP pArea, USHORT uiIndex, LPDBORDERINFO pO break; #if ADS_LIB_VERSION >= 900 - case DBOI_SKIPUNIQUE: - if( hIndex && - AdsSkipUnique( hIndex, ( SIGNED32 ) ( pOrderInfo && HB_IS_NUMBER( pOrderInfo->itmNewVal ) ? hb_itemGetNL( pOrderInfo->itmNewVal ) : 1 ) ) == AE_SUCCESS ) - hb_itemPutL( pOrderInfo->itmResult, TRUE ); + { + LONG lToSkip = pOrderInfo->itmNewVal && HB_IS_NUMERIC( pOrderInfo->itmNewVal ) ? + hb_itemGetNL( pOrderInfo->itmNewVal ) : 1; + if( hIndex ) + hb_itemPutL( pOrderInfo->itmResult, + AdsSkipUnique( hIndex, lToSkip >= 0 ? 1 : -1 ) == AE_SUCCESS ); + else + hb_itemPutL( pOrderInfo->itmResult, + SELF_SKIP( ( AREAP ) pArea, lToSkip ) == HB_SUCCESS ); break; - + } #endif case DBOI_OPTLEVEL : diff --git a/harbour/src/rdd/dbfcdx/dbfcdx1.c b/harbour/src/rdd/dbfcdx/dbfcdx1.c index 84fff7ea09..82bb2639b7 100644 --- a/harbour/src/rdd/dbfcdx/dbfcdx1.c +++ b/harbour/src/rdd/dbfcdx/dbfcdx1.c @@ -5179,23 +5179,28 @@ static BOOL hb_cdxCurKeyRefresh( CDXAREAP pArea, LPCDXTAG pTag ) /* * skip to next/previous unique key */ -static HB_ERRCODE hb_cdxDBOISkipUnique( CDXAREAP pArea, LPCDXTAG pTag, BOOL fForward ) +static HB_ERRCODE hb_cdxDBOISkipUnique( CDXAREAP pArea, LPCDXTAG pTag, LONG lToSkip ) { HB_ERRCODE retval; + BOOL fForward; - HB_TRACE(HB_TR_DEBUG, ("hb_cdxDBOISkipUnique(%p, %p, %i)", pArea, pTag, fForward)); + HB_TRACE(HB_TR_DEBUG, ("hb_cdxDBOISkipUnique(%p, %p, %ld)", pArea, pTag, lToSkip)); if( FAST_GOCOLD( ( AREAP ) pArea ) == HB_FAILURE ) return HB_FAILURE; if( ! pTag ) - return SELF_SKIP( ( AREAP ) pArea, fForward ? 1 : -1 ); + return SELF_SKIP( ( AREAP ) pArea, lToSkip ); if( pArea->dbfarea.lpdbPendingRel ) SELF_FORCEREL( ( AREAP ) pArea ); pArea->dbfarea.area.fTop = pArea->dbfarea.area.fBottom = FALSE; + /* CL53 DBFCDX when index is active use this parameter + only to chose forward or backward skipping */ + fForward = lToSkip >= 0; + if( !pArea->dbfarea.fPositioned ) { if( fForward ) @@ -8115,8 +8120,9 @@ static HB_ERRCODE hb_cdxOrderInfo( CDXAREAP pArea, USHORT uiIndex, LPDBORDERINFO case DBOI_SKIPUNIQUE: pInfo->itmResult = hb_itemPutL( pInfo->itmResult, - hb_cdxDBOISkipUnique( pArea, pTag, - hb_itemGetNI( pInfo->itmNewVal ) >= 0 ) == HB_SUCCESS ); + hb_cdxDBOISkipUnique( pArea, pTag, + pInfo->itmNewVal && HB_IS_NUMERIC( pInfo->itmNewVal ) ? + hb_itemGetNL( pInfo->itmNewVal ) : 1 ) == HB_SUCCESS ); break; case DBOI_SKIPEVAL: diff --git a/harbour/src/rdd/dbfnsx/dbfnsx1.c b/harbour/src/rdd/dbfnsx/dbfnsx1.c index 942775bab3..0b22bc0e0c 100644 --- a/harbour/src/rdd/dbfnsx/dbfnsx1.c +++ b/harbour/src/rdd/dbfnsx/dbfnsx1.c @@ -4413,10 +4413,10 @@ static void hb_nsxOrdSetRelKeyPos( LPTAGINFO pTag, double dPos ) /* * skip to next/previous unique key */ -static BOOL hb_nsxOrdSkipUnique( LPTAGINFO pTag, LONG lDir ) +static BOOL hb_nsxOrdSkipUnique( LPTAGINFO pTag, LONG lToSkip ) { NSXAREAP pArea = pTag->pIndex->pArea; - BOOL fOut = FALSE, fEof = FALSE, fForward = ( lDir >= 0 ); + BOOL fOut = FALSE, fEof = FALSE, fForward = ( lToSkip >= 0 ); if( pArea->dbfarea.lpdbPendingRel ) SELF_FORCEREL( ( AREAP ) pArea ); @@ -7491,7 +7491,9 @@ static HB_ERRCODE hb_nsxOrderInfo( NSXAREAP pArea, USHORT uiIndex, LPDBORDERINFO break; case DBOI_SKIPUNIQUE: pInfo->itmResult = hb_itemPutL( pInfo->itmResult, - hb_nsxOrdSkipUnique( pTag, hb_itemGetNL( pInfo->itmNewVal ) ) ); + hb_nsxOrdSkipUnique( pTag, + pInfo->itmNewVal && HB_IS_NUMERIC( pInfo->itmNewVal ) ? + hb_itemGetNL( pInfo->itmNewVal ) : 1 ) ); break; case DBOI_SKIPEVAL: case DBOI_SKIPEVALBACK: @@ -7647,7 +7649,8 @@ static HB_ERRCODE hb_nsxOrderInfo( NSXAREAP pArea, USHORT uiIndex, LPDBORDERINFO break; case DBOI_SKIPUNIQUE: hb_itemPutL( pInfo->itmResult, SELF_SKIP( ( AREAP ) pArea, - hb_itemGetNL( pInfo->itmNewVal ) >= 0 ? 1 : -1 ) == HB_SUCCESS ); + pInfo->itmNewVal && HB_IS_NUMERIC( pInfo->itmNewVal ) ? + hb_itemGetNL( pInfo->itmNewVal ) : 1 ) == HB_SUCCESS ); break; case DBOI_SKIPEVAL: case DBOI_SKIPEVALBACK: diff --git a/harbour/src/rdd/dbfntx/dbfntx1.c b/harbour/src/rdd/dbfntx/dbfntx1.c index 105d68e630..91bd99dde0 100644 --- a/harbour/src/rdd/dbfntx/dbfntx1.c +++ b/harbour/src/rdd/dbfntx/dbfntx1.c @@ -4047,10 +4047,10 @@ static void hb_ntxOrdSetRelKeyPos( LPTAGINFO pTag, double dPos ) /* * skip to next/previous unique key */ -static BOOL hb_ntxOrdSkipUnique( LPTAGINFO pTag, LONG lDir ) +static BOOL hb_ntxOrdSkipUnique( LPTAGINFO pTag, LONG lToSkip ) { NTXAREAP pArea = pTag->Owner->Owner; - BOOL fOut = FALSE, fEof = FALSE, fForward = ( lDir >= 0 ); + BOOL fOut = FALSE, fEof = FALSE, fForward = ( lToSkip >= 0 ); if( pArea->dbfarea.lpdbPendingRel ) SELF_FORCEREL( ( AREAP ) pArea ); @@ -7100,7 +7100,8 @@ static HB_ERRCODE hb_ntxOrderInfo( NTXAREAP pArea, USHORT uiIndex, LPDBORDERINFO break; case DBOI_SKIPUNIQUE: hb_itemPutL( pInfo->itmResult, hb_ntxOrdSkipUnique( pTag, - hb_itemGetNL( pInfo->itmNewVal ) ) ); + pInfo->itmNewVal && HB_IS_NUMERIC( pInfo->itmNewVal ) ? + hb_itemGetNL( pInfo->itmNewVal ) : 1 ) ); break; case DBOI_SKIPEVAL: case DBOI_SKIPEVALBACK: @@ -7276,7 +7277,8 @@ static HB_ERRCODE hb_ntxOrderInfo( NTXAREAP pArea, USHORT uiIndex, LPDBORDERINFO break; case DBOI_SKIPUNIQUE: hb_itemPutL( pInfo->itmResult, SELF_SKIP( ( AREAP ) pArea, - hb_itemGetNL( pInfo->itmNewVal ) >= 0 ? 1 : -1 ) == HB_SUCCESS ); + pInfo->itmNewVal && HB_IS_NUMERIC( pInfo->itmNewVal ) ? + hb_itemGetNL( pInfo->itmNewVal ) : 1 ) == HB_SUCCESS ); break; case DBOI_SKIPEVAL: case DBOI_SKIPEVALBACK: