diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9d15b531f2..63b7229f64 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,18 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2003-04-09 13:40 UTC+0300 Alexander Kresin + * include/hbexprb.c + * At() function is now Clipper compatible ( At( "","abc" ) ) - + borrowed from xHarbour + * source/rdd/workarea.c + ! Fixed hb_waRelEval() - When the current order is zero, relation works + by GOTO istead of SEEK, as Clipper does - + borrowed from xHarbour + * source/rdd/dbfntx/dbfntx1.c + ! Fix in indexing - when index expression includes fields from the child + related workarea + 2003-04-08 15:40 UTC-0400 David G. Holm * contrib/Makefile ! Added a build path for MSVC++. diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index 420676a8aa..a4122f5c02 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -1265,6 +1265,53 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) */ if( pSelf->value.asFunCall.pParms ) pSelf->value.asFunCall.pParms = HB_EXPR_USE( pSelf->value.asFunCall.pParms, HB_EA_REDUCE ); + #ifndef HB_C52_STRICT + if( pSelf->value.asFunCall.pFunName->ExprType == HB_ET_FUNNAME ) + { + HB_EXPR_PTR pName = pSelf->value.asFunCall.pFunName; + HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms; + HB_EXPR_PTR pReduced; + USHORT usCount; + + if( pParms ) + { + usCount = ( USHORT ) hb_compExprListLen( pSelf->value.asFunCall.pParms ); + + if( usCount == 1 && pParms->value.asList.pExprList->ExprType == HB_ET_NONE ) + { + --usCount; + } + } + + #ifndef HB_MACRO_SUPPORT + hb_compFunCallCheck( pName->value.asSymbol, usCount ); + #endif + + if( ( strcmp( "AT", pName->value.asSymbol ) == 0 ) && usCount == 2 ) + { + HB_EXPR_PTR pSub = pParms->value.asList.pExprList; + HB_EXPR_PTR pText = pSub->pNext; + + if( pSub->ExprType == HB_ET_STRING && pText->ExprType == HB_ET_STRING ) + { + if( pSub->value.asString.string[0] == '\0' ) + { + pReduced = hb_compExprNewLong( 1 ); + } + else + { + pReduced = hb_compExprNewLong( hb_strAt( pSub->value.asString.string, pSub->ulLength, pText->value.asString.string, pText->ulLength ) ); + } + + HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asFunCall.pFunName ); + HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asFunCall.pParms ); + + memcpy( pSelf, pReduced, sizeof( HB_EXPR ) ); + HB_XFREE( pReduced ); + } + } + } + #endif } break; diff --git a/harbour/source/rdd/dbfntx/dbfntx1.c b/harbour/source/rdd/dbfntx/dbfntx1.c index d48d481ce4..eee03daacd 100644 --- a/harbour/source/rdd/dbfntx/dbfntx1.c +++ b/harbour/source/rdd/dbfntx/dbfntx1.c @@ -2364,7 +2364,7 @@ static void hb_ntxBufferSave( LPTAGINFO pTag, LPNTXSORTINFO pSortInfo ) static BOOL hb_ntxReadBuf( NTXAREAP pArea, BYTE* readBuffer, USHORT* numRecinBuf, LPDBORDERCONDINFO lpdbOrdCondInfo ) { - if( !lpdbOrdCondInfo || lpdbOrdCondInfo->fAll ) + if( ( !lpdbOrdCondInfo || lpdbOrdCondInfo->fAll ) && !pArea->lpdbRelations ) { if( *numRecinBuf == 10 ) *numRecinBuf = 0; @@ -2376,7 +2376,7 @@ static BOOL hb_ntxReadBuf( NTXAREAP pArea, BYTE* readBuffer, USHORT* numRecinBuf (*numRecinBuf) ++; return TRUE; } - else + else if( lpdbOrdCondInfo ) { if( lpdbOrdCondInfo->lNextCount < 0 ) return FALSE; @@ -2400,6 +2400,7 @@ static BOOL hb_ntxReadBuf( NTXAREAP pArea, BYTE* readBuffer, USHORT* numRecinBuf return TRUE; } + return TRUE; } /* DJGPP can sprintf a float that is almost 320 digits long */ @@ -2472,14 +2473,14 @@ static ERRCODE hb_ntxIndexCreate( LPNTXINDEX pIndex ) else sortInfo.sortBuffer = NULL; - if( !pArea->lpdbOrdCondInfo || pArea->lpdbOrdCondInfo->fAll ) + if( ( !pArea->lpdbOrdCondInfo || pArea->lpdbOrdCondInfo->fAll ) && !pArea->lpdbRelations ) { pRecordTmp = pArea->pRecord; fValidBuffer = pArea->fValidBuffer; pArea->fValidBuffer = TRUE; hb_fsSeek( pArea->hDataFile, pArea->uiHeaderLen, FS_SET ); } - else if( pArea->lpdbOrdCondInfo->fUseCurrent ) + else if( pArea->lpdbRelations || pArea->lpdbOrdCondInfo->fUseCurrent ) SELF_GOTOP( ( AREAP ) pArea ); for( ulRecNo = 1; ulRecNo <= ulRecCount; ulRecNo++) { @@ -2587,9 +2588,11 @@ static ERRCODE hb_ntxIndexCreate( LPNTXINDEX pIndex ) hb_vmSend( 0 ); } } + else if( pArea->lpdbRelations ) + SELF_SKIP( ( AREAP ) pArea, 1 ); } hb_ntxSortKeyEnd( pTag, &sortInfo ); - if( !pArea->lpdbOrdCondInfo || pArea->lpdbOrdCondInfo->fAll ) + if( ( !pArea->lpdbOrdCondInfo || pArea->lpdbOrdCondInfo->fAll ) && !pArea->lpdbRelations ) { pArea->pRecord = pRecordTmp; pArea->fValidBuffer = fValidBuffer; diff --git a/harbour/source/rdd/workarea.c b/harbour/source/rdd/workarea.c index 0434521b1b..f51187704b 100644 --- a/harbour/source/rdd/workarea.c +++ b/harbour/source/rdd/workarea.c @@ -843,16 +843,44 @@ ERRCODE hb_waRelEval( AREAP pArea, LPDBRELINFO pRelInfo ) { int iCurrArea; PHB_ITEM pResult; + DBORDERINFO pInfo; + int iOrder; + HB_TRACE(HB_TR_DEBUG, ("hb_waRelEval(%p, %p)", pArea, pRelInfo)); iCurrArea = hb_rddGetCurrentWorkAreaNumber(); hb_rddSelectWorkAreaNumber( pRelInfo->lpaParent->uiArea ); pResult = hb_vmEvalBlock( pRelInfo->itmCobExpr ); hb_rddSelectWorkAreaNumber( iCurrArea ); - if( SELF_SEEK( pArea, 0, pResult, 0 ) == SUCCESS ) - return SUCCESS; + + /* + * Check the current order + */ + + pInfo.itmResult = hb_itemPutNI( NULL, 0 ); + pInfo.itmOrder = NULL; + SELF_ORDINFO( pArea, DBOI_NUMBER, &pInfo ); + iOrder = hb_itemGetNI( pInfo.itmResult ); + hb_itemRelease( pInfo.itmResult ); + + if( iOrder != 0 ) + { + if( SELF_SEEK( pArea, 0, pResult, 0 ) == SUCCESS ) + return SUCCESS; + else + return FAILURE; + } else - return FAILURE; + { + /* + * If current order equals to zero, use GOTO instead of SEEK + */ + + if( SELF_GOTO( pArea, hb_itemGetNI( pResult ) ) == SUCCESS ) + return SUCCESS; + else + return FAILURE; + } } /*