diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3d563f6783..61f2f8ab26 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,15 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2003-09-15 12:50 UTC+0300 Alexander Kresin + * source/rdd/dbf1.c + * source/rdd/dbfntx/dbfntx1.c + ! Bug fixed in hb_IncString(), reported by Przemyslaw Czerpak - + now this function respects the national sorting rules. + ! Bug fixed in hb_ntxTagKeyNo(), reported by Przemyslaw Czerpak - + index unlocking wasn't present in some occasions. + ! Bug fixed with scoping, reported by Giovi Verrua. + 2003-09-11 11:30 UTC+0200 Przemyslaw Czerpak * harbour/harbour.spec * small fix in auto platform detection (thanks to Tomaz Zupan) diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index 6dae78f84f..e7e7d144d3 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -812,10 +812,12 @@ ERRCODE hb_dbfSkip( DBFAREAP pArea, LONG lToSkip ) } /* Update Bof and Eof flags */ + /* if( lToSkip < 0 ) pArea->fEof = FALSE; else if( lToSkip > 0 ) pArea->fBof = FALSE; + */ return uiError; } diff --git a/harbour/source/rdd/dbfntx/dbfntx1.c b/harbour/source/rdd/dbfntx/dbfntx1.c index bbfe0020f7..5a94e9ad2a 100644 --- a/harbour/source/rdd/dbfntx/dbfntx1.c +++ b/harbour/source/rdd/dbfntx/dbfntx1.c @@ -263,7 +263,7 @@ static void commonError( NTXAREAP pArea, USHORT uiGenCode, USHORT uiSubCode, cha return; } -static void hb_IncString( char* s, int slen ) +static void hb_IncString( NTXAREAP pArea, char* s, int slen ) { char *ptr; unsigned int nsymb; @@ -273,7 +273,23 @@ static void hb_IncString( char* s, int slen ) nsymb = (unsigned int) *ptr; if( nsymb < 255 ) { - *ptr = (char) ++nsymb; + unsigned int n1, i; + if( pArea->cdPage->lSort && ( n1 = (unsigned int)pArea->cdPage->s_chars[ nsymb ] ) != 0 ) + { + n1 ++; + for( i=0; i<255; i++ ) + { + if( n1 == (unsigned int)pArea->cdPage->s_chars[ i ] ) + { + *ptr = (char) i; + break; + } + } + if( i >= 255 ) + *ptr = (char) ++nsymb; + } + else + *ptr = (char) ++nsymb; break; } } @@ -429,25 +445,24 @@ static ULONG hb_ntxTagKeyNo( LPTAGINFO pTag ) hb_ntxGetCurrentKey( pTag,pKey ); seekRes = hb_ntxTagFindCurrentKey( pTag, hb_ntxPageLoad( pTag,0 ), pKey, (int)pTag->KeyLength, FALSE, FALSE ); hb_ntxKeyFree( pKey ); - if( seekRes ) + if( !seekRes ) { - return 0; - } - ulKeyNo = 1; - for( i=0;i<=pTag->stackLevel;i++ ) - { - pPage = hb_ntxPageLoad( pTag,pTag->stack[i].page ); - ulKeyNo += pTag->stack[i].ikey; - if( pTag->stackLevel ) - pTag->stack[i].ikey --; - for( j=0;j<=pTag->stack[i].ikey;j++ ) + ulKeyNo = 1; + for( i=0;i<=pTag->stackLevel;i++ ) { - p = KEYITEM( pPage, j ); - if( p->page ) - hb__ntxTagKeyCount( pTag, hb_ntxPageLoad( pTag,p->page ), - &ulKeyNo ); + pPage = hb_ntxPageLoad( pTag,pTag->stack[i].page ); + ulKeyNo += pTag->stack[i].ikey; + if( pTag->stackLevel ) + pTag->stack[i].ikey --; + for( j=0;j<=pTag->stack[i].ikey;j++ ) + { + p = KEYITEM( pPage, j ); + if( p->page ) + hb__ntxTagKeyCount( pTag, hb_ntxPageLoad( pTag,p->page ), + &ulKeyNo ); + } + hb_ntxPageRelease( pTag,pPage ); } - hb_ntxPageRelease( pTag,pPage ); } } @@ -2975,7 +2990,11 @@ static ERRCODE ntxGoBottom( NTXAREAP pArea ) pTag = pArea->lpCurTag; if( pTag->bottomScope ) - ntxSeek( pArea, 1, pTag->bottomScope, 1 ); + { + ntxSeek( pArea, 0, pTag->bottomScope, 1 ); + if( pArea->fEof ) + return SUCCESS; + } else hb_ntxTagKeyGoTo( pTag, BTTM_RECORD, NULL ); SELF_GOTO( ( AREAP ) pArea, pTag->CurKeyInfo->Xtra ); @@ -3098,7 +3117,7 @@ static ERRCODE ntxSeek( NTXAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFin LONG lRecnoLast; pArea->fEof = pArea->fBof = FALSE; - hb_IncString( pKey2->key,keylen ); + hb_IncString( pArea, pKey2->key, keylen ); lRecnoLast = hb_ntxTagKeyFind( pTag, pKey2, keylen, &result ); hb_ntxKeyFree( pKey2 ); if( lRecnoLast > 0 ) @@ -3139,11 +3158,20 @@ static ERRCODE ntxSeek( NTXAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFin } else { - pArea->fFound = FALSE; - if ( lRecno > 0 && !result && bSoftSeek && !pTag->TagEOF ) - return SELF_GOTO( ( AREAP ) pArea, lRecno ); - else - return hb_ntxGoEof( pArea ); + pArea->fFound = FALSE; + if ( lRecno > 0 && !result && bSoftSeek && !pTag->TagEOF ) + { + SELF_GOTO( ( AREAP ) pArea, lRecno ); + if( pTag->bottomScope ) + { + hb_ntxGetCurrentKey( pTag, pTag->CurKeyInfo ); + if( !hb_ntxInBottomScope( pTag, pTag->CurKeyInfo->key ) ) + pArea->fEof = pTag->TagEOF = TRUE; + } + return SUCCESS; + } + else + return hb_ntxGoEof( pArea ); } } } @@ -3188,7 +3216,10 @@ static ERRCODE ntxSkipRaw( NTXAREAP pArea, LONG lToSkip ) } pArea->ulRecNo = ulRecNo; if ( !pTag->TagEOF ) - SELF_GOTO( ( AREAP ) pArea, pTag->CurKeyInfo->Xtra ); + { + if( pTag->CurKeyInfo->Tag ) + SELF_GOTO( ( AREAP ) pArea, pTag->CurKeyInfo->Xtra ); + } else { hb_ntxGoEof( pArea ); @@ -3218,7 +3249,10 @@ static ERRCODE ntxSkipRaw( NTXAREAP pArea, LONG lToSkip ) } pArea->ulRecNo = ulRecNo; if ( !pTag->TagBOF ) - SELF_GOTO( ( AREAP ) pArea, pTag->CurKeyInfo->Xtra ); + { + if( pTag->CurKeyInfo->Tag ) + SELF_GOTO( ( AREAP ) pArea, pTag->CurKeyInfo->Xtra ); + } else { pTag->TagBOF = FALSE;