From f4c83832bb244b243becb0d98b9ac323be7f0aef Mon Sep 17 00:00:00 2001 From: Mindaugas Kavaliauskas Date: Thu, 31 Dec 2009 12:03:22 +0000 Subject: [PATCH] 2009-12-31 13:59 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) * harbour/contrib/rddads/ads1.c ! fixed softseek seeklast behavior in case seek positions at EOF * added additional ADS function return value check in seek operation --- harbour/ChangeLog | 5 +++++ harbour/contrib/rddads/ads1.c | 32 ++++++++++++++------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f21747f677..d2f7a8a020 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,11 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-31 13:59 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) + * harbour/contrib/rddads/ads1.c + ! fixed softseek seeklast behavior in case seek positions at EOF + * added additional ADS function return value check in seek operation + 2009-12-31 12:43 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbextcdp.ch * harbour/include/hbextlng.ch diff --git a/harbour/contrib/rddads/ads1.c b/harbour/contrib/rddads/ads1.c index f5d625718f..96c1034b2f 100644 --- a/harbour/contrib/rddads/ads1.c +++ b/harbour/contrib/rddads/ads1.c @@ -1058,33 +1058,29 @@ static HB_ERRCODE adsSeek( ADSAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL b if( bFindLast ) { - AdsSeekLast( pArea->hOrdCurrent, - pszKey, u16KeyLen, u16KeyType, &u16Found ); - if( bSoftSeek && ! u16Found ) + u32RetVal = AdsSeekLast( pArea->hOrdCurrent, + pszKey, u16KeyLen, u16KeyType, &u16Found ); + if( u32RetVal == AE_SUCCESS && bSoftSeek && ! u16Found ) { - UNSIGNED16 u16Eof; - /* in such case ADS set record at EOF position so we should make normal soft seek and then skip -1 to emulate Clipper behavior, Druzus */ - AdsSeek( pArea->hOrdCurrent, pszKey, u16KeyLen, - u16KeyType, u16SeekType, &u16Found ); + u32RetVal = AdsSeek( pArea->hOrdCurrent, pszKey, u16KeyLen, + u16KeyType, u16SeekType, &u16Found ); - AdsAtEOF( pArea->hTable, &u16Eof ); - if( !u16Eof ) - { + if( u32RetVal == AE_SUCCESS ) u32RetVal = AdsSkip( pArea->hOrdCurrent, -1 ); - if( u32RetVal != AE_SUCCESS ) - { - commonError( pArea, EG_CORRUPTION, ( HB_ERRCODE ) u32RetVal, 0, NULL, EF_CANDEFAULT, NULL ); - return HB_FAILURE; - } - } } } else - AdsSeek( pArea->hOrdCurrent, pszKey, u16KeyLen, - u16KeyType, u16SeekType, &u16Found ); + u32RetVal = AdsSeek( pArea->hOrdCurrent, pszKey, u16KeyLen, + u16KeyType, u16SeekType, &u16Found ); + + if( u32RetVal != AE_SUCCESS ) + { + commonError( pArea, EG_CORRUPTION, ( HB_ERRCODE ) u32RetVal, 0, NULL, EF_CANDEFAULT, NULL ); + return HB_FAILURE; + } hb_adsUpdateAreaFlags( pArea );