diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 66b11155fb..64f3abc8c2 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,101 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2005-10-24 02:50 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/dot/pp.prg + * harbour/contrib/dot/pp_harb.ch + * harbour/include/hbapi.h + * harbour/include/hbapirdd.h + * harbour/include/hbdefs.h + * harbour/include/hbextern.ch + * harbour/include/hbinit.h + * harbour/include/hbstack.h + * harbour/include/hbsxfunc.h + * harbour/include/hbvm.h + + harbour/include/hbvmopt.h + * harbour/include/hbvmpub.h + * harbour/source/codepage/cdp_tpl.c + * harbour/source/codepage/cdppl852.c + * harbour/source/codepage/cdppliso.c + * harbour/source/codepage/cdpplmaz.c + * harbour/source/codepage/cdpplwin.c + * harbour/source/compiler/genc.c + * harbour/source/compiler/harbour.c + * harbour/source/lang/msgca.c + * harbour/source/lang/msgpl852.c + * harbour/source/lang/msgpliso.c + * harbour/source/lang/msgplmaz.c + * harbour/source/lang/msgplwin.c + * harbour/source/rdd/Makefile + * harbour/source/rdd/dbcmd.c + - harbour/source/rdd/dbf0.prg + * harbour/source/rdd/dbf1.c + - harbour/source/rdd/delim0.prg + * harbour/source/rdd/delim1.c + * harbour/source/rdd/rddsys.prg + - harbour/source/rdd/sdf0.prg + * harbour/source/rdd/sdf1.c + * harbour/source/rdd/dbfcdx/Makefile + - harbour/source/rdd/dbfcdx/dbfcdx0.prg + * harbour/source/rdd/dbfcdx/dbfcdx1.c + - harbour/source/rdd/dbfcdx/sixcdx0.prg + * harbour/source/rdd/dbfdbt/Makefile + - harbour/source/rdd/dbfdbt/dbfdbt0.prg + * harbour/source/rdd/dbfdbt/dbfdbt1.c + * harbour/source/rdd/dbffpt/Makefile + - harbour/source/rdd/dbffpt/dbffpt0.prg + * harbour/source/rdd/dbffpt/dbffpt1.c + * harbour/source/rdd/dbfntx/Makefile + * harbour/source/rdd/dbfntx/dbfntx0.prg + * harbour/source/rdd/dbfntx/dbfntx1.c + * harbour/source/rdd/hbsix/Makefile + * harbour/source/rdd/hbsix/sxcompr.c + * harbour/source/rdd/hbsix/sxcrypt.c + * harbour/source/rdd/hbsix/sxdate.c + * harbour/source/rdd/hsx/hsx.c + * harbour/source/rdd/nulsys/nulsys.prg + * harbour/source/rtl/browdbx.prg + * harbour/source/rtl/cdpapi.c + * harbour/source/vm/arrays.c + * harbour/source/vm/arrayshb.c + * harbour/source/vm/asort.c + * harbour/source/vm/break.c + * harbour/source/vm/classes.c + * harbour/source/vm/cmdarg.c + * harbour/source/vm/codebloc.c + * harbour/source/vm/debug.c + * harbour/source/vm/dynlibhb.c + * harbour/source/vm/dynsym.c + * harbour/source/vm/estack.c + * harbour/source/vm/eval.c + * harbour/source/vm/evalhb.c + * harbour/source/vm/extend.c + * harbour/source/vm/fm.c + * harbour/source/vm/garbage.c + - harbour/source/codepage/cdpru866.c + * harbour/source/vm/initsymb.c + * harbour/source/vm/itemapi.c + * harbour/source/vm/macro.c + * harbour/source/vm/maindllp.c + * harbour/source/vm/memvars.c + * harbour/source/vm/memvclip.c + * harbour/source/vm/pcount.c + * harbour/source/vm/proc.c + * harbour/source/vm/pvalue.c + * harbour/source/vm/runner.c + * remove default API and stack macros. Now API/stack macros can be + enabled by including hb_vmopt.h file. + This file should be included _ONLY_ by core code because binary + object/libraries generated after can work only with _EXACTLY_ the + same HVM compiled the same C alignment switches + * cleaned some HB_EXTERN_C declaration - Anotonio you should be able + to build FWH now + * cleaned startup initialization code - + please update lang and codepage files - I only updated + source/codepage/cdppl*.c and source/lang/msgpl*.c files + Or other files should be updated or they will not work MSC + * synced with recent xHarbour modification in RDD init code + 2005-10-23 09:05 UTC+0100 Antonio Linares * harbour/source/rdd/dbfntx/dbfntx1.c * harbour/source/rdd/dbfcdx/dbfcdx1.c diff --git a/harbour/contrib/dot/pp.prg b/harbour/contrib/dot/pp.prg index d1e5263cfc..fb62757471 100644 --- a/harbour/contrib/dot/pp.prg +++ b/harbour/contrib/dot/pp.prg @@ -3209,7 +3209,7 @@ FUNCTION PP_PreProLine( sLine, nLine, sSource ) IF Left( sLine, 1 ) == '#' sLine := LTrim( SubStr( sLine, 2 ) ) - sDirective := RTrim( Upper( NextToken( @sLine ) ) ) + sDirective := RTrim( Upper( _pp_NextToken( @sLine ) ) ) IF ( nLen := Len( sDirective ) ) < 4 Alert( [ERROR! Unknown directive: ] + "'" + sDirective + "' " + sSource ) @@ -3443,7 +3443,7 @@ FUNCTION PP_PreProLine( sLine, nLine, sSource ) sBackupLine := sLine sPassed := "" - DO WHILE ( sToken := NextIdentifier( @sLine, @sSkipped ) ) != NIL + DO WHILE ( sToken := _pp_NextIdentifier( @sLine, @sSkipped ) ) != NIL //? "Token = '" + sToken + "'" //WAIT @@ -3451,7 +3451,7 @@ FUNCTION PP_PreProLine( sLine, nLine, sSource ) // Save incase MatchRule fails. #ifdef USE_C_BOOST - bArrayPrefix := GetArrayPrefix() + bArrayPrefix := _pp_GetArrayPrefix() #else bArrayPrefix := s_bArrayPrefix #endif @@ -3510,7 +3510,7 @@ FUNCTION PP_PreProLine( sLine, nLine, sSource ) ELSE // Restore since MatchRule() faild. #ifdef USE_C_BOOST - SetArrayPrefix( bArrayPrefix ) + _pp_setArrayPrefix( bArrayPrefix ) #else s_bArrayPrefix := bArrayPrefix #endif @@ -3525,13 +3525,13 @@ FUNCTION PP_PreProLine( sLine, nLine, sSource ) sLine := sBackupLine sPassed := "" - DO WHILE ( sToken := NextToken( @sLine ) ) != NIL + DO WHILE ( sToken := _pp_NextToken( @sLine ) ) != NIL //? "Token = '" + sToken + "'" //WAIT // Save incase MatchRule fails. #ifdef USE_C_BOOST - bArrayPrefix := GetArrayPrefix() + bArrayPrefix := _pp_GetArrayPrefix() #else bArrayPrefix := s_bArrayPrefix #endif @@ -3592,7 +3592,7 @@ FUNCTION PP_PreProLine( sLine, nLine, sSource ) ELSE // Restore since MatchRule() faild. #ifdef USE_C_BOOST - SetArrayPrefix( bArrayPrefix ) + _pp_setArrayPrefix( bArrayPrefix ) #else s_bArrayPrefix := bArrayPrefix #endif @@ -3603,7 +3603,7 @@ FUNCTION PP_PreProLine( sLine, nLine, sSource ) sLine := sPassed //sBackupLine - sToken := NextToken( @sLine ) + sToken := _pp_NextToken( @sLine ) IF sToken != NIL .AND. ( nRule := MatchRule( sToken, @sLine, aCommRules, aCommResults, .T., .T. ) ) > 0 //? "COMMANDED: " + sLine @@ -3889,7 +3889,7 @@ STATIC FUNCTION MatchRule( sKey, sLine, aRules, aResults, bStatement, bUpper ) IF cType != ':' .AND. sAnchor == NIL .AND. ValType( aList ) == 'A' sPreStoppers := sWorkLine - sPrimaryStopper := NextToken( @sWorkLine ) + sPrimaryStopper := _pp_NextToken( @sWorkLine ) IF sPrimaryStopper == NIL @@ -3926,7 +3926,7 @@ STATIC FUNCTION MatchRule( sKey, sLine, aRules, aResults, bStatement, bUpper ) sMultiStopper += sNextStopper sStopper := SubStr( sStopper, nSpaceAt ) sMultiStopper += ExtractLeadingWS( @sStopper ) - sToken := NextToken( @sStopLine ) + sToken := _pp_NextToken( @sStopLine ) sToken := Upper( RTrim( sToken ) ) ELSE EXIT @@ -4040,7 +4040,7 @@ STATIC FUNCTION MatchRule( sKey, sLine, aRules, aResults, bStatement, bUpper ) sPreMatch := sWorkLine IF ( sAnchor == NIL .OR. sMultiStopper != NIL .OR. ; - ( ( ( sToken := NextToken( @sWorkLine ) ) != NIL .AND. ( DropTrailingWS( @sToken, @sPad ), nLen := Max( 4, Len( sToken ) ), Upper( sToken ) == Left( sAnchor, nLen ) ) ) ) ) ; + ( ( ( sToken := _pp_NextToken( @sWorkLine ) ) != NIL .AND. ( DropTrailingWS( @sToken, @sPad ), nLen := Max( 4, Len( sToken ) ), Upper( sToken ) == Left( sAnchor, nLen ) ) ) ) ) ; .AND. ( nMarkerId == 0 .OR. ( sAnchor == NIL .AND. sMultiStopper != NIL ) .OR. ( ( xMarker := NextExp( @sWorkLine, cType, aList, sNextAnchor, aRules[nRule][3] ) ) != NIL ) ) IF sMultiStopper != NIL @@ -4611,7 +4611,7 @@ RETURN 0 #ifndef USE_C_BOOST -STATIC FUNCTION NextToken( sLine, lDontRecord ) +STATIC FUNCTION _pp_NextToken( sLine, lDontRecord ) LOCAL sReturn, Counter, nLen, nClose LOCAL s1, s2, s3 @@ -4650,7 +4650,7 @@ STATIC FUNCTION NextToken( sLine, lDontRecord ) nClose := AT( ']]', sLine ) IF nClose == 0 - //Alert( "ERROR! [NextToken()] Unterminated '[[' at: " + sLine + "[" + Str( ProcLine() ) + "]" ) + //Alert( "ERROR! [_pp_NextToken()] Unterminated '[[' at: " + sLine + "[" + Str( ProcLine() ) + "]" ) sReturn := "[" // Clipper does NOT consider '[[' a single token ELSE sReturn := Left( sLine, nClose + 2 ) @@ -4765,7 +4765,7 @@ STATIC FUNCTION NextToken( sLine, lDontRecord ) nClose := AT( '"', sLine, 2 ) IF nClose == 0 - //Alert( 'ERROR! [NextToken()] Unterminated ["] at: ' + sLine ) + //Alert( 'ERROR! [_pp_NextToken()] Unterminated ["] at: ' + sLine ) sReturn := '"' ELSE sReturn := Left( sLine, nClose ) @@ -4777,7 +4777,7 @@ STATIC FUNCTION NextToken( sLine, lDontRecord ) nClose := AT( "'", sLine, 2 ) IF nClose == 0 - //Alert( "ERROR! [NextToken()] Unterminated ['] at: " + sLine ) + //Alert( "ERROR! [_pp_NextToken()] Unterminated ['] at: " + sLine ) sReturn := "'" ELSE sReturn := SubStr( sLine, 2, nClose - 2 ) @@ -4797,7 +4797,7 @@ STATIC FUNCTION NextToken( sLine, lDontRecord ) ELSE nClose := AT( ']', sLine ) IF nClose == 0 - //Alert( "ERROR! [NextToken()] Unterminated '[' at: " + sLine + "[" + Str( ProcLine() ) + "]" ) + //Alert( "ERROR! [_pp_NextToken()] Unterminated '[' at: " + sLine + "[" + Str( ProcLine() ) + "]" ) sReturn := '[' ELSE sReturn := SubStr( sLine, 2, nClose - 2 ) @@ -4863,12 +4863,12 @@ STATIC FUNCTION NextToken( sLine, lDontRecord ) IF s_bRecursive s1 := Left( sReturn, 1 ) IF ( IsAlpha( s1 ) .OR. s1 == '_' ) .AND. MatchRule( sReturn, @sLine, aDefRules, aDefResults, .F., .F. ) > 0 - RETURN NextToken( @sLine, .T. ) + RETURN _pp_NextToken( @sLine, .T. ) ENDIF IF MatchRule( sReturn, @sLine, aTransRules, aTransResults, .F., .T. ) > 0 //? '>', sLine, '<' - RETURN NextToken( @sLine, .T. ) + RETURN _pp_NextToken( @sLine, .T. ) ENDIF //? sReturn, "not defined/translated." @@ -4912,7 +4912,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) CASE cType == ':' sWorkLine := sLine - sPrimaryStopper := NextToken( @sWorkLine ) + sPrimaryStopper := _pp_NextToken( @sWorkLine ) IF sPrimaryStopper == NIL //? "No primary", sPrimaryStopper @@ -4947,7 +4947,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) sMultiStopper += sNextStopper sStopper := SubStr( sStopper, nSpaceAt ) sMultiStopper += ExtractLeadingWS( @sStopper ) - sToken := NextToken( @sStopLine ) + sToken := _pp_NextToken( @sStopLine ) sToken := Upper( RTrim( sToken ) ) ELSE EXIT @@ -5002,7 +5002,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) CASE cType == '!' IF IsAlpha( cChar := Left( sLine, 1 ) ) .OR. cChar == '_' - RETURN NextToken( @sLine ) + RETURN _pp_NextToken( @sLine ) ELSE RETURN NIL ENDIF @@ -5013,7 +5013,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) sExp := "" DO WHILE .T. - sToken := NextToken( @sLine ) + sToken := _pp_NextToken( @sLine ) IF sToken == NIL EXIT @@ -5048,7 +5048,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) sNext1 := "" ELSE sNextLine := sLine - sNextToken := NextToken( @sNextLine, .T. ) + sNextToken := _pp_NextToken( @sNextLine, .T. ) IF sNextToken == NIL sNextToken := "" sJustNext := "" @@ -5085,23 +5085,23 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) sLastToken := sJustNext sLine := sNextLine #ifdef USE_C_BOOST - SetArrayPrefix( .T. ) + _pp_setArrayPrefix( .T. ) #else s_bArrayPrefix := .T. #endif - sNextToken := NextToken( @sNextLine, .T. ) + sNextToken := _pp_NextToken( @sNextLine, .T. ) IF sNextToken != NIL .AND. Left( sNextToken, 1 ) == '.' // Get the macro terminator. sExp += sNextToken sLastToken := "." sLine := sNextLine #ifdef USE_C_BOOST - SetArrayPrefix( .T. ) + _pp_setArrayPrefix( .T. ) #else s_bArrayPrefix := .T. #endif IF sNextToken == '.' //(Last Token) No space after Macro terminator, so get the suffix. - sNextToken := NextToken( @sNextLine, .T. ) + sNextToken := _pp_NextToken( @sNextLine, .T. ) IF sNextToken != NIL sNext1 := Left( sNextToken, 1 ) IF IsAlpha( sNext1 ) .OR. IsDigit( sNext1 ) .OR. sNext1 == '_' @@ -5110,7 +5110,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) sLastToken := RTrim( sNextToken ) sLine := sNextLine #ifdef USE_C_BOOST - SetArrayPrefix( .T. ) + _pp_setArrayPrefix( .T. ) #else s_bArrayPrefix := .T. #endif @@ -5132,7 +5132,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) sExp += sNextToken sLine := sNextLine #ifdef USE_C_BOOST - SetArrayPrefix( .T. ) + _pp_setArrayPrefix( .T. ) #else s_bArrayPrefix := .T. #endif @@ -5148,7 +5148,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) //TraceLog( "Content: '" + sTemp + "'", sExp, sLine ) ENDIF - sToken := NextToken( @sLine ) // Close + sToken := _pp_NextToken( @sLine ) // Close IF sToken == NIL TraceLog( "ERROR!(2) Unbalanced '(' at: " + sExp, sLine ) Alert( [ERROR!(2) Unbalanced '(' at: ] + sExp ) @@ -5175,16 +5175,16 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) sExp += sNextToken sLine := sNextLine #ifdef USE_C_BOOST - SetArrayPrefix( .F. ) + _pp_setArrayPrefix( .F. ) #else s_bArrayPrefix := .F. #endif - sNextToken := NextToken( @sNextLine, .T. ) + sNextToken := _pp_NextToken( @sNextLine, .T. ) IF sNextToken != NIL .AND. Left( sNextToken, 1 ) == '|' sExp += sNextToken sLine := sNextLine #ifdef USE_C_BOOST - SetArrayPrefix( .F. ) + _pp_setArrayPrefix( .F. ) #else s_bArrayPrefix := .F. #endif @@ -5200,12 +5200,12 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) /* sLine was changed by NextExp()! */ sNextLine := sLine - sNextToken := NextToken( @sNextLine, .T. ) + sNextToken := _pp_NextToken( @sNextLine, .T. ) IF sNextToken != NIL .AND. Left( sNextToken, 1 ) == '|' sExp += sNextToken sLine := sNextLine #ifdef USE_C_BOOST - SetArrayPrefix( .F. ) + _pp_setArrayPrefix( .F. ) #else s_bArrayPrefix := .F. #endif @@ -5225,7 +5225,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) sExp += sTemp ENDIF - sToken := NextToken( @sLine ) // Close + sToken := _pp_NextToken( @sLine ) // Close IF sToken == NIL TraceLog( "ERROR! Unbalanced '{' at: " + sExp ) Alert( [ERROR! Unbalanced '{' at: ] + sExp ) @@ -5247,7 +5247,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) sExp += sNextToken sLine := sNextLine #ifdef USE_C_BOOST - SetArrayPrefix( .T. ) + _pp_setArrayPrefix( .T. ) #else s_bArrayPrefix := .T. #endif @@ -5261,7 +5261,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) sExp += sTemp ENDIF - sToken := NextToken( @sLine ) // Close + sToken := _pp_NextToken( @sLine ) // Close IF sToken == NIL TraceLog( "ERROR! Unbalanced '{' at: " + sExp ) Alert( [ERROR! Unbalanced '{' at: ] + sExp ) @@ -5292,7 +5292,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) sExp += sTemp ENDIF - sToken := NextToken( @sLine ) // Close + sToken := _pp_NextToken( @sLine ) // Close IF sToken == NIL Alert( [ERROR! Unbalanced ] + "'['" + [ at: ] + sExp ) EXIT @@ -5356,7 +5356,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) IF s5 == '.AND.' sLine := sToken + sLine EXIT - /* .NOT. is being translated to ! at NextToken() !!! + /* .NOT. is being translated to ! at _pp_NextToken() !!! ELSEIF s5 == ".NOT." sExp += sToken LOOP @@ -5392,7 +5392,7 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) EXIT ELSE sNextLine := sLine - sNextToken := NextToken( @sNextLine, .T. ) + sNextToken := _pp_NextToken( @sNextLine, .T. ) IF sNextToken == NIL sNextToken := "" ENDIF @@ -5428,13 +5428,13 @@ STATIC FUNCTION NextExp( sLine, cType, aWords, sNextAnchor, bX ) IF sNext1 == '(' .AND. ( IsAlpha( cLastChar ) .OR. IsDigit( cLastChar ) .OR. cLastChar $ "_." ) LOOP - ELSEIF sNext1 == '[' // No need to check prefix because NextToken() already has the logic. + ELSEIF sNext1 == '[' // No need to check prefix because _pp_NextToken() already has the logic. LOOP ELSEIF sNext1 $ "+-*/:=^!>item.asSymbol.paramcnt ) +#define hb_pcount() ( ( int ) ( hb_stackBaseItem() )->item.asSymbol.paramcnt ) -#define hb_ret() hb_itemClear( &hb_stack.Return ) -#define hb_reta( ulLen ) hb_arrayNew( &hb_stack.Return, ulLen ) -#define hb_retc( szText ) hb_itemPutC( &hb_stack.Return, szText ) -#define hb_retc_buffer( szText ) hb_itemPutCPtr( &hb_stack.Return, szText, strlen( szText ) ) -#define hb_retc_const( szText ) hb_itemPutCConst( &hb_stack.Return, szText ) -#define hb_retclen( szText, ulLen ) hb_itemPutCL( &hb_stack.Return, szText, ulLen ) -#define hb_retclen_buffer( szText, ulLen ) hb_itemPutCPtr( &hb_stack.Return, szText, ulLen ) -#define hb_retcAdopt( szText ) hb_itemPutCPtr( &hb_stack.Return, (szText), strlen( szText ) ) -#define hb_retds( szDate ) hb_itemPutDS( &hb_stack.Return, szDate ) -#define hb_retd( lYear, lMonth, lDay ) hb_itemPutD( &hb_stack.Return, lYear, lMonth, lDay ) -#define hb_retdl( lJulian ) hb_itemPutDL( &hb_stack.Return, lJulian ) -#define hb_retl( iLogical ) hb_itemPutL( &hb_stack.Return, iLogical ? TRUE : FALSE ) -#define hb_retnd( dNumber ) hb_itemPutND( &hb_stack.Return, dNumber ) -#define hb_retni( iNumber ) hb_itemPutNI( &hb_stack.Return, iNumber ) -#define hb_retnl( lNumber ) hb_itemPutNL( &hb_stack.Return, lNumber ) -#define hb_retnll( lNumber ) hb_itemPutNLL( &hb_stack.Return, lNumber ) -#define hb_retnlen( dNumber, iWidth, iDec ) hb_itemPutNLen( &hb_stack.Return, dNumber, iWidth, iDec ) -#define hb_retndlen( dNumber, iWidth, iDec ) hb_itemPutNDLen( &hb_stack.Return, dNumber, iWidth, iDec ) -#define hb_retnilen( iNumber, iWidth ) hb_itemPutNILen( &hb_stack.Return, iNumber, iWidth ) -#define hb_retnllen( lNumber, iWidth ) hb_itemPutNLLen( &hb_stack.Return, lNumber, iWidth ) -#define hb_retnlllen( lNumber, iWidth ) hb_itemPutNLLLen( &hb_stack.Return, lNumber, iWidth ) -#define hb_retnint( iNumber ) hb_itemPutNInt( &hb_stack.Return, iNumber ) -#define hb_retnintlen( lNumber, iWidth ) hb_itemPutNIntLen( &hb_stack.Return, lNumber, iWidth ) -#define hb_retptr( pointer ) hb_itemPutPtr( &hb_stack.Return, pointer ) +#define hb_ret() hb_itemClear( hb_stackReturnItem() ) +#define hb_reta( ulLen ) hb_arrayNew( hb_stackReturnItem(), ulLen ) +#define hb_retc( szText ) hb_itemPutC( hb_stackReturnItem(), szText ) +#define hb_retc_buffer( szText ) hb_itemPutCPtr( hb_stackReturnItem(), szText, strlen( szText ) ) +#define hb_retc_const( szText ) hb_itemPutCConst( hb_stackReturnItem(), szText ) +#define hb_retclen( szText, ulLen ) hb_itemPutCL( hb_stackReturnItem(), szText, ulLen ) +#define hb_retclen_buffer( szText, ulLen ) hb_itemPutCPtr( hb_stackReturnItem(), szText, ulLen ) +#define hb_retcAdopt( szText ) hb_itemPutCPtr( hb_stackReturnItem(), (szText), strlen( szText ) ) +#define hb_retds( szDate ) hb_itemPutDS( hb_stackReturnItem(), szDate ) +#define hb_retd( iYear, iMonth, iDay ) hb_itemPutD( hb_stackReturnItem(), iYear, iMonth, iDay ) +#define hb_retdl( lJulian ) hb_itemPutDL( hb_stackReturnItem(), lJulian ) +#define hb_retl( iLogical ) hb_itemPutL( hb_stackReturnItem(), iLogical ? TRUE : FALSE ) +#define hb_retnd( dNumber ) hb_itemPutND( hb_stackReturnItem(), dNumber ) +#define hb_retni( iNumber ) hb_itemPutNI( hb_stackReturnItem(), iNumber ) +#define hb_retnl( lNumber ) hb_itemPutNL( hb_stackReturnItem(), lNumber ) +#define hb_retnll( lNumber ) hb_itemPutNLL( hb_stackReturnItem(), lNumber ) +#define hb_retnlen( dNumber, iWidth, iDec ) hb_itemPutNLen( hb_stackReturnItem(), dNumber, iWidth, iDec ) +#define hb_retndlen( dNumber, iWidth, iDec ) hb_itemPutNDLen( hb_stackReturnItem(), dNumber, iWidth, iDec ) +#define hb_retnilen( iNumber, iWidth ) hb_itemPutNILen( hb_stackReturnItem(), iNumber, iWidth ) +#define hb_retnllen( lNumber, iWidth ) hb_itemPutNLLen( hb_stackReturnItem(), lNumber, iWidth ) +#define hb_retnlllen( lNumber, iWidth ) hb_itemPutNLLLen( hb_stackReturnItem(), lNumber, iWidth ) +#define hb_retnint( iNumber ) hb_itemPutNInt( hb_stackReturnItem(), iNumber ) +#define hb_retnintlen( lNumber, iWidth ) hb_itemPutNIntLen( hb_stackReturnItem(), lNumber, iWidth ) +#define hb_retptr( pointer ) hb_itemPutPtr( hb_stackReturnItem(), pointer ) #else extern int HB_EXPORT hb_pcount( void ); /* returns the number of suplied parameters */ extern void HB_EXPORT hb_ret( void ); /* post a NIL return value */ -extern void HB_EXPORT hb_retc( char * szText ); /* returns a string */ +extern void HB_EXPORT hb_retc( const char * szText ); /* returns a string */ extern void HB_EXPORT hb_retc_buffer( char * szText ); /* sames as above, but accepts an allocated buffer */ -extern void HB_EXPORT hb_retc_const( char * szText ); /* returns a string as a pcode based string */ -extern void HB_EXPORT hb_retclen( char * szText, ULONG ulLen ); /* returns a string with a specific length */ +extern void HB_EXPORT hb_retc_const( const char * szText ); /* returns a string as a pcode based string */ +extern void HB_EXPORT hb_retclen( const char * szText, ULONG ulLen ); /* returns a string with a specific length */ extern void HB_EXPORT hb_retclen_buffer( char * szText, ULONG ulLen ); /* sames as above, but accepts an allocated buffer */ extern void HB_EXPORT hb_retcAdopt( char * szText ); /* adopts a pointer to a string as the value of an item */ -extern void HB_EXPORT hb_retds( char * szDate ); /* returns a date, must use yyyymmdd format */ +extern void HB_EXPORT hb_retds( const char * szDate ); /* returns a date, must use yyyymmdd format */ extern void HB_EXPORT hb_retd( int iYear, int iMonth, int iDay ); /* returns a date */ extern void HB_EXPORT hb_retdl( long lJulian ); /* returns a long value as a julian date */ extern void HB_EXPORT hb_retl( int iTrueFalse ); /* returns a logical integer */ diff --git a/harbour/include/hbapirdd.h b/harbour/include/hbapirdd.h index cb3f0a70b3..345ac60194 100644 --- a/harbour/include/hbapirdd.h +++ b/harbour/include/hbapirdd.h @@ -1099,11 +1099,15 @@ typedef RDDNODE * LPRDDNODE; * PROTOTYPES * ---------- */ + +extern int HB_EXPORT hb_rddRegister( char * szDriver, USHORT uiType ); extern ERRCODE HB_EXPORT hb_rddInherit( PRDDFUNCS pTable, PRDDFUNCS pSubTable, PRDDFUNCS pSuperTable, BYTE * szDrvName ); -extern ERRCODE HB_EXPORT hb_rddDisinherit( BYTE * drvName ); -extern USHORT HB_EXPORT hb_rddExtendType( USHORT fieldType ); -extern USHORT HB_EXPORT hb_rddFieldType( USHORT extendType ); extern LPRDDNODE HB_EXPORT hb_rddGetNode( USHORT uiNode ); +#if 0 +extern ERRCODE HB_EXPORT hb_rddDisinherit( BYTE * drvName ); +extern USHORT HB_EXPORT hb_rddExtendType( HB_TYPE fieldType ); +extern HB_TYPE HB_EXPORT hb_rddFieldType( USHORT extendType ); +#endif typedef short (* WACALLBACK )( AREA *, int ); extern ERRCODE HB_EXPORT hb_rddIterateWorkAreas ( WACALLBACK pCallBack, int data ); diff --git a/harbour/include/hbdefs.h b/harbour/include/hbdefs.h index 5fc4bef326..c5181025d4 100644 --- a/harbour/include/hbdefs.h +++ b/harbour/include/hbdefs.h @@ -1020,6 +1020,7 @@ typedef PHB_FUNC HB_FUNC_PTR; #define HB_EXTERN_C_ #endif +#define HB_FUNC_EXEC( funcname ) HB_FUN_##funcname(); #define HB_FUNC( funcname ) HB_EXTERN_C_ HARBOUR HB_EXPORT HB_FUN_##funcname ( void ) #define HB_FUNC_STATIC( funcname ) HB_EXTERN_C_ static HARBOUR HB_FUN_##funcname ( void ) #define HB_FUNC_EXTERN( funcname ) HB_EXTERN_C_ extern HARBOUR HB_FUN_##funcname ( void ) diff --git a/harbour/include/hbextern.ch b/harbour/include/hbextern.ch index 3f53b9da5e..176bbf6187 100644 --- a/harbour/include/hbextern.ch +++ b/harbour/include/hbextern.ch @@ -229,8 +229,8 @@ EXTERNAL MEMOREAD EXTERNAL MEMORY EXTERNAL MEMOTRAN EXTERNAL MEMOWRIT -EXTERNAL MENUMODAL EXTERNAL MEMVARBLOCK +EXTERNAL MENUMODAL EXTERNAL MIN EXTERNAL MLCOUNT EXTERNAL MLCTOPOS @@ -494,32 +494,14 @@ EXTERNAL HB_DBG_PROCLEVEL /* RDD related symbols */ -EXTERNAL _DBF -EXTERNAL _DBFC -EXTERNAL DBF_GETFUNCTABLE - -EXTERNAL DBFFPT -EXTERNAL _DBFFPT -EXTERNAL DBFFPT_GETFUNCTABLE - -EXTERNAL DBFNTX -EXTERNAL _DBFNTX -EXTERNAL DBFNTX_GETFUNCTABLE - -EXTERNAL DBFCDX -EXTERNAL _DBFCDX -EXTERNAL DBFCDX_GETFUNCTABLE - -EXTERNAL DELIM -EXTERNAL _DELIM -EXTERNAL DELIM_GETFUNCTABLE - -EXTERNAL SDF -EXTERNAL _SDF -EXTERNAL SDF_GETFUNCTABLE +EXTERNAL _DBF, DBF_GETFUNCTABLE +EXTERNAL DBFFPT, DBFFPT_GETFUNCTABLE +EXTERNAL DBFNTX, DBFNTX_GETFUNCTABLE +EXTERNAL DBFCDX, DBFCDX_GETFUNCTABLE +EXTERNAL DELIM, DELIM_GETFUNCTABLE +EXTERNAL SDF, SDF_GETFUNCTABLE EXTERNAL RDDSYS -EXTERNAL RDDINIT /* CA-Cl*pper 5.2 compatible undocumented functions */ @@ -694,4 +676,4 @@ EXTERNAL STRPOKE #endif /* HB_COMPAT_FLAGSHIP */ -#endif /* HB_EXTERN_CH_ */ \ No newline at end of file +#endif /* HB_EXTERN_CH_ */ diff --git a/harbour/include/hbinit.h b/harbour/include/hbinit.h index 16e6d61d2c..0d17c31045 100644 --- a/harbour/include/hbinit.h +++ b/harbour/include/hbinit.h @@ -59,9 +59,28 @@ HB_EXTERN_BEGIN extern void HB_EXPORT hb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbols ); /* statics symbols initialization */ +#if defined(_MSC_VER) && !defined(_WIN64) && \ + !defined(__LCC__) && !defined(__POCC__) && !defined(__XCC__) && \ + !defined(HARBOUR_STRICT_ANSI_C) && !defined(HB_STATIC_STARTUP) && \ + !defined(HB_PRAGMA_STARTUP) && !defined(HB_MSC_STARTUP) + + /* In order to maintain compatibility with other products, MSVC should + always use this startup. If you know that you can use HB_STATIC_STARTUP + below, then all you need to do is define HB_STATIC_STARTUP to the + compiler. + + Sat 07 Maj 2005 02:46:38 CEST + This is only necessary when you want to create binary libs using + MSC in C++ mode (-TP switch) and later this binaries will be linked + by standard C linker with [x]Harbour programs. I strongly suggest + to for 3-rd party developers to use MSC in standard C mode to create + libraries which can be used with standard C compilers. This will + eliminate the problem and we will be able to set C++ initialization + as default for MSC in C++ mode. Druzus. + */ + + #define HB_MSC_STARTUP -#if ! defined(__GNUC__) && ! defined(_MSC_VER) - #define HB_USE_PRAGMA_STARTUP #endif @@ -69,124 +88,138 @@ extern void HB_EXPORT hb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbols ) #define HB_INIT_SYMBOLS_BEGIN( func ) \ static HB_SYMB symbols[] = { - - #define HB_INIT_SYMBOLS_END( func ) }; \ + + #define HB_INIT_SYMBOLS_END( func ) \ + }; \ void func( void ) \ { \ - hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) ); \ + hb_vmProcessSymbols( symbols, (USHORT) ( sizeof( symbols ) / sizeof( HB_SYMB ) ) ); \ } - #define HB_CALL_ON_STARTUP_BEGIN( func ) func( void ) { - #define HB_CALL_ON_STARTUP_END( func ) } + #define HB_CALL_ON_STARTUP_BEGIN( func ) \ + func( void ) \ + { + + #define HB_CALL_ON_STARTUP_END( func ) \ + } #elif defined(__GNUC__) + #if defined(HB_PRAGMA_STARTUP) || defined(HB_MSC_STARTUP) + #error Wrong macros set for startup code - clean your make/env settings. + #endif + #define HB_INIT_SYMBOLS_BEGIN( func ) \ static HB_SYMB symbols[] = { - #define HB_INIT_SYMBOLS_END( func ) }; \ + #define HB_INIT_SYMBOLS_END( func ) \ + }; \ static void __attribute__ ((constructor)) func( void ) \ { \ - hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) ); \ + hb_vmProcessSymbols( symbols, (USHORT) ( sizeof( symbols ) / sizeof( HB_SYMB ) ) ); \ } #define HB_CALL_ON_STARTUP_BEGIN( func ) \ - static void __attribute__ ((constructor)) func( void ) { + static void __attribute__ ((constructor)) func( void ) \ + { - #define HB_CALL_ON_STARTUP_END( func ) } - -#elif defined(__BORLANDC__) - - #define HB_INIT_SYMBOLS_BEGIN( func ) \ - static HB_SYMB symbols[] = { - - #define HB_INIT_SYMBOLS_END( func ) }; \ - static void func( void ) \ - { \ - hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) ); \ + #define HB_CALL_ON_STARTUP_END( func ) \ } - #define HB_CALL_ON_STARTUP_BEGIN( func ) \ - static void func( void ) { - - #define HB_CALL_ON_STARTUP_END( func ) } - -#elif defined(__IBMCPP__) || defined(__MPW__) - - #define HB_INIT_SYMBOLS_BEGIN( func ) \ - static HB_SYMB symbols[] = { - - #define HB_INIT_SYMBOLS_END( func ) }; \ - static int func( void ) \ - { \ - hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) ); \ - return 1; \ - }; \ - static int static_int_##func = func(); - - #define HB_CALL_ON_STARTUP_BEGIN( func ) \ - static int func( void ) { - - #define HB_CALL_ON_STARTUP_END( func ) return 1; } \ - static int static_int_##func = func(); - -#elif defined(_MSC_VER) +#elif defined(HB_MSC_STARTUP) typedef int (* HB_$INITSYM)( void ); #define HB_INIT_SYMBOLS_BEGIN( func ) \ static HB_SYMB symbols[] = { - #ifndef _WIN64 + #define HB_INIT_SYMBOLS_END( func ) \ + }; \ + static int func( void ) \ + { \ + hb_vmProcessSymbols( symbols, (USHORT) ( sizeof( symbols ) / sizeof( HB_SYMB ) ) ); \ + return 0; \ + } - #define HB_INIT_SYMBOLS_END( func ) }; \ - static int func( void ) \ - { \ - hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) ); \ - return 1; \ - } - - #else - - #define HB_INIT_SYMBOLS_END( func ) }; \ - static int func( void ) \ - { \ - hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) ); \ - return 1; \ - } \ - static int static_int_##func = func(); - - #endif - #define HB_CALL_ON_STARTUP_BEGIN( func ) \ - static int func( void ) { + static int func( void ) \ + { - #define HB_CALL_ON_STARTUP_END( func ) return 1; } \ - static int static_int_##func = func(); + #define HB_CALL_ON_STARTUP_END( func ) \ + return 0; \ + } -#elif defined(__WATCOMC__) + /* After each '_END' symbol, additional 'hooks' are required See the C + output of a generated prg for example + */ + +#elif defined(HB_STATIC_STARTUP) || defined(__cplusplus) + + #if defined(HB_PRAGMA_STARTUP) || defined(HB_MSC_STARTUP) + #error Wrong macros set for startup code - clean your make/env settings. + #endif #define HB_INIT_SYMBOLS_BEGIN( func ) \ static HB_SYMB symbols[] = { - #define HB_INIT_SYMBOLS_END( func ) }; \ + /* this allows any macros to be preprocessed first + so that token pasting is handled correctly */ + #define HB_INIT_SYMBOLS_END( func ) \ + _HB_INIT_SYMBOLS_END( func ) + + #define _HB_INIT_SYMBOLS_END( func ) \ + }; \ static int func( void ) \ { \ - hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) ); \ - return 1; \ - }; \ - static int static_int_##func = func(); + hb_vmProcessSymbols( symbols, (USHORT) ( sizeof( symbols ) / sizeof( HB_SYMB ) ) ); \ + return 0; \ + } \ + static int hb_vm_auto_##func = func(); #define HB_CALL_ON_STARTUP_BEGIN( func ) \ - static int func( void ) { + static int func( void ) \ + { - #define HB_CALL_ON_STARTUP_END( func ) return 1; }; \ + /* this allows any macros to be preprocessed first + so that token pasting is handled correctly */ + #define HB_CALL_ON_STARTUP_END( func ) \ + _HB_CALL_ON_STARTUP_END( func ) + + #define _HB_CALL_ON_STARTUP_END( func ) \ + return 0; \ + } \ static int static_int_##func = func(); -#endif +#elif defined(HB_PRAGMA_STARTUP) || \ + defined(__BORLANDC__) || defined(__LCC__) || defined(__POCC__) || defined(__XCC__) -#if ! defined(__GNUC__) && ! defined(_MSC_VER) - #define HB_PRAGMA_STARTUP + #if defined(HB_MSC_STARTUP) + #error Wrong macros set for startup code - clean your make/env settings. + #endif + + #if !defined(HB_PRAGMA_STARTUP) + #define HB_PRAGMA_STARTUP + #endif + + #define HB_INIT_SYMBOLS_BEGIN( func ) \ + static HB_SYMB symbols[] = { + + #define HB_INIT_SYMBOLS_END( func ) \ + }; \ + static void func( void ) \ + { \ + hb_vmProcessSymbols( symbols, (USHORT) ( sizeof( symbols ) / sizeof( HB_SYMB ) ) ); \ + } + + #define HB_CALL_ON_STARTUP_BEGIN( func ) \ + static void func( void ) \ + { + + #define HB_CALL_ON_STARTUP_END( func ) \ + } + +#else + #error Unknown initialization method. #endif HB_EXTERN_END diff --git a/harbour/include/hbstack.h b/harbour/include/hbstack.h index bc4df0755c..23584dd952 100644 --- a/harbour/include/hbstack.h +++ b/harbour/include/hbstack.h @@ -62,10 +62,6 @@ HB_EXTERN_BEGIN -#ifndef HB_NO_DEFAULT_STACK_MACROS - #define HB_STACK_MACROS -#endif - /* stack managed by the virtual machine */ typedef struct { @@ -79,8 +75,6 @@ typedef struct char szDate[ 9 ]; /* last returned date from _pards() yyyymmdd format */ } HB_STACK; -HB_STACK HB_EXPORT hb_GetStack( void ); - extern HB_STACK hb_stack; typedef struct diff --git a/harbour/include/hbsxfunc.h b/harbour/include/hbsxfunc.h index 04ec163b5a..78f439c6d4 100644 --- a/harbour/include/hbsxfunc.h +++ b/harbour/include/hbsxfunc.h @@ -54,6 +54,7 @@ #define HB_SXFUNC_H_ #include "hbapi.h" +#include "hbapiitm.h" #include "hbapifs.h" #include "hbapirdd.h" #include "hbapierr.h" diff --git a/harbour/include/hbvm.h b/harbour/include/hbvm.h index fa6a3ba756..c08b2249ba 100644 --- a/harbour/include/hbvm.h +++ b/harbour/include/hbvm.h @@ -61,6 +61,12 @@ HB_EXTERN_BEGIN extern void HB_EXPORT hb_vmInit( BOOL bStartMainProc ); extern void HB_EXPORT hb_vmQuit( void ); /* Immediately quits the virtual machine */ +/* registration AtInit and AtExit functions - they are executed + * just before (after) .prg INIT (EXIT) procedures. + */ +void HB_EXPORT hb_vmAtInit( HB_INIT_FUNC pFunc, void * cargo ); +void HB_EXPORT hb_vmAtExit( HB_INIT_FUNC pFunc, void * cargo ); + /* Harbour virtual machine functions */ extern void HB_EXPORT hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ); /* invokes the virtual machine */ extern void HB_EXPORT hb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbols ); /* statics symbols initialization */ @@ -88,7 +94,8 @@ extern void hb_vmSend( USHORT uiParams ); /* sends a message to an object */ extern PHB_ITEM hb_vmEvalBlock( PHB_ITEM pBlockItem ); /* executes passed codeblock with no arguments */ /* executes passed codeblock with variable number of arguments */ extern PHB_ITEM hb_vmEvalBlockV( PHB_ITEM pBlockItem, ULONG ulArgCount, ... ); -extern PHB_ITEM hb_vmEvalBlockOrMacro( HB_ITEM_PTR pItem ); /* execute a codeblock or a macro */ +HB_EXPORT extern PHB_ITEM hb_vmEvalBlockOrMacro( PHB_ITEM pItem ); /* executes codeblock or macro pointed by given item */ +HB_EXPORT extern void hb_vmDestroyBlockOrMacro( PHB_ITEM pItem ); /* destroy codeblock or macro in given item */ /* Push */ extern void hb_vmPush( PHB_ITEM pItem ); /* pushes a generic item onto the stack */ @@ -106,8 +113,8 @@ extern void hb_vmPushPointer( void * ); /* push an item of HB_IT_POINTER type /* various flags for supported features */ -#define HB_VMFLAG_HARBOUR 1 /* enable Harbour extension */ -#define HB_VMFLAG_ARRSTR 2 /* support for string as array of bytes -ks */ +#define HB_VMFLAG_HARBOUR 1 /* enable Harbour extension */ +#define HB_VMFLAG_ARRSTR 2 /* support for string as array of bytes -ks */ extern ULONG hb_vmFlagEnabled( ULONG flag); diff --git a/harbour/source/rdd/dbf0.prg b/harbour/include/hbvmopt.h similarity index 74% rename from harbour/source/rdd/dbf0.prg rename to harbour/include/hbvmopt.h index 981ba89077..d2ca9d953d 100644 --- a/harbour/source/rdd/dbf0.prg +++ b/harbour/include/hbvmopt.h @@ -3,10 +3,10 @@ */ /* - * Harbour Project source code: - * DBF RDD module + * xHarbour Project source code: + * Header files to force macro inlining for HVM build * - * Copyright 1999 Bruno Cantero + * Copyright 2005 Przemyslaw Czerpak * www - http://www.harbour-project.org * * This program is free software; you can redistribute it and/or modify @@ -50,14 +50,19 @@ * */ -#include "rddsys.ch" +/* + * This header file enable macro inlining of some functions. + * It should be included before any other hb*.h files. + * !!! Be careful - including this file cause that the final binaries + * can be linked only with exactly the same HVM version for which + * it was compiled and only if exactly the same C compiler switches + * which interacts with alignment are used. [druzus] + */ +#if !defined( HB_NO_DEFAULT_API_MACROS ) && !defined( HB_API_MACROS ) +# define HB_API_MACROS +#endif -ANNOUNCE _DBF +#if !defined( HB_NO_DEFAULT_STACK_MACROS ) && !defined( HB_STACK_MACROS ) +# define HB_STACK_MACROS +#endif -init procedure DBFInit - - REQUEST _DBFC - - rddRegister( "DBF", RDT_FULL ) - -return diff --git a/harbour/include/hbvmpub.h b/harbour/include/hbvmpub.h index 9aae8678c7..6636790fb8 100644 --- a/harbour/include/hbvmpub.h +++ b/harbour/include/hbvmpub.h @@ -93,6 +93,15 @@ typedef struct _HB_DYNS #define HB_DYNS_FUNC( hbfunc ) BOOL hbfunc( PHB_DYNS pDynSymbol, void * Cargo ) typedef HB_DYNS_FUNC( PHB_DYNS_FUNC ); +typedef void (*HB_INIT_FUNC)(void *); +/* List of functions used by hb_vmAtInit()/hb_vmAtExit() */ +typedef struct _HB_FUNC_LIST +{ + HB_INIT_FUNC pFunc; + void * cargo; + struct _HB_FUNC_LIST * pNext; +} HB_FUNC_LIST, * PHB_FUNC_LIST; + /* Harbour Functions scope ( HB_SYMBOLSCOPE ) */ #define HB_FS_PUBLIC ( ( HB_SYMBOLSCOPE ) 0x01 ) #define HB_FS_STATIC ( ( HB_SYMBOLSCOPE ) 0x02 ) diff --git a/harbour/source/codepage/cdp_tpl.c b/harbour/source/codepage/cdp_tpl.c index 91daf8437f..c5a2aea718 100644 --- a/harbour/source/codepage/cdp_tpl.c +++ b/harbour/source/codepage/cdp_tpl.c @@ -91,7 +91,15 @@ static HB_CODEPAGE s_codepage = { "EN", HB_CODEPAGE_INIT( EN ); -#if ! defined(__GNUC__) && ! defined(_MSC_VER) +#if defined(HB_PRAGMA_STARTUP) #pragma startup hb_codepage_Init_EN +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_hb_codepage_Init_EN = hb_codepage_Init_EN; + #pragma data_seg() #endif - diff --git a/harbour/source/codepage/cdppl852.c b/harbour/source/codepage/cdppl852.c index 55dcc52a23..f2b42ce42f 100644 --- a/harbour/source/codepage/cdppl852.c +++ b/harbour/source/codepage/cdppl852.c @@ -92,7 +92,15 @@ static HB_CODEPAGE s_codepage = { "PL852", HB_CODEPAGE_INIT( PL852 ); -#if ! defined(__GNUC__) && ! defined(_MSC_VER) +#if defined(HB_PRAGMA_STARTUP) #pragma startup hb_codepage_Init_PL852 +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_hb_codepage_Init_PL852 = hb_codepage_Init_PL852; + #pragma data_seg() #endif - diff --git a/harbour/source/codepage/cdppliso.c b/harbour/source/codepage/cdppliso.c index 99a2d6dc6e..0a17df8afd 100644 --- a/harbour/source/codepage/cdppliso.c +++ b/harbour/source/codepage/cdppliso.c @@ -92,7 +92,15 @@ static HB_CODEPAGE s_codepage = { "PLISO", HB_CODEPAGE_INIT( PLISO ); -#if ! defined(__GNUC__) && ! defined(_MSC_VER) +#if defined(HB_PRAGMA_STARTUP) #pragma startup hb_codepage_Init_PLISO +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_hb_codepage_Init_PLISO = hb_codepage_Init_PLISO; + #pragma data_seg() #endif - diff --git a/harbour/source/codepage/cdpplmaz.c b/harbour/source/codepage/cdpplmaz.c index 026fe3f0f0..3338b65dc9 100644 --- a/harbour/source/codepage/cdpplmaz.c +++ b/harbour/source/codepage/cdpplmaz.c @@ -92,6 +92,15 @@ static HB_CODEPAGE s_codepage = { "PLMAZ", HB_CODEPAGE_INIT( PLMAZ ); -#if ! defined(__GNUC__) && ! defined(_MSC_VER) +#if defined(HB_PRAGMA_STARTUP) #pragma startup hb_codepage_Init_PLMAZ +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_hb_codepage_Init_PLMAZ = hb_codepage_Init_PLMAZ; + #pragma data_seg() #endif diff --git a/harbour/source/codepage/cdpplwin.c b/harbour/source/codepage/cdpplwin.c index 5dbaf2ea40..406157667d 100644 --- a/harbour/source/codepage/cdpplwin.c +++ b/harbour/source/codepage/cdpplwin.c @@ -92,7 +92,15 @@ static HB_CODEPAGE s_codepage = { "PLWIN", HB_CODEPAGE_INIT( PLWIN ); -#if ! defined(__GNUC__) && ! defined(_MSC_VER) +#if defined(HB_PRAGMA_STARTUP) #pragma startup hb_codepage_Init_PLWIN +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_hb_codepage_Init_PLWIN = hb_codepage_Init_PLWIN; + #pragma data_seg() #endif - diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index 67c32fac5c..917c379ee4 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -33,6 +33,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc, FILE * yyc ); static void hb_compGenCCompact( PFUNCTION pFunc, FILE * yyc ); static void hb_compGenCFunc( FILE *yyc, char *cDecor, char *szName, int iStrip ); +static void hb_writeEndInit( FILE* yyc, char * szModulname ); /* helper structure to pass information */ typedef struct HB_stru_genc_info @@ -221,25 +222,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou pSym = pSym->pNext; } - fprintf( yyc, "\nHB_INIT_SYMBOLS_END( hb_vm_SymbolInit_%s%s )\n" - "#if defined(_MSC_VER)\n" - " #if _MSC_VER >= 1010\n" - /* [pt] First version of MSC I have that supports this */ - /* is msvc4.1 (which is msc 10.10) */ - " #pragma data_seg( \".CRT$XIY\" )\n" - " #pragma comment( linker, \"/Merge:.CRT=.data\" )\n" - " #else\n" - " #pragma data_seg( \"XIY\" )\n" - " #endif\n" - " static HB_$INITSYM hb_vm_auto_SymbolInit_%s%s = hb_vm_SymbolInit_%s%s;\n" - " #pragma data_seg()\n" - "#elif ! defined(__GNUC__)\n" - " #pragma startup hb_vm_SymbolInit_%s%s\n" - "#endif\n\n", - hb_comp_szPrefix, szModulname, - hb_comp_szPrefix, szModulname, - hb_comp_szPrefix, szModulname, - hb_comp_szPrefix, szModulname ); + hb_writeEndInit( yyc, szModulname ); /* Generate functions data */ @@ -377,6 +360,30 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou printf( "Done.\n" ); } +static void hb_writeEndInit( FILE* yyc, char * szModulname ) +{ + fprintf( yyc, "\nHB_INIT_SYMBOLS_END( hb_vm_SymbolInit_%s%s )\n\n" + "#if defined(HB_PRAGMA_STARTUP)\n" + " #pragma startup hb_vm_SymbolInit_%s%s\n" + "#elif defined(HB_MSC_STARTUP)\n" + " #if _MSC_VER >= 1010\n" + /* [pt] First version of MSC I have that supports this */ + /* is msvc4.1 (which is msc 10.10) */ + " #pragma data_seg( \".CRT$XIY\" )\n" + " #pragma comment( linker, \"/Merge:.CRT=.data\" )\n" + " #else\n" + " #pragma data_seg( \"XIY\" )\n" + " #endif\n" + " static HB_$INITSYM hb_vm_auto_SymbolInit_%s%s = hb_vm_SymbolInit_%s%s;\n" + " #pragma data_seg()\n" + "#endif\n\n", + hb_comp_szPrefix, szModulname, + hb_comp_szPrefix, szModulname, + hb_comp_szPrefix, szModulname, + hb_comp_szPrefix, szModulname ); +} + + static void hb_compGenCFunc( FILE * yyc, char *cDecor, char *szName, int iStrip ) { int i=0; diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 8fcefebc91..e8d50c9db1 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -1703,6 +1703,7 @@ void hb_compAnnounce( char * szFunName ) hb_comp_functions.pLast = pFunc; } hb_comp_functions.iCount++; + hb_comp_iFunctionCnt++; /* this function have a very limited functionality */ diff --git a/harbour/source/lang/msgca.c b/harbour/source/lang/msgca.c index a7db66839a..e14da20e5a 100644 --- a/harbour/source/lang/msgca.c +++ b/harbour/source/lang/msgca.c @@ -205,6 +205,16 @@ HB_LANG_ANNOUNCE( CA ); HB_CALL_ON_STARTUP_BEGIN( hb_lang_Init_CA ) hb_langRegister( &s_lang ); HB_CALL_ON_STARTUP_END( hb_lang_Init_CA ) -#if ! defined(__GNUC__) && ! defined(_MSC_VER) + +#if defined(HB_PRAGMA_STARTUP) #pragma startup hb_lang_Init_CA +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_hb_lang_Init_CA = hb_lang_Init_CA; + #pragma data_seg() #endif diff --git a/harbour/source/lang/msgpl852.c b/harbour/source/lang/msgpl852.c index 8ca6808779..e4e32ed811 100644 --- a/harbour/source/lang/msgpl852.c +++ b/harbour/source/lang/msgpl852.c @@ -205,7 +205,16 @@ HB_LANG_ANNOUNCE( PL852 ); HB_CALL_ON_STARTUP_BEGIN( hb_lang_Init_PL852 ) hb_langRegister( &s_lang ); HB_CALL_ON_STARTUP_END( hb_lang_Init_PL852 ) -#if ! defined(__GNUC__) && ! defined(_MSC_VER) - #pragma startup hb_lang_Init_PL852 -#endif +#if defined(HB_PRAGMA_STARTUP) + #pragma startup hb_lang_Init_PL852 +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_hb_lang_Init_PL852 = hb_lang_Init_PL852; + #pragma data_seg() +#endif diff --git a/harbour/source/lang/msgpliso.c b/harbour/source/lang/msgpliso.c index 6b3b451211..a20d1fcd0f 100644 --- a/harbour/source/lang/msgpliso.c +++ b/harbour/source/lang/msgpliso.c @@ -205,7 +205,17 @@ HB_LANG_ANNOUNCE( PLISO ); HB_CALL_ON_STARTUP_BEGIN( hb_lang_Init_PLISO ) hb_langRegister( &s_lang ); HB_CALL_ON_STARTUP_END( hb_lang_Init_PLISO ) -#if ! defined(__GNUC__) && ! defined(_MSC_VER) + +#if defined(HB_PRAGMA_STARTUP) #pragma startup hb_lang_Init_PLISO +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_hb_lang_Init_PLISO = hb_lang_Init_PLISO; + #pragma data_seg() #endif diff --git a/harbour/source/lang/msgplmaz.c b/harbour/source/lang/msgplmaz.c index db3ef2d2a0..5afd4929e6 100644 --- a/harbour/source/lang/msgplmaz.c +++ b/harbour/source/lang/msgplmaz.c @@ -205,7 +205,17 @@ HB_LANG_ANNOUNCE( PLMAZ ); HB_CALL_ON_STARTUP_BEGIN( hb_lang_Init_PLMAZ ) hb_langRegister( &s_lang ); HB_CALL_ON_STARTUP_END( hb_lang_Init_PLMAZ ) -#if ! defined(__GNUC__) && ! defined(_MSC_VER) + +#if defined(HB_PRAGMA_STARTUP) #pragma startup hb_lang_Init_PLMAZ +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_hb_lang_Init_PLMAZ = hb_lang_Init_PLMAZ; + #pragma data_seg() #endif diff --git a/harbour/source/lang/msgplwin.c b/harbour/source/lang/msgplwin.c index 2c259b8d45..e05af3aef8 100644 --- a/harbour/source/lang/msgplwin.c +++ b/harbour/source/lang/msgplwin.c @@ -205,7 +205,17 @@ HB_LANG_ANNOUNCE( PLWIN ); HB_CALL_ON_STARTUP_BEGIN( hb_lang_Init_PLWIN ) hb_langRegister( &s_lang ); HB_CALL_ON_STARTUP_END( hb_lang_Init_PLWIN ) -#if ! defined(__GNUC__) && ! defined(_MSC_VER) + +#if defined(HB_PRAGMA_STARTUP) #pragma startup hb_lang_Init_PLWIN +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_hb_lang_Init_PLWIN = hb_lang_Init_PLWIN; + #pragma data_seg() #endif diff --git a/harbour/source/rdd/Makefile b/harbour/source/rdd/Makefile index 64a863ca83..c6f86562f5 100644 --- a/harbour/source/rdd/Makefile +++ b/harbour/source/rdd/Makefile @@ -14,15 +14,12 @@ C_SOURCES=\ hbdbsort.c \ PRG_SOURCES=\ - dbf0.prg \ dbfuncs.prg \ dbtotal.prg \ dblist.prg \ dbsort.prg \ dbstrux.prg \ dbupdat.prg \ - sdf0.prg \ - delim0.prg \ rddord.prg \ rddsys.prg \ diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index 2e5db0bc67..ad11795a10 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -62,7 +62,11 @@ * */ +/* JC1: optimizing stack access under MT */ +#define HB_THREAD_OPTIMIZE_STACK + #include +#include "hbvmopt.h" #include "hbapi.h" #include "hbstack.h" #include "hbvm.h" @@ -331,11 +335,47 @@ static LPRDDNODE hb_rddFindNode( char * szDriver, USHORT * uiIndex ) return NULL; } +/* + * Get (/set) default RDD driver + */ +static char * hb_rddDefaultDrv( char * szDriver ) +{ + static BOOL fInit = FALSE; + + if( szDriver && *szDriver ) + { + char szNewDriver[ HARBOUR_MAX_RDD_DRIVERNAME_LENGTH + 1 ]; + + hb_strncpyUpper( szNewDriver, szDriver, HARBOUR_MAX_RDD_DRIVERNAME_LENGTH ); + if( !hb_rddFindNode( szNewDriver, NULL ) ) + { + return NULL; + } + strcpy( s_szDefDriver, szNewDriver ); + } + else if( !fInit && !s_szDefDriver[ 0 ] && s_uiRddMax ) + { + char *szDrvTable[] = { "DBFNTX", "DBFCDX", "DBFFPT", "DBF", NULL }; + int i; + + for( i = 0; szDrvTable[ i ]; ++i ) + { + if( hb_rddFindNode( szDrvTable[ i ], NULL ) ) + { + strcpy( s_szDefDriver, szDrvTable[ i ] ); + break; + } + } + fInit = TRUE; + } + + return s_szDefDriver; +} /* * Register a RDD driver. */ -static int hb_rddRegister( char * szDriver, USHORT uiType ) +int HB_EXPORT hb_rddRegister( char * szDriver, USHORT uiType ) { LPRDDNODE pRddNewNode; PHB_DYNS pGetFuncTable; @@ -1567,7 +1607,7 @@ static ERRCODE hb_rddOpenTable( char * szFileName, char * szDriver, } else { - szDriver = s_szDefDriver; + szDriver = hb_rddDefaultDrv( NULL ); } uiPrevArea = hb_rddGetCurrentWorkAreaNumber(); @@ -1635,7 +1675,7 @@ static ERRCODE hb_rddCreateTable( char * szFileName, PHB_ITEM pStruct, } else { - szDriver = s_szDefDriver; + szDriver = hb_rddDefaultDrv( NULL ); } uiPrevArea = hb_rddGetCurrentWorkAreaNumber(); @@ -2139,7 +2179,7 @@ HB_FUNC( DBTABLEEXT ) { LPRDDNODE pRddNode; USHORT uiRddID; - pRddNode = hb_rddFindNode( s_szDefDriver, &uiRddID ); + pRddNode = hb_rddFindNode( hb_rddDefaultDrv( NULL ), &uiRddID ); if( pRddNode ) { pArea = hb_rddNewAreaNode( pRddNode, uiRddID ); @@ -2532,7 +2572,7 @@ HB_FUNC( ORDBAGEXT ) { LPRDDNODE pRddNode; USHORT uiRddID; - pRddNode = hb_rddFindNode( s_szDefDriver, &uiRddID ); + pRddNode = hb_rddFindNode( hb_rddDefaultDrv( NULL ), &uiRddID ); if( pRddNode ) { pArea = hb_rddNewAreaNode( pRddNode, uiRddID ); @@ -3237,7 +3277,6 @@ HB_FUNC( ORDSETFOCUS ) HB_FUNC( RDDLIST ) { - HB_THREAD_STUB USHORT uiType, uiCount, uiRdds = 0, uiIndex = 0; PHB_ITEM pRddArray = hb_itemNew( NULL ); @@ -3419,26 +3458,15 @@ HB_FUNC( RDDSETDEFAULT ) { HB_THREAD_STUB - USHORT uiLen; - char szNewDriver[ HARBOUR_MAX_RDD_DRIVERNAME_LENGTH + 1 ]; + hb_retc( hb_rddDefaultDrv( NULL ) ); - hb_retc( s_szDefDriver ); - - uiLen = ( USHORT ) hb_parclen( 1 ); - - if( uiLen > 0 ) + if( hb_parclen( 1 ) > 0 ) { - if( uiLen > HARBOUR_MAX_RDD_DRIVERNAME_LENGTH ) - { - uiLen = HARBOUR_MAX_RDD_DRIVERNAME_LENGTH; - } - hb_strncpyUpper( szNewDriver, hb_parc( 1 ), uiLen ); - if( ! hb_rddFindNode( szNewDriver, NULL ) ) + if( ! hb_rddDefaultDrv( hb_parc( 1 ) ) ) { hb_errRT_DBCMD( EG_ARG, EDBCMD_BADPARAMETER, NULL, "RDDSETDEFAULT" ); return; } - strcpy( s_szDefDriver, szNewDriver ); } } @@ -3446,26 +3474,15 @@ HB_FUNC( DBSETDRIVER ) { HB_THREAD_STUB - USHORT uiLen; - char szNewDriver[ HARBOUR_MAX_RDD_DRIVERNAME_LENGTH + 1 ]; + hb_retc( hb_rddDefaultDrv( NULL ) ); - hb_retc( s_szDefDriver ); - - uiLen = ( USHORT ) hb_parclen( 1 ); - - if( uiLen > 0 ) + if( hb_parclen( 1 ) > 0 ) { - if( uiLen > HARBOUR_MAX_RDD_DRIVERNAME_LENGTH ) - { - uiLen = HARBOUR_MAX_RDD_DRIVERNAME_LENGTH; - } - hb_strncpyUpper( szNewDriver, hb_parc( 1 ), uiLen ); - if( !hb_rddFindNode( szNewDriver, NULL ) ) + if( ! hb_rddDefaultDrv( hb_parc( 1 ) ) ) { hb_errRT_DBCMD( EG_ARG, EDBCMD_BADPARAMETER, NULL, "DBSETDRIVER" ); return; } - strcpy( s_szDefDriver, szNewDriver ); } } @@ -3938,7 +3955,7 @@ HB_FUNC( DBDROP ) szDriver = hb_parc( 3 ); if( !szDriver ) /* no VIA RDD parameter, use default */ { - szDriver = s_szDefDriver; + szDriver = hb_rddDefaultDrv( NULL ); } pRDDNode = hb_rddFindNode( szDriver, &uiRddID ); /* find the RDDNODE */ @@ -3963,7 +3980,7 @@ HB_FUNC( DBEXISTS ) szDriver = hb_parc( 3 ); if( !szDriver ) /* no VIA RDD parameter, use default */ { - szDriver = s_szDefDriver; + szDriver = hb_rddDefaultDrv( NULL ); } pRDDNode = hb_rddFindNode( szDriver, &uiRddID ); // find the RDD @@ -3989,7 +4006,7 @@ HB_FUNC( RDDINFO ) szDriver = hb_parc( 3 ); if( !szDriver ) /* no VIA RDD parameter, use default */ { - szDriver = s_szDefDriver; + szDriver = hb_rddDefaultDrv( NULL ); } ulConnection = hb_parnl( 4 ); @@ -4223,7 +4240,7 @@ static ERRCODE hb_rddTransRecords( AREAP pArea, if( errCode == SUCCESS ) { - hb_rddSelectWorkAreaNumber( lpaSource->uiArea ); + hb_rddSelectWorkAreaNumber( dbTransInfo.lpaSource->uiArea ); dbTransInfo.dbsci.itmCobFor = pCobFor; dbTransInfo.dbsci.lpstrFor = pStrFor; @@ -4239,7 +4256,7 @@ static ERRCODE hb_rddTransRecords( AREAP pArea, dbTransInfo.dbsci.fIgnoreDuplicates = FALSE; dbTransInfo.dbsci.fBackword = FALSE; - errCode = SELF_TRANS( lpaSource, &dbTransInfo ); + errCode = SELF_TRANS( dbTransInfo.lpaSource, &dbTransInfo ); } if( dbTransInfo.lpTransItems ) @@ -4339,7 +4356,6 @@ HB_FUNC( __RDDGETTEMPALIAS ) hb_ret(); } -#if defined(__XHARBOUR__) HB_FUNC( DBSKIPPER ) { HB_THREAD_STUB @@ -4398,7 +4414,6 @@ HB_FUNC( DBSKIPPER ) else hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, "DBSKIPPER" ); } -#endif // Escaping delimited strings. Need to be cleaned/optimized/improved static char *hb_strescape( char *szInput, int lLen, char *cDelim ) diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index 826fc15a04..23372bf654 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -65,6 +65,7 @@ #include "hbdbsort.h" #include "hbsxfunc.h" #include "error.ch" +#include "rddsys.ch" #ifndef HB_CDP_SUPPORT_OFF # include "hbapicdp.h" @@ -74,33 +75,6 @@ #include #endif -#define __PRG_SOURCE__ __FILE__ - -HB_FUNC( _DBFC ); -HB_FUNC( DBF_GETFUNCTABLE ); -#define __PRG_SOURCE__ __FILE__ -#undef HB_PRG_PCODE_VER -#define HB_PRG_PCODE_VER HB_PCODE_VER - - -HB_INIT_SYMBOLS_BEGIN( dbf1__InitSymbols ) -{ "_DBFC", HB_FS_PUBLIC, {HB_FUNCNAME( _DBFC )}, NULL }, -{ "DBF_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( DBF_GETFUNCTABLE )}, NULL } -HB_INIT_SYMBOLS_END( dbf1__InitSymbols ) - -#if defined(HB_PRAGMA_STARTUP) - #pragma startup dbf1__InitSymbols -#elif defined(HB_MSC_STARTUP) - #if _MSC_VER >= 1010 - #pragma data_seg( ".CRT$XIY" ) - #pragma comment( linker, "/Merge:.CRT=.data" ) - #else - #pragma data_seg( "XIY" ) - #endif - static HB_$INITSYM hb_vm_auto_dbf1__InitSymbols = dbf1__InitSymbols; - #pragma data_seg() -#endif - static USHORT s_uiRddId = ( USHORT ) -1; static RDDFUNCS dbfSuper; static RDDFUNCS dbfTable = { ( DBENTRYP_BP ) hb_dbfBof, @@ -4375,7 +4349,7 @@ static ERRCODE hb_dbfRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P } -HB_FUNC( _DBFC ) { ; } +HB_FUNC( _DBF ) { ; } HB_FUNC( DBF_GETFUNCTABLE ) { @@ -4408,3 +4382,45 @@ HB_FUNC( DBF_GETFUNCTABLE ) else hb_retni( FAILURE ); } + + +#define __PRG_SOURCE__ __FILE__ + +#ifdef HB_PCODE_VER + #undef HB_PRG_PCODE_VER + #define HB_PRG_PCODE_VER HB_PCODE_VER +#endif + +static void hb_dbfRddInit( void * cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + + if( hb_rddRegister( "DBF", RDT_FULL ) > 1 ) + { + hb_errInternal( HB_EI_RDDINVALID, NULL, NULL, NULL ); + } +} + +HB_INIT_SYMBOLS_BEGIN( dbf1__InitSymbols ) +{ "_DBF", HB_FS_PUBLIC, {HB_FUNCNAME( _DBF )}, NULL }, +{ "DBF_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( DBF_GETFUNCTABLE )}, NULL } +HB_INIT_SYMBOLS_END( dbf1__InitSymbols ) + +HB_CALL_ON_STARTUP_BEGIN( _hb_dbf_rdd_init_ ) + hb_vmAtInit( hb_dbfRddInit, NULL ); +HB_CALL_ON_STARTUP_END( _hb_dbf_rdd_init_ ) + +#if defined(HB_PRAGMA_STARTUP) + #pragma startup dbf1__InitSymbols + #pragma startup _hb_dbf_rdd_init_ +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_dbf1__InitSymbols = dbf1__InitSymbols; + static HB_$INITSYM hb_vm_auto_dbf_rdd_init = _hb_dbf_rdd_init_; + #pragma data_seg() +#endif diff --git a/harbour/source/rdd/dbfcdx/Makefile b/harbour/source/rdd/dbfcdx/Makefile index 3f3edbea4d..9c1039bf39 100644 --- a/harbour/source/rdd/dbfcdx/Makefile +++ b/harbour/source/rdd/dbfcdx/Makefile @@ -8,14 +8,6 @@ C_SOURCES=\ dbfcdx1.c \ sixcdx1.c \ -PRG_SOURCES=\ - dbfcdx0.prg \ - sixcdx0.prg \ - -ifeq ($(HB_MT),MT) - MT_LIBNAME=$(LIBNAME)mt -endif - LIBNAME=dbfcdx include $(TOP)$(ROOT)config/lib.cf diff --git a/harbour/source/rdd/dbfcdx/dbfcdx0.prg b/harbour/source/rdd/dbfcdx/dbfcdx0.prg deleted file mode 100644 index a88d148da8..0000000000 --- a/harbour/source/rdd/dbfcdx/dbfcdx0.prg +++ /dev/null @@ -1,66 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * DBFCDX RDD (ver.2) - * - * Copyright 1999 Bruno Cantero - * Copyright 2003 Przemyslaw Czerpak - * www - http://www.xharbour.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include "rddsys.ch" - -ANNOUNCE DBFCDX - -procedure DBFCDXInit - - REQUEST _DBF - REQUEST _DBFCDX - - rddRegister( "DBF", RDT_FULL ) - rddRegister( "DBFCDX", RDT_FULL ) - -return diff --git a/harbour/source/rdd/dbfcdx/dbfcdx1.c b/harbour/source/rdd/dbfcdx/dbfcdx1.c index e0c5baa6d9..cabe7a05fc 100644 --- a/harbour/source/rdd/dbfcdx/dbfcdx1.c +++ b/harbour/source/rdd/dbfcdx/dbfcdx1.c @@ -61,7 +61,6 @@ # define HB_CDX_PACKTRAIL #endif - #define HB_CDX_DBGCODE /* #define HB_CDX_DBGCODE_EXT @@ -72,9 +71,7 @@ */ #include "hbapi.h" -#ifdef HB_NO_DEFAULT_API_MACROS #include "hbapiitm.h" -#endif #include "hbinit.h" #include "hbapierr.h" #include "hbapilng.h" @@ -82,6 +79,7 @@ #include "hbset.h" #include "hbrddcdx.h" #include "hbmath.h" +#include "rddsys.ch" #ifdef __XHARBOUR__ #include "hbregex.h" #endif @@ -98,13 +96,6 @@ */ #endif -#define __PRG_SOURCE__ __FILE__ -#ifdef HB_PCODE_VER - #undef HB_PRG_PCODE_VER - #define HB_PRG_PCODE_VER HB_PCODE_VER -#endif - - /* * Tag->fRePos = TURE means that rootPage->...->childLeafPage path is * bad and has to be reloaded @@ -293,113 +284,6 @@ static RDDFUNCS cdxTable = ( DBENTRYP_SVP ) hb_cdxWhoCares }; -#if defined( HB_SIXCDX ) - -HB_FUNC( _SIXCDX ) {;} - -HB_FUNC( SIXCDX_GETFUNCTABLE ) -{ - RDDFUNCS * pTable; - USHORT * uiCount, uiRddId; - - uiCount = ( USHORT * ) hb_itemGetPtr( hb_param( 1, HB_IT_POINTER ) ); - pTable = ( RDDFUNCS * ) hb_itemGetPtr( hb_param( 2, HB_IT_POINTER ) ); - uiRddId = hb_parni( 4 ); - - HB_TRACE(HB_TR_DEBUG, ("SIXCDX_GETFUNCTABLE(%i, %p)", uiCount, pTable)); - - if ( pTable ) - { - ERRCODE errCode; - - if ( uiCount ) - * uiCount = RDDFUNCSCOUNT; - errCode = hb_rddInherit( pTable, &cdxTable, &cdxSuper, ( BYTE * ) "DBFFPT" ); - if ( errCode != SUCCESS ) - errCode = hb_rddInherit( pTable, &cdxTable, &cdxSuper, ( BYTE * ) "DBFDBT" ); - if ( errCode != SUCCESS ) - errCode = hb_rddInherit( pTable, &cdxTable, &cdxSuper, ( BYTE * ) "DBF" ); - hb_retni( errCode ); - if ( errCode == SUCCESS ) - { - /* - * we successfully register our RDD so now we can initialize it - * You may think that this place is RDD init statement, Druzus - */ - s_uiRddId = uiRddId; - } - } - else - hb_retni( FAILURE ); -} - - -HB_INIT_SYMBOLS_BEGIN( dbfcdx1__InitSymbols ) -{ "_SIXCDX", HB_FS_PUBLIC, {HB_FUNCNAME( _SIXCDX )}, NULL }, -{ "SIXCDX_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( SIXCDX_GETFUNCTABLE )}, NULL } -HB_INIT_SYMBOLS_END( dbfcdx1__InitSymbols ) - -#else - -HB_FUNC( _DBFCDX ) {;} - -HB_FUNC( DBFCDX_GETFUNCTABLE ) -{ - RDDFUNCS * pTable; - USHORT * uiCount, uiRddId; - - uiCount = ( USHORT * ) hb_itemGetPtr( hb_param( 1, HB_IT_POINTER ) ); - pTable = ( RDDFUNCS * ) hb_itemGetPtr( hb_param( 2, HB_IT_POINTER ) ); - uiRddId = hb_parni( 4 ); - - HB_TRACE(HB_TR_DEBUG, ("DBFCDX_GETFUNCTABLE(%i, %p)", uiCount, pTable)); - - if ( pTable ) - { - ERRCODE errCode; - - if ( uiCount ) - * uiCount = RDDFUNCSCOUNT; - errCode = hb_rddInherit( pTable, &cdxTable, &cdxSuper, ( BYTE * ) "DBFFPT" ); - if ( errCode != SUCCESS ) - errCode = hb_rddInherit( pTable, &cdxTable, &cdxSuper, ( BYTE * ) "DBFDBT" ); - if ( errCode != SUCCESS ) - errCode = hb_rddInherit( pTable, &cdxTable, &cdxSuper, ( BYTE * ) "DBF" ); - if ( errCode == SUCCESS ) - { - /* - * we successfully register our RDD so now we can initialize it - * You may think that this place is RDD init statement, Druzus - */ - s_uiRddId = uiRddId; - } - hb_retni( errCode ); - } - else - hb_retni( FAILURE ); -} - - -HB_INIT_SYMBOLS_BEGIN( dbfcdx1__InitSymbols ) -{ "_DBFCDX", HB_FS_PUBLIC, {HB_FUNCNAME( _DBFCDX )}, NULL }, -{ "DBFCDX_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( DBFCDX_GETFUNCTABLE )}, NULL } -HB_INIT_SYMBOLS_END( dbfcdx1__InitSymbols ) - -#endif - -#if defined(HB_PRAGMA_STARTUP) - #pragma startup dbfcdx1__InitSymbols -#elif defined(HB_MSC_STARTUP) - #if _MSC_VER >= 1010 - #pragma data_seg( ".CRT$XIY" ) - #pragma comment( linker, "/Merge:.CRT=.data" ) - #else - #pragma data_seg( "XIY" ) - #endif - static HB_$INITSYM hb_vm_auto_dbfcdx1__InitSymbols = dbfcdx1__InitSymbols; - #pragma data_seg() -#endif - #ifdef HB_CDX_DSPDBG_INFO static void hb_cdxDspTags( LPCDXINDEX pIndex ) @@ -831,16 +715,6 @@ static PHB_ITEM hb_cdxKeyGetItem( LPCDXKEY pKey, PHB_ITEM pItem, LPCDXTAG pTag, return pItem; } -/* - * destroy compiled expression - */ -static void hb_cdxDestroyExp( PHB_ITEM pExp ) -{ - if ( hb_itemType( pExp ) != HB_IT_BLOCK ) - hb_macroDelete( ( HB_MACRO_PTR ) hb_itemGetPtr( pExp ) ); - hb_itemRelease( pExp ); -} - /* * evaluate key expression and create new Key from the result */ @@ -3176,8 +3050,8 @@ static int hb_cdxPageKeyIntBalance( LPCDXPAGE pPage, int iChildRet ) #if 1 if ( iNeedKeys == 1 && iBlncKeys > 1 && childs[0]->Left != CDX_DUMMYNODE && childs[iBlncKeys-1]->Right != CDX_DUMMYNODE && - iKeys >= CDX_BALANCE_INTPAGES << 1 && - iKeys > pPage->TagParent->MaxKeys * 3 >> 1 ) + iKeys >= ( CDX_BALANCE_INTPAGES << 1 ) && + iKeys > ( pPage->TagParent->MaxKeys * 3 ) >> 1 ) { iNeedKeys = 2; } @@ -3685,11 +3559,11 @@ static void hb_cdxTagFree( LPCDXTAG pTag ) if ( pTag->KeyExpr != NULL ) hb_xfree( pTag->KeyExpr ); if ( pTag->pKeyItem != NULL ) - hb_cdxDestroyExp( pTag->pKeyItem ); + hb_vmDestroyBlockOrMacro( pTag->pKeyItem ); if ( pTag->ForExpr != NULL ) hb_xfree( pTag->ForExpr ); if ( pTag->pForItem != NULL ) - hb_cdxDestroyExp( pTag->pForItem ); + hb_vmDestroyBlockOrMacro( pTag->pForItem ); hb_cdxKeyFree( pTag->CurKey ); if ( pTag->HotKey ) hb_cdxKeyFree( pTag->HotKey ); @@ -5424,6 +5298,14 @@ static BOOL hb_cdxDBOISkipWild( CDXAREAP pArea, LPCDXTAG pTag, BOOL fForward, return fForward ? pArea->fPositioned : !pArea->fBof; } +#ifndef HB_CDP_SUPPORT_OFF + if( pArea->cdPage != hb_cdp_page ) + { + szPattern = hb_strdup( szPattern ); + hb_cdpTranslate( szPattern, hb_cdp_page, pArea->cdPage ); + } +#endif + if( pArea->lpdbPendingRel ) SELF_FORCEREL( ( AREAP ) pArea ); @@ -5493,10 +5375,36 @@ static BOOL hb_cdxDBOISkipWild( CDXAREAP pArea, LPCDXTAG pTag, BOOL fForward, else pArea->fEof = FALSE; +#ifndef HB_CDP_SUPPORT_OFF + if( pArea->cdPage != hb_cdp_page ) + { + hb_xfree( szPattern ); + } +#endif + return fFound; } #if defined(__XHARBOUR__) + +static BOOL hb_cdxRegexMatch( CDXAREAP pArea, PHB_REGEX pRegEx, LPCDXKEY pKey ) +{ + char * szKey = ( char * ) pKey->val; +#ifndef HB_CDP_SUPPORT_OFF + char szBuff[ CDX_MAXKEY + 1 ]; + + if( pArea->cdPage != hb_cdp_page ) + { + hb_strncpy( szBuff, szKey, pKey->len ); + hb_cdpnTranslate( szBuff, pArea->cdPage, hb_cdp_page, pKey->len ); + szKey = szBuff; + } +#else + HB_SYMBOL_UNUSED( pArea ); +#endif + return hb_regexMatch( pRegEx, szKey, FALSE ); +} + /* * skip while regular expression on index key val doesn't return TRUE */ @@ -5537,12 +5445,12 @@ static BOOL hb_cdxDBOISkipRegEx( CDXAREAP pArea, LPCDXTAG pTag, BOOL fForward, hb_cdxTagSkipNext( pTag ); while ( !pTag->TagEOF ) { - if( hb_regexMatch( &RegEx, (const char *) pTag->CurKey->val, FALSE ) ) + if( hb_cdxRegexMatch( pArea, &RegEx, pTag->CurKey ) ) { ULONG ulRecNo = pArea->ulRecNo; SELF_SKIPFILTER( ( AREAP ) pArea, 1 ); if ( pArea->ulRecNo == ulRecNo || - hb_regexMatch( &RegEx, (const char *) pTag->CurKey->val, FALSE ) ) + hb_cdxRegexMatch( pArea, &RegEx, pTag->CurKey ) ) { fFound = TRUE; break; @@ -5558,12 +5466,12 @@ static BOOL hb_cdxDBOISkipRegEx( CDXAREAP pArea, LPCDXTAG pTag, BOOL fForward, hb_cdxTagSkipPrev( pTag ); while ( !pTag->TagBOF ) { - if( hb_regexMatch( &RegEx, (const char *) pTag->CurKey->val, FALSE ) ) + if( hb_cdxRegexMatch( pArea, &RegEx, pTag->CurKey ) ) { ULONG ulRecNo = pArea->ulRecNo; SELF_SKIPFILTER( ( AREAP ) pArea, -1 ); if ( pArea->ulRecNo == ulRecNo || - hb_regexMatch( &RegEx, (const char *) pTag->CurKey->val, FALSE ) ) + hb_cdxRegexMatch( pArea, &RegEx, pTag->CurKey ) ) { fFound = TRUE; break; @@ -7300,7 +7208,7 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo SELF_GOTO( ( AREAP ) pArea, 0 ); if ( SELF_EVALBLOCK( ( AREAP ) pArea, pKeyExp ) == FAILURE ) { - hb_cdxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); SELF_GOTO( ( AREAP ) pArea, ulRecNo ); return FAILURE; } @@ -7328,7 +7236,7 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo if ( bType == 'U' || uiLen == 0 ) { - hb_cdxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); SELF_GOTO( ( AREAP ) pArea, ulRecNo ); hb_cdxErrorRT( pArea, bType == 'U' ? EG_DATATYPE : EG_DATAWIDTH, 1026, NULL, 0, 0 ); @@ -7351,7 +7259,7 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo /* Otherwise, try compiling the conditional expression string */ if ( SELF_COMPILE( (AREAP) pArea, pArea->lpdbOrdCondInfo->abFor ) == FAILURE ) { - hb_cdxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); SELF_GOTO( ( AREAP ) pArea, ulRecNo ); return FAILURE; } @@ -7362,24 +7270,24 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo /* Test conditional expression */ if ( pForExp ) { - USHORT uiType; + BOOL fOK; if ( SELF_EVALBLOCK( ( AREAP ) pArea, pForExp ) == FAILURE ) { - hb_cdxDestroyExp( pKeyExp ); - hb_cdxDestroyExp( pForExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); + hb_vmDestroyBlockOrMacro( pForExp ); SELF_GOTO( ( AREAP ) pArea, ulRecNo ); return FAILURE; } - uiType = hb_itemType( pArea->valResult ); + fOK = hb_itemType( pArea->valResult ) == HB_IT_LOGICAL; hb_itemRelease( pArea->valResult ); pArea->valResult = NULL; - if ( uiType != HB_IT_LOGICAL ) + if ( ! fOK ) { - hb_cdxDestroyExp( pKeyExp ); - hb_cdxDestroyExp( pForExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); + hb_vmDestroyBlockOrMacro( pForExp ); SELF_GOTO( ( AREAP ) pArea, ulRecNo ); - /* TODO: !!! runtime error ? */ + hb_cdxErrorRT( pArea, EG_DATATYPE, EDBF_INVALIDFOR, NULL, 0, 0 ); return FAILURE; } } @@ -7499,9 +7407,9 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo if ( hFile == FS_ERROR ) { - hb_cdxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); if ( pForExp != NULL ) - hb_cdxDestroyExp( pForExp ); + hb_vmDestroyBlockOrMacro( pForExp ); return FAILURE; } } @@ -7786,7 +7694,7 @@ static ERRCODE hb_cdxOrderInfo( CDXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pO } if ( pTag->pForItem != NULL ) { - hb_cdxDestroyExp( pTag->pForItem ); + hb_vmDestroyBlockOrMacro( pTag->pForItem ); pTag->pForItem = NULL; } if ( hb_itemGetCLen( pOrderInfo->itmNewVal ) > 0 ) @@ -7808,7 +7716,7 @@ static ERRCODE hb_cdxOrderInfo( CDXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pO pArea->valResult = NULL; } if ( pForItem ) - hb_cdxDestroyExp( pForItem ); + hb_vmDestroyBlockOrMacro( pForItem ); } } } @@ -9195,3 +9103,160 @@ static void hb_cdxTagDoIndex( LPCDXTAG pTag, BOOL fReindex ) hb_cdp_page = cdpTmp; #endif } + +#define __PRG_SOURCE__ __FILE__ +#ifdef HB_PCODE_VER + #undef HB_PRG_PCODE_VER + #define HB_PRG_PCODE_VER HB_PCODE_VER +#endif + +HB_FUNC_EXTERN( _DBF ); + +#if defined( HB_SIXCDX ) + +HB_FUNC( SIXCDX ) {;} + +HB_FUNC( SIXCDX_GETFUNCTABLE ) +{ + RDDFUNCS * pTable; + USHORT * uiCount, uiRddId; + + uiCount = ( USHORT * ) hb_itemGetPtr( hb_param( 1, HB_IT_POINTER ) ); + pTable = ( RDDFUNCS * ) hb_itemGetPtr( hb_param( 2, HB_IT_POINTER ) ); + uiRddId = hb_parni( 4 ); + + HB_TRACE(HB_TR_DEBUG, ("SIXCDX_GETFUNCTABLE(%i, %p)", uiCount, pTable)); + + if ( pTable ) + { + ERRCODE errCode; + + if ( uiCount ) + * uiCount = RDDFUNCSCOUNT; + errCode = hb_rddInherit( pTable, &cdxTable, &cdxSuper, ( BYTE * ) "DBFFPT" ); + if ( errCode != SUCCESS ) + errCode = hb_rddInherit( pTable, &cdxTable, &cdxSuper, ( BYTE * ) "DBFDBT" ); + if ( errCode != SUCCESS ) + errCode = hb_rddInherit( pTable, &cdxTable, &cdxSuper, ( BYTE * ) "DBF" ); + hb_retni( errCode ); + if ( errCode == SUCCESS ) + { + /* + * we successfully register our RDD so now we can initialize it + * You may think that this place is RDD init statement, Druzus + */ + s_uiRddId = uiRddId; + } + } + else + hb_retni( FAILURE ); +} + +static void hb_dbfcdxRddInit( void * cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + + if( hb_rddRegister( "DBF", RDT_FULL ) <= 1 ) + { + hb_rddRegister( "DBFFPT", RDT_FULL ); + if( hb_rddRegister( "SIXCDX", RDT_FULL ) <= 1 ) + { + return; + } + } + + hb_errInternal( HB_EI_RDDINVALID, NULL, NULL, NULL ); + + /* not executed, only to force DBF RDD linking */ + HB_FUNC_EXEC( _DBF ); +} + +HB_INIT_SYMBOLS_BEGIN( dbfcdx1__InitSymbols ) +{ "SIXCDX", HB_FS_PUBLIC, {HB_FUNCNAME( SIXCDX )}, NULL }, +{ "SIXCDX_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( SIXCDX_GETFUNCTABLE )}, NULL } +HB_INIT_SYMBOLS_END( dbfcdx1__InitSymbols ) + +#else + +HB_FUNC( DBFCDX ) {;} + +HB_FUNC( DBFCDX_GETFUNCTABLE ) +{ + RDDFUNCS * pTable; + USHORT * uiCount, uiRddId; + + uiCount = ( USHORT * ) hb_itemGetPtr( hb_param( 1, HB_IT_POINTER ) ); + pTable = ( RDDFUNCS * ) hb_itemGetPtr( hb_param( 2, HB_IT_POINTER ) ); + uiRddId = hb_parni( 4 ); + + HB_TRACE(HB_TR_DEBUG, ("DBFCDX_GETFUNCTABLE(%i, %p)", uiCount, pTable)); + + if ( pTable ) + { + ERRCODE errCode; + + if ( uiCount ) + * uiCount = RDDFUNCSCOUNT; + errCode = hb_rddInherit( pTable, &cdxTable, &cdxSuper, ( BYTE * ) "DBFFPT" ); + if ( errCode != SUCCESS ) + errCode = hb_rddInherit( pTable, &cdxTable, &cdxSuper, ( BYTE * ) "DBFDBT" ); + if ( errCode != SUCCESS ) + errCode = hb_rddInherit( pTable, &cdxTable, &cdxSuper, ( BYTE * ) "DBF" ); + if ( errCode == SUCCESS ) + { + /* + * we successfully register our RDD so now we can initialize it + * You may think that this place is RDD init statement, Druzus + */ + s_uiRddId = uiRddId; + } + hb_retni( errCode ); + } + else + hb_retni( FAILURE ); +} + +static void hb_dbfcdxRddInit( void * cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + + if( hb_rddRegister( "DBF", RDT_FULL ) <= 1 ) + { + hb_rddRegister( "DBFFPT", RDT_FULL ); + if( hb_rddRegister( "DBFCDX", RDT_FULL ) <= 1 ) + { + return; + } + } + + hb_errInternal( HB_EI_RDDINVALID, NULL, NULL, NULL ); + + /* not executed, only to force DBF RDD linking */ + HB_FUNC_EXEC( _DBF ); +} + +HB_INIT_SYMBOLS_BEGIN( dbfcdx1__InitSymbols ) +{ "DBFCDX", HB_FS_PUBLIC, {HB_FUNCNAME( DBFCDX )}, NULL }, +{ "DBFCDX_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( DBFCDX_GETFUNCTABLE )}, NULL } +HB_INIT_SYMBOLS_END( dbfcdx1__InitSymbols ) + +#endif + +HB_CALL_ON_STARTUP_BEGIN( _hb_dbfcdx_rdd_init_ ) + hb_vmAtInit( hb_dbfcdxRddInit, NULL ); +HB_CALL_ON_STARTUP_END( _hb_dbfcdx_rdd_init_ ) + +#if defined(HB_PRAGMA_STARTUP) +# pragma startup dbfcdx1__InitSymbols +# pragma startup _hb_dbfcdx_rdd_init_ +#elif defined(HB_MSC_STARTUP) +# if _MSC_VER >= 1010 +# pragma data_seg( ".CRT$XIY" ) +# pragma comment( linker, "/Merge:.CRT=.data" ) +# else +# pragma data_seg( "XIY" ) +# endif + static HB_$INITSYM hb_vm_auto_dbfcdx1__InitSymbols = dbfcdx1__InitSymbols; + static HB_$INITSYM hb_vm_auto_dbfcdx_rdd_init = _hb_dbfcdx_rdd_init_; +# pragma data_seg() +#endif diff --git a/harbour/source/rdd/dbfcdx/sixcdx0.prg b/harbour/source/rdd/dbfcdx/sixcdx0.prg deleted file mode 100644 index 8a4f791124..0000000000 --- a/harbour/source/rdd/dbfcdx/sixcdx0.prg +++ /dev/null @@ -1,66 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * DBFCDX RDD (ver.2) - * - * Copyright 1999 Bruno Cantero - * Copyright 2003 Przemyslaw Czerpak - * www - http://www.xharbour.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include "rddsys.ch" - -ANNOUNCE SIXCDX - -procedure SIXCDXInit - - REQUEST _DBF - REQUEST _SIXCDX - - rddRegister( "DBF", RDT_FULL ) - rddRegister( "SIXCDX", RDT_FULL ) - -return diff --git a/harbour/source/rdd/dbfdbt/Makefile b/harbour/source/rdd/dbfdbt/Makefile index 6ead7c8ed6..e60e39d8f8 100644 --- a/harbour/source/rdd/dbfdbt/Makefile +++ b/harbour/source/rdd/dbfdbt/Makefile @@ -7,14 +7,6 @@ ROOT = ../../../ C_SOURCES=\ dbfdbt1.c \ -PRG_SOURCES=\ - dbfdbt0.prg \ - -ifeq ($(HB_MT),MT) - MT_LIBNAME=dbfdbtmt -endif - - LIBNAME=dbfdbt include $(TOP)$(ROOT)config/lib.cf diff --git a/harbour/source/rdd/dbfdbt/dbfdbt0.prg b/harbour/source/rdd/dbfdbt/dbfdbt0.prg deleted file mode 100644 index 01b9ee49eb..0000000000 --- a/harbour/source/rdd/dbfdbt/dbfdbt0.prg +++ /dev/null @@ -1,64 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * DBFDBT RDD - * - * Copyright 2003 Przemyslaw Czerpak - * www - http://www.xharbour.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include "rddsys.ch" - -ANNOUNCE DBFDBT - -procedure DBFDBTInit - - REQUEST _DBFDBT - - rddRegister( "DBF", RDT_FULL ) - rddRegister( "DBFDBT", RDT_FULL ) - -return diff --git a/harbour/source/rdd/dbfdbt/dbfdbt1.c b/harbour/source/rdd/dbfdbt/dbfdbt1.c index 1aeedb18ec..bddc44d16c 100644 --- a/harbour/source/rdd/dbfdbt/dbfdbt1.c +++ b/harbour/source/rdd/dbfdbt/dbfdbt1.c @@ -54,23 +54,20 @@ */ #include "hbapi.h" +#include "hbapiitm.h" #include "hbinit.h" #include "hbapierr.h" #include "hbapilng.h" #include "hbset.h" +#include "hbvm.h" #include "hbdate.h" #include "hbrdddbt.h" +#include "rddsys.ch" #ifndef HB_CDP_SUPPORT_OFF # include "hbapicdp.h" #endif -#define __PRG_SOURCE__ __FILE__ -#ifdef HB_PCODE_VER -# undef HB_PRG_PCODE_VER -# define HB_PRG_PCODE_VER HB_PCODE_VER -#endif - static RDDFUNCS dbtSuper; static RDDFUNCS dbtTable = { @@ -221,47 +218,6 @@ static RDDFUNCS dbtTable = }; -HB_FUNC( _DBFDBT ) {;} - -HB_FUNC( DBFDBT_GETFUNCTABLE ) -{ - RDDFUNCS * pTable; - USHORT * uiCount; - - uiCount = ( USHORT * ) hb_itemGetPtr( hb_param( 1, HB_IT_POINTER ) ); - pTable = ( RDDFUNCS * ) hb_itemGetPtr( hb_param( 2, HB_IT_POINTER ) ); - - HB_TRACE(HB_TR_DEBUG, ("DBFDBT_GETFUNCTABLE(%i, %p)", uiCount, pTable)); - - if( pTable ) - { - if ( uiCount ) - * uiCount = RDDFUNCSCOUNT; - hb_retni( hb_rddInherit( pTable, &dbtTable, &dbtSuper, ( BYTE * ) "DBF" ) ); - } - else - hb_retni( FAILURE ); -} - - -HB_INIT_SYMBOLS_BEGIN( dbfdbt1__InitSymbols ) -{ "_DBFDBT", HB_FS_PUBLIC, {HB_FUNCNAME( _DBFDBT )}, NULL }, -{ "DBFDBT_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( DBFDBT_GETFUNCTABLE )}, NULL } -HB_INIT_SYMBOLS_END( dbfdbt1__InitSymbols ) - -#if defined(HB_PRAGMA_STARTUP) -# pragma startup dbfdbt1__InitSymbols -#elif defined(HB_MSC_STARTUP) -# if _MSC_VER >= 1010 -# pragma data_seg( ".CRT$XIY" ) -# pragma comment( linker, "/Merge:.CRT=.data" ) -# else -# pragma data_seg( "XIY" ) -# endif - static HB_$INITSYM hb_vm_auto_dbfdbt1__InitSymbols = dbfdbt1__InitSymbols; -# pragma data_seg() -#endif - /* * Exclusive lock memo file. */ @@ -844,3 +800,74 @@ static ERRCODE hb_dbtRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P return SUCCESS; } + + +HB_FUNC( DBFDBT ) {;} + +HB_FUNC( DBFDBT_GETFUNCTABLE ) +{ + RDDFUNCS * pTable; + USHORT * uiCount; + + uiCount = ( USHORT * ) hb_itemGetPtr( hb_param( 1, HB_IT_POINTER ) ); + pTable = ( RDDFUNCS * ) hb_itemGetPtr( hb_param( 2, HB_IT_POINTER ) ); + + HB_TRACE(HB_TR_DEBUG, ("DBFDBT_GETFUNCTABLE(%i, %p)", uiCount, pTable)); + + if( pTable ) + { + if ( uiCount ) + * uiCount = RDDFUNCSCOUNT; + hb_retni( hb_rddInherit( pTable, &dbtTable, &dbtSuper, ( BYTE * ) "DBF" ) ); + } + else + hb_retni( FAILURE ); +} + + +#define __PRG_SOURCE__ __FILE__ + +#ifdef HB_PCODE_VER +# undef HB_PRG_PCODE_VER +# define HB_PRG_PCODE_VER HB_PCODE_VER +#endif + +HB_FUNC_EXTERN( _DBF ); + +static void hb_dbfdbtRddInit( void * cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + + if( hb_rddRegister( "DBF", RDT_FULL ) > 1 || + hb_rddRegister( "DBFDBT", RDT_FULL ) > 1 ) + { + hb_errInternal( HB_EI_RDDINVALID, NULL, NULL, NULL ); + + /* not executed, only to force DBF RDD linking */ + HB_FUNC_EXEC( _DBF ); + } +} + +HB_INIT_SYMBOLS_BEGIN( dbfdbt1__InitSymbols ) +{ "DBFDBT", HB_FS_PUBLIC, {HB_FUNCNAME( DBFDBT )}, NULL }, +{ "DBFDBT_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( DBFDBT_GETFUNCTABLE )}, NULL } +HB_INIT_SYMBOLS_END( dbfdbt1__InitSymbols ) + +HB_CALL_ON_STARTUP_BEGIN( _hb_dbfdbt_rdd_init_ ) + hb_vmAtInit( hb_dbfdbtRddInit, NULL ); +HB_CALL_ON_STARTUP_END( _hb_dbfdbt_rdd_init_ ) + +#if defined(HB_PRAGMA_STARTUP) +# pragma startup dbfdbt1__InitSymbols +# pragma startup _hb_dbfdbt_rdd_init_ +#elif defined(HB_MSC_STARTUP) +# if _MSC_VER >= 1010 +# pragma data_seg( ".CRT$XIY" ) +# pragma comment( linker, "/Merge:.CRT=.data" ) +# else +# pragma data_seg( "XIY" ) +# endif + static HB_$INITSYM hb_vm_auto_dbfdbt1__InitSymbols = dbfdbt1__InitSymbols; + static HB_$INITSYM hb_vm_auto_dbfdbt_rdd_init = _hb_dbfdbt_rdd_init_; +# pragma data_seg() +#endif diff --git a/harbour/source/rdd/dbffpt/Makefile b/harbour/source/rdd/dbffpt/Makefile index a12a0f0d05..cc94ce3faf 100644 --- a/harbour/source/rdd/dbffpt/Makefile +++ b/harbour/source/rdd/dbffpt/Makefile @@ -7,13 +7,6 @@ ROOT = ../../../ C_SOURCES=\ dbffpt1.c \ -PRG_SOURCES=\ - dbffpt0.prg \ - -ifeq ($(HB_MT),MT) - MT_LIBNAME=dbffptmt -endif - LIBNAME=dbffpt include $(TOP)$(ROOT)config/lib.cf diff --git a/harbour/source/rdd/dbffpt/dbffpt0.prg b/harbour/source/rdd/dbffpt/dbffpt0.prg deleted file mode 100644 index 135e50d632..0000000000 --- a/harbour/source/rdd/dbffpt/dbffpt0.prg +++ /dev/null @@ -1,69 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * DBFFPT RDD - * - * Copyright 2003 Przemyslaw Czerpak - * www - http://www.xharbour.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include "rddsys.ch" - -ANNOUNCE DBFFPT - -procedure DBFFPTInit - - REQUEST _DBF - REQUEST _DBFFPT - - rddRegister( "DBF", RDT_FULL ) - rddRegister( "DBFFPT", RDT_FULL ) - -return - -/* to satisfy old code which has: REQUEST DBFDBT */ -proc DBFDBT -return diff --git a/harbour/source/rdd/dbffpt/dbffpt1.c b/harbour/source/rdd/dbffpt/dbffpt1.c index 66864d8120..1fe83c6200 100644 --- a/harbour/source/rdd/dbffpt/dbffpt1.c +++ b/harbour/source/rdd/dbffpt/dbffpt1.c @@ -62,9 +62,7 @@ #endif #include "hbapi.h" -#ifdef HB_NO_DEFAULT_API_MACROS #include "hbapiitm.h" -#endif #include "hbinit.h" #include "hbapierr.h" #include "hbapilng.h" @@ -73,17 +71,12 @@ #include "hbdate.h" #include "hbrddfpt.h" #include "hbsxfunc.h" +#include "rddsys.ch" #ifndef HB_CDP_SUPPORT_OFF # include "hbapicdp.h" #endif -#define __PRG_SOURCE__ __FILE__ -#ifdef HB_PCODE_VER -# undef HB_PRG_PCODE_VER -# define HB_PRG_PCODE_VER HB_PCODE_VER -#endif - static RDDFUNCS fptSuper; static RDDFUNCS fptTable = { @@ -233,47 +226,6 @@ static RDDFUNCS fptTable = ( DBENTRYP_SVP ) hb_fptWhoCares }; -HB_FUNC( _DBFFPT ) {;} - -HB_FUNC( DBFFPT_GETFUNCTABLE ) -{ - RDDFUNCS * pTable; - USHORT * uiCount; - - uiCount = ( USHORT * ) hb_itemGetPtr( hb_param( 1, HB_IT_POINTER ) ); - pTable = ( RDDFUNCS * ) hb_itemGetPtr( hb_param( 2, HB_IT_POINTER ) ); - - HB_TRACE(HB_TR_DEBUG, ("DBFFPT_GETFUNCTABLE(%i, %p)", uiCount, pTable)); - - if( pTable ) - { - if ( uiCount ) - * uiCount = RDDFUNCSCOUNT; - hb_retni( hb_rddInherit( pTable, &fptTable, &fptSuper, ( BYTE * ) "DBF" ) ); - } - else - hb_retni( FAILURE ); -} - - -HB_INIT_SYMBOLS_BEGIN( dbffpt1__InitSymbols ) -{ "_DBFFPT", HB_FS_PUBLIC, {HB_FUNCNAME( _DBFFPT )}, NULL }, -{ "DBFFPT_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( DBFFPT_GETFUNCTABLE )}, NULL } -HB_INIT_SYMBOLS_END( dbffpt1__InitSymbols ) - -#if defined(HB_PRAGMA_STARTUP) -# pragma startup dbffpt1__InitSymbols -#elif defined(HB_MSC_STARTUP) -# if _MSC_VER >= 1010 -# pragma data_seg( ".CRT$XIY" ) -# pragma comment( linker, "/Merge:.CRT=.data" ) -# else -# pragma data_seg( "XIY" ) -# endif - static HB_$INITSYM hb_vm_auto_dbffpt1__InitSymbols = dbffpt1__InitSymbols; -# pragma data_seg() -#endif - /* * generate Run-Time error */ @@ -1183,10 +1135,8 @@ static ULONG hb_fptCountSMTItemLength( FPTAREAP pArea, PHB_ITEM pItem, ULONG * pulArrayCount ) { ULONG ulLen, i, ulSize; - USHORT usType; - usType = hb_itemType( pItem ); - switch( usType ) + switch( hb_itemType( pItem ) ) { case HB_IT_ARRAY: // HB_IT_OBJECT = HB_IT_ARRAY (*pulArrayCount)++; @@ -1584,10 +1534,8 @@ static ULONG hb_fptCountSixItemLength( FPTAREAP pArea, PHB_ITEM pItem, ULONG * pulArrayCount ) { ULONG ulLen, i, ulSize; - USHORT usType; - usType = hb_itemType( pItem ); - switch ( usType ) + switch ( hb_itemType( pItem ) ) { case HB_IT_ARRAY: // HB_IT_OBJECT = HB_IT_ARRAY (*pulArrayCount)++; @@ -1630,16 +1578,14 @@ static ULONG hb_fptCountSixItemLength( FPTAREAP pArea, PHB_ITEM pItem, */ static ULONG hb_fptStoreSixItem( FPTAREAP pArea, PHB_ITEM pItem, BYTE ** bBufPtr ) { - USHORT usType; ULONG ulLen, i, ulSize; HB_LONG iVal; int iWidth, iDec; PHB_ITEM pTmpItem; memset( *bBufPtr, '\0', SIX_ITEM_BUFSIZE ); - usType = hb_itemType( pItem ); ulSize = SIX_ITEM_BUFSIZE; - switch ( usType ) + switch ( hb_itemType( pItem ) ) { case HB_IT_ARRAY: // HB_IT_OBJECT = HB_IT_ARRAY HB_PUT_LE_UINT16( &(*bBufPtr)[0], FPTIT_SIX_ARRAY ); @@ -1825,11 +1771,9 @@ static ULONG hb_fptCountFlexItemLength( FPTAREAP pArea, PHB_ITEM pItem, ULONG * pulArrayCount ) { ULONG ulLen, i, ulSize = 1; - USHORT usType; HB_LONG iVal; - usType = hb_itemType( pItem ); - switch ( usType ) + switch ( hb_itemType( pItem ) ) { case HB_IT_ARRAY: (*pulArrayCount)++; @@ -1870,11 +1814,9 @@ static ULONG hb_fptCountFlexItemLength( FPTAREAP pArea, PHB_ITEM pItem, static void hb_fptStoreFlexItem( FPTAREAP pArea, PHB_ITEM pItem, BYTE ** bBufPtr ) { ULONG ulLen, i; - USHORT usType; HB_LONG iVal; - usType = hb_itemType( pItem ); - switch ( usType ) + switch ( hb_itemType( pItem ) ) { case HB_IT_ARRAY: ulLen = hb_arrayLen( pItem ) & 0xFFFF; @@ -2663,7 +2605,6 @@ static ERRCODE hb_fptPutMemo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) } else if( pArea->uiMemoVersion == DB_MEMOVER_SIX ) { - ulType = hb_itemType( pItem ); ulSize = hb_fptCountSixItemLength( pArea, pItem, &ulArrayCount ); if ( ulSize > 0 ) { @@ -2672,11 +2613,14 @@ static ERRCODE hb_fptPutMemo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) ulType = ( ULONG ) HB_GET_LE_UINT16( bBufAlloc ); bBufPtr = bBufAlloc; } + else + { + return EDBF_DATATYPE; + } } else if ( pArea->uiMemoVersion == DB_MEMOVER_FLEX ) { - ulType = hb_itemType( pItem ); - switch ( ulType ) + switch ( hb_itemType( pItem ) ) { case HB_IT_ARRAY: ulType = FPTIT_FLEX_ARRAY; @@ -3719,9 +3663,17 @@ static ERRCODE hb_fptPutValueFile( FPTAREAP pArea, USHORT uiIndex, BYTE * szFile } else { + ULONG ulSize, ulBlock, ulType, ulOldSize, ulOldType; HB_FOFFSET size = hb_fsSeekLarge( hFile, 0, FS_END ); - ULONG ulSize = HB_MIN( size, 0xFFFFFFFF - sizeof( FPTBLOCK ) ), - ulBlock, ulType, ulOldSize, ulOldType; + + if( ( size & 0xFFFFFFFF ) == size ) + { + ulSize = HB_MIN( ( ULONG ) size, 0xFFFFFFFFUL - sizeof( FPTBLOCK ) ); + } + else + { + ulSize = HB_MIN( size, ( HB_FOFFSET ) ( 0xFFFFFFFF - sizeof( FPTBLOCK ) ) ); + } if( pArea->bMemoType == DB_MEMO_SMT ) ulType = SMT_IT_CHAR; @@ -4022,3 +3974,76 @@ static ERRCODE hb_fptRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P return SUCCESS; } + +/* for backward compatibility */ +HB_FUNC( DBFDBT ) {;} + +HB_FUNC( DBFFPT ) {;} + +HB_FUNC( DBFFPT_GETFUNCTABLE ) +{ + RDDFUNCS * pTable; + USHORT * uiCount; + + uiCount = ( USHORT * ) hb_itemGetPtr( hb_param( 1, HB_IT_POINTER ) ); + pTable = ( RDDFUNCS * ) hb_itemGetPtr( hb_param( 2, HB_IT_POINTER ) ); + + HB_TRACE(HB_TR_DEBUG, ("DBFFPT_GETFUNCTABLE(%i, %p)", uiCount, pTable)); + + if( pTable ) + { + if ( uiCount ) + * uiCount = RDDFUNCSCOUNT; + hb_retni( hb_rddInherit( pTable, &fptTable, &fptSuper, ( BYTE * ) "DBF" ) ); + } + else + hb_retni( FAILURE ); +} + + +#define __PRG_SOURCE__ __FILE__ + +#ifdef HB_PCODE_VER +# undef HB_PRG_PCODE_VER +# define HB_PRG_PCODE_VER HB_PCODE_VER +#endif + +HB_FUNC_EXTERN( _DBF ); + +static void hb_dbffptRddInit( void * cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + + if( hb_rddRegister( "DBF", RDT_FULL ) > 1 || + hb_rddRegister( "DBFFPT", RDT_FULL ) > 1 ) + { + hb_errInternal( HB_EI_RDDINVALID, NULL, NULL, NULL ); + + /* not executed, only to force DBF RDD linking */ + HB_FUNC_EXEC( _DBF ); + } +} + +HB_INIT_SYMBOLS_BEGIN( dbffpt1__InitSymbols ) +{ "DBFFPT", HB_FS_PUBLIC, {HB_FUNCNAME( DBFFPT )}, NULL }, +{ "DBFFPT_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( DBFFPT_GETFUNCTABLE )}, NULL } +HB_INIT_SYMBOLS_END( dbffpt1__InitSymbols ) + +HB_CALL_ON_STARTUP_BEGIN( _hb_dbffpt_rdd_init_ ) + hb_vmAtInit( hb_dbffptRddInit, NULL ); +HB_CALL_ON_STARTUP_END( _hb_dbffpt_rdd_init_ ) + +#if defined(HB_PRAGMA_STARTUP) +# pragma startup dbffpt1__InitSymbols +# pragma startup _hb_dbffpt_rdd_init_ +#elif defined(HB_MSC_STARTUP) +# if _MSC_VER >= 1010 +# pragma data_seg( ".CRT$XIY" ) +# pragma comment( linker, "/Merge:.CRT=.data" ) +# else +# pragma data_seg( "XIY" ) +# endif + static HB_$INITSYM hb_vm_auto_dbffpt1__InitSymbols = dbffpt1__InitSymbols; + static HB_$INITSYM hb_vm_auto_dbffpt_rdd_init = _hb_dbffpt_rdd_init_; +# pragma data_seg() +#endif diff --git a/harbour/source/rdd/dbfntx/Makefile b/harbour/source/rdd/dbfntx/Makefile index 56d3c565ac..21c0b8db05 100644 --- a/harbour/source/rdd/dbfntx/Makefile +++ b/harbour/source/rdd/dbfntx/Makefile @@ -7,13 +7,6 @@ ROOT = ../../../ C_SOURCES=\ dbfntx1.c \ -PRG_SOURCES=\ - dbfntx0.prg \ - -ifeq ($(HB_MT),MT) - MT_LIBNAME=dbfntxmt -endif - LIBNAME=dbfntx include $(TOP)$(ROOT)config/lib.cf diff --git a/harbour/source/rdd/dbfntx/dbfntx0.prg b/harbour/source/rdd/dbfntx/dbfntx0.prg index e692ddfc20..dd4c581f0d 100644 --- a/harbour/source/rdd/dbfntx/dbfntx0.prg +++ b/harbour/source/rdd/dbfntx/dbfntx0.prg @@ -50,6 +50,7 @@ * */ +/* #include "error.ch" #include "rddsys.ch" #include "dbinfo.ch" @@ -66,6 +67,7 @@ procedure DBFNTXInit rddInfo( RDDI_MEMOTYPE, DB_MEMO_DBT, "DBFNTX" ) return +*/ /* NOTE: Commented out, because in Harbour the INIT order is not guaranteed, so it can happen that this error handler will be installed *before* diff --git a/harbour/source/rdd/dbfntx/dbfntx1.c b/harbour/source/rdd/dbfntx/dbfntx1.c index 011a8ada27..7080c961bb 100644 --- a/harbour/source/rdd/dbfntx/dbfntx1.c +++ b/harbour/source/rdd/dbfntx/dbfntx1.c @@ -132,9 +132,7 @@ */ #include "hbapi.h" -#ifdef HB_NO_DEFAULT_API_MACROS #include "hbapiitm.h" -#endif #include "hbinit.h" #include "hbapierr.h" #include "hbapilng.h" @@ -142,6 +140,7 @@ #include "hbset.h" #include "hbmath.h" #include "hbrddntx.h" +#include "rddsys.ch" #ifdef __XHARBOUR__ #include "hbregex.h" #endif @@ -149,34 +148,6 @@ #include "hbapicdp.h" #endif -#define __PRG_SOURCE__ __FILE__ - -#ifdef HB_PCODE_VER - #undef HB_PRG_PCODE_VER - #define HB_PRG_PCODE_VER HB_PCODE_VER -#endif - -HB_FUNC( _DBFNTX ); -HB_FUNC( DBFNTX_GETFUNCTABLE ); - -HB_INIT_SYMBOLS_BEGIN( dbfntx1__InitSymbols ) -{ "_DBFNTX", HB_FS_PUBLIC, {HB_FUNCNAME( _DBFNTX )}, 0 }, -{ "DBFNTX_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( DBFNTX_GETFUNCTABLE)} , 0 } -HB_INIT_SYMBOLS_END( dbfntx1__InitSymbols ) - -#if defined(HB_PRAGMA_STARTUP) - #pragma startup dbfntx1__InitSymbols -#elif defined(HB_MSC_STARTUP) - #if _MSC_VER >= 1010 - #pragma data_seg( ".CRT$XIY" ) - #pragma comment( linker, "/Merge:.CRT=.data" ) - #else - #pragma data_seg( "XIY" ) - #endif - static HB_$INITSYM hb_vm_auto_dbfntx1__InitSymbols = dbfntx1__InitSymbols; - #pragma data_seg() -#endif - #ifdef HB_NTX_DEBUG_DISP static ULONG s_rdNO = 0; static ULONG s_wrNO = 0; @@ -468,6 +439,8 @@ static LPKEYINFO hb_ntxKeyPutItem( LPKEYINFO pKey, PHB_ITEM pItem, ULONG ulRecNo #ifndef HB_CDP_SUPPORT_OFF if( fTrans ) hb_cdpnTranslate( pKey->key, hb_cdp_page, pTag->Owner->Owner->cdPage, pTag->KeyLength ); +#else + HB_SYMBOL_UNUSED( fTrans ); #endif break; case 'N': @@ -511,6 +484,8 @@ static PHB_ITEM hb_ntxKeyGetItem( PHB_ITEM pItem, LPKEYINFO pKey, pItem = hb_itemPutCPtr( pItem, pVal, pTag->KeyLength ); } else +#else + HB_SYMBOL_UNUSED( fTrans ); #endif { pItem = hb_itemPutCL( pItem, pKey->key, pTag->KeyLength ); @@ -540,16 +515,6 @@ static PHB_ITEM hb_ntxKeyGetItem( PHB_ITEM pItem, LPKEYINFO pKey, return pItem; } -/* - * destroy compiled expression - */ -static void hb_ntxDestroyExp( PHB_ITEM pExp ) -{ - if( hb_itemType( pExp ) != HB_IT_BLOCK ) - hb_macroDelete( ( HB_MACRO_PTR ) hb_itemGetPtr( pExp ) ); - hb_itemRelease( pExp ); -} - /* * evaluate conditional expression and return the logical result */ @@ -1471,9 +1436,9 @@ static void hb_ntxTagFree( LPTAGINFO pTag ) if( pTag->ForExpr ) hb_xfree( pTag->ForExpr ); if( pTag->pKeyItem ) - hb_ntxDestroyExp( pTag->pKeyItem ); + hb_vmDestroyBlockOrMacro( pTag->pKeyItem ); if( pTag->pForItem ) - hb_ntxDestroyExp( pTag->pForItem ); + hb_vmDestroyBlockOrMacro( pTag->pForItem ); if( pTag->HotKeyInfo ) hb_ntxKeyFree( pTag->HotKeyInfo ); hb_ntxKeyFree( pTag->CurKeyInfo ); @@ -1559,7 +1524,7 @@ static LPTAGINFO hb_ntxTagLoad( LPNTXINDEX pIndex, ULONG ulBlock, { if( SELF_COMPILE( ( AREAP ) pIndex->Owner, lpNTX->for_expr ) == FAILURE ) { - hb_ntxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); return NULL; } pForExp = pIndex->Owner->valResult; @@ -3014,7 +2979,7 @@ static BOOL hb_ntxTagKeyDel( LPTAGINFO pTag, LPKEYINFO pKey ) while( iLevel > 0 ) { - if( pPage->uiKeys < pTag->MaxKeys >> 1 ) + if( pPage->uiKeys < ( pTag->MaxKeys >> 1 ) ) { USHORT uiFirst, uiLast, uiBaseKey; @@ -4079,6 +4044,14 @@ static BOOL hb_ntxOrdSkipWild( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pWildItm return fForward ? !pArea->fEof : !pArea->fBof; } +#ifndef HB_CDP_SUPPORT_OFF + if( pArea->cdPage != hb_cdp_page ) + { + szPattern = hb_strdup( szPattern ); + hb_cdpTranslate( szPattern, hb_cdp_page, pArea->cdPage ); + } +#endif + if( pArea->lpdbPendingRel ) SELF_FORCEREL( ( AREAP ) pArea ); @@ -4138,10 +4111,35 @@ static BOOL hb_ntxOrdSkipWild( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pWildItm else pArea->fEof = FALSE; +#ifndef HB_CDP_SUPPORT_OFF + if( pArea->cdPage != hb_cdp_page ) + { + hb_xfree( szPattern ); + } +#endif + return fFound; } #if defined(__XHARBOUR__) + +static BOOL hb_ntxRegexMatch( LPTAGINFO pTag, PHB_REGEX pRegEx, char * szKey ) +{ +#ifndef HB_CDP_SUPPORT_OFF + char szBuff[ NTX_MAX_KEY + 1 ]; + + if( pTag->Owner->Owner->cdPage != hb_cdp_page ) + { + hb_strncpy( szBuff, pTag->CurKeyInfo->key, pTag->KeyLength ); + hb_cdpnTranslate( szBuff, pTag->Owner->Owner->cdPage, hb_cdp_page, pTag->KeyLength ); + szKey = szBuff; + } +#else + HB_SYMBOL_UNUSED( pTag ); +#endif + return hb_regexMatch( pRegEx, szKey, FALSE ); +} + /* * skip while regular expression on index key val doesn't return TRUE */ @@ -4182,12 +4180,13 @@ static BOOL hb_ntxOrdSkipRegEx( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pRegExIt { if( SELF_GOTO( ( AREAP ) pArea, pTag->CurKeyInfo->Xtra ) != SUCCESS ) break; - if( hb_regexMatch( &RegEx, (const char *) pTag->CurKeyInfo->key, FALSE ) ) + + if( hb_ntxRegexMatch( pTag, &RegEx, ( char * ) pTag->CurKeyInfo->key ) ) { ULONG ulRecNo = pArea->ulRecNo; SELF_SKIPFILTER( ( AREAP ) pArea, fForward ? 1 : -1 ); if( pArea->ulRecNo == ulRecNo || - hb_regexMatch( &RegEx, (const char *) pTag->CurKeyInfo->key, FALSE ) ) + hb_ntxRegexMatch( pTag, &RegEx, ( char * ) pTag->CurKeyInfo->key ) ) { fFound = TRUE; break; @@ -4243,7 +4242,7 @@ static BOOL hb_ntxOrdKeyAdd( LPTAGINFO pTag, PHB_ITEM pItem ) { if( pArea->lpdbPendingRel ) SELF_FORCEREL( ( AREAP ) pArea ); - pKey = hb_ntxKeyPutItem( NULL, pItem, pArea->ulRecNo, pTag, FALSE, NULL ); + pKey = hb_ntxKeyPutItem( NULL, pItem, pArea->ulRecNo, pTag, TRUE, NULL ); } else { @@ -4283,7 +4282,7 @@ static BOOL hb_ntxOrdKeyDel( LPTAGINFO pTag, PHB_ITEM pItem ) { if( pArea->lpdbPendingRel ) SELF_FORCEREL( ( AREAP ) pArea ); - pKey = hb_ntxKeyPutItem( NULL, pItem, pArea->ulRecNo, pTag, FALSE, NULL ); + pKey = hb_ntxKeyPutItem( NULL, pItem, pArea->ulRecNo, pTag, TRUE, NULL ); } else { @@ -5939,7 +5938,7 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) errCode = SELF_EVALBLOCK( ( AREAP ) pArea, pKeyExp ); if( errCode != SUCCESS ) { - hb_ntxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); SELF_GOTO( ( AREAP ) pArea, ulRecNo ); return errCode; } @@ -5974,7 +5973,7 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) /* Make sure KEY has proper type and iLen is not 0 */ if( bType == 'U' || iLen == 0 ) { - hb_ntxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); SELF_GOTO( ( AREAP ) pArea, ulRecNo ); hb_ntxErrorRT( pArea, bType == 'U' ? EG_DATATYPE : EG_DATAWIDTH, 1026, NULL, 0, 0 ); @@ -5998,7 +5997,7 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) errCode = SELF_COMPILE( ( AREAP ) pArea, ( BYTE * ) szFor ); if( errCode != SUCCESS ) { - hb_ntxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); SELF_GOTO( ( AREAP ) pArea, ulRecNo ); return errCode; } @@ -6010,23 +6009,23 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) /* Test conditional expression */ if( pForExp ) { - USHORT uiType; + BOOL fOK; errCode = SELF_EVALBLOCK( ( AREAP ) pArea, pForExp ); if( errCode != SUCCESS ) { - hb_ntxDestroyExp( pKeyExp ); - hb_ntxDestroyExp( pForExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); + hb_vmDestroyBlockOrMacro( pForExp ); SELF_GOTO( ( AREAP ) pArea, ulRecNo ); return errCode; } - uiType = hb_itemType( pArea->valResult ); + fOK = hb_itemType( pArea->valResult ) == HB_IT_LOGICAL; hb_itemRelease( pArea->valResult ); pArea->valResult = NULL; - if( uiType != HB_IT_LOGICAL ) + if( ! fOK ) { - hb_ntxDestroyExp( pKeyExp ); - hb_ntxDestroyExp( pForExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); + hb_vmDestroyBlockOrMacro( pForExp ); SELF_GOTO( ( AREAP ) pArea, ulRecNo ); hb_ntxErrorRT( pArea, EG_DATATYPE, EDBF_INVALIDFOR, NULL, 0, 0 ); return FAILURE; @@ -6078,18 +6077,18 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) { if( pIndex->fReadonly ) { - hb_ntxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); if( pForExp != NULL ) - hb_ntxDestroyExp( pForExp ); + hb_vmDestroyBlockOrMacro( pForExp ); hb_ntxErrorRT( pArea, EG_READONLY, EDBF_READONLY, pIndex->IndexName, 0, 0 ); return FAILURE; } #if 0 /* enable this code if you want to forbid tag deleting in shared mode */ else if( pIndex->fShared ) { - hb_ntxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); if( pForExp != NULL ) - hb_ntxDestroyExp( pForExp ); + hb_vmDestroyBlockOrMacro( pForExp ); hb_ntxErrorRT( pArea, EG_SHARED, EDBF_SHARED, pIndex->IndexName, 0, 0 ); return FAILURE; } @@ -6129,9 +6128,9 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) if( hFile == FS_ERROR ) { - hb_ntxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); if( pForExp != NULL ) - hb_ntxDestroyExp( pForExp ); + hb_vmDestroyBlockOrMacro( pForExp ); /* hb_ntxSetTagNumbers() */ return FAILURE; } @@ -6167,9 +6166,9 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) { *pIndexPtr = pIndex->pNext; hb_ntxIndexFree( pIndex ); - hb_ntxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); if( pForExp != NULL ) - hb_ntxDestroyExp( pForExp ); + hb_vmDestroyBlockOrMacro( pForExp ); /* hb_ntxSetTagNumbers() */ hb_ntxErrorRT( pArea, EG_CORRUPTION, EDBF_CORRUPT, szFileName, 0, 0 ); return errCode; @@ -6186,9 +6185,9 @@ static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) if( ! iTag && pIndex->iTags == CTX_MAX_TAGS ) { - hb_ntxDestroyExp( pKeyExp ); + hb_vmDestroyBlockOrMacro( pKeyExp ); if( pForExp != NULL ) - hb_ntxDestroyExp( pForExp ); + hb_vmDestroyBlockOrMacro( pForExp ); /* hb_ntxSetTagNumbers() */ hb_ntxErrorRT( pArea, EG_LIMIT, EDBF_LIMITEXCEEDED, pIndex->IndexName, 0, 0 ); return FAILURE; @@ -6531,7 +6530,7 @@ static ERRCODE ntxOrderInfo( NTXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pInfo if( pTag->ForExpr ) hb_xfree( pTag->ForExpr ); if( pTag->pForItem ) - hb_ntxDestroyExp( pTag->pForItem ); + hb_vmDestroyBlockOrMacro( pTag->pForItem ); if( pForItem ) { pTag->ForExpr = hb_strndup( szForExpr, NTX_MAX_EXP ); @@ -6549,7 +6548,7 @@ static ERRCODE ntxOrderInfo( NTXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pInfo hb_ntxTagUnLockWrite( pTag ); } if( pForItem ) - hb_ntxDestroyExp( pForItem ); + hb_vmDestroyBlockOrMacro( pForItem ); } } break; @@ -6746,10 +6745,14 @@ static ERRCODE ntxOrderInfo( NTXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pInfo hb_itemPutNI( pInfo->itmResult, pTag->KeyDec ); break; case DBOI_KEYVAL: - if( hb_ntxCurKeyRefresh( pTag ) ) - hb_ntxKeyGetItem( pInfo->itmResult, pTag->CurKeyInfo, pTag, TRUE ); - else - hb_itemClear( pInfo->itmResult ); + if( hb_ntxTagLockRead( pTag ) ) + { + if( hb_ntxCurKeyRefresh( pTag ) ) + hb_ntxKeyGetItem( pInfo->itmResult, pTag->CurKeyInfo, pTag, TRUE ); + else + hb_itemClear( pInfo->itmResult ); + hb_ntxTagUnLockRead( pTag ); + } break; case DBOI_SKIPUNIQUE: hb_itemPutL( pInfo->itmResult, hb_ntxOrdSkipUnique( pTag, @@ -7390,7 +7393,7 @@ static RDDFUNCS ntxTable = { ntxBof, ntxWhoCares }; -HB_FUNC(_DBFNTX ) {;} +HB_FUNC( DBFNTX ) {;} HB_FUNC( DBFNTX_GETFUNCTABLE ) { @@ -7427,3 +7430,65 @@ HB_FUNC( DBFNTX_GETFUNCTABLE ) hb_retni( FAILURE ); } } + + +#define __PRG_SOURCE__ __FILE__ + +#ifdef HB_PCODE_VER +# undef HB_PRG_PCODE_VER +# define HB_PRG_PCODE_VER HB_PCODE_VER +#endif + +HB_FUNC_EXTERN( _DBF ); + +static void hb_dbfntxRddInit( void * cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + + if( hb_rddRegister( "DBF", RDT_FULL ) <= 1 ) + { + USHORT usResult; + + hb_rddRegister( "DBFFPT", RDT_FULL ); + usResult = hb_rddRegister( "DBFNTX", RDT_FULL ); + if( usResult <= 1 ) + { + if( usResult == 0 ) + { + PHB_ITEM pItem = hb_itemPutNI( NULL, DB_MEMO_DBT ); + SELF_RDDINFO( hb_rddGetNode( s_uiRddId ), RDDI_MEMOTYPE, 0, pItem ); + hb_itemRelease( pItem ); + } + return; + } + } + + hb_errInternal( HB_EI_RDDINVALID, NULL, NULL, NULL ); + + /* not executed, only to force DBF RDD linking */ + HB_FUNC_EXEC( _DBF ); +} + +HB_INIT_SYMBOLS_BEGIN( dbfntx1__InitSymbols ) +{ "DBFNTX", HB_FS_PUBLIC, {HB_FUNCNAME( DBFNTX )}, NULL }, +{ "DBFNTX_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( DBFNTX_GETFUNCTABLE )}, NULL } +HB_INIT_SYMBOLS_END( dbfntx1__InitSymbols ) + +HB_CALL_ON_STARTUP_BEGIN( _hb_dbfntx_rdd_init_ ) + hb_vmAtInit( hb_dbfntxRddInit, NULL ); +HB_CALL_ON_STARTUP_END( _hb_dbfntx_rdd_init_ ) + +#if defined(HB_PRAGMA_STARTUP) +# pragma startup dbfntx1__InitSymbols +# pragma startup _hb_dbfntx_rdd_init_ +#elif defined(HB_MSC_STARTUP) +# if _MSC_VER >= 1010 +# pragma data_seg( ".CRT$XIY" ) +# pragma comment( linker, "/Merge:.CRT=.data" ) +# else +# pragma data_seg( "XIY" ) +# endif + static HB_$INITSYM hb_vm_auto_dbfntx1__InitSymbols = dbfntx1__InitSymbols; + static HB_$INITSYM hb_vm_auto_dbfntx_rdd_init = _hb_dbfntx_rdd_init_; +# pragma data_seg() +#endif diff --git a/harbour/source/rdd/delim0.prg b/harbour/source/rdd/delim0.prg deleted file mode 100644 index 5fe8f5fd42..0000000000 --- a/harbour/source/rdd/delim0.prg +++ /dev/null @@ -1,63 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * DELIMITED RDD module - * - * Copyright 1999 Bruno Cantero - * www - http://www.harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include "rddsys.ch" - -ANNOUNCE DELIM - -init procedure DELIMInit - - REQUEST _DELIM - - rddRegister( "DELIM", RDT_TRANSFER ) - -return diff --git a/harbour/source/rdd/delim1.c b/harbour/source/rdd/delim1.c index 420f75304b..1a3e1bfacf 100644 --- a/harbour/source/rdd/delim1.c +++ b/harbour/source/rdd/delim1.c @@ -55,33 +55,9 @@ #include "hbvm.h" #include "hbapirdd.h" #include "hbapiitm.h" +#include "hbapierr.h" #include "hbrdddel.h" - -#define __PRG_SOURCE__ __FILE__ - -HB_FUNC( _DELIM ); -HB_FUNC( DELIM_GETFUNCTABLE ); - -#undef HB_PRG_PCODE_VER -#define HB_PRG_PCODE_VER HB_PCODE_VER - -HB_INIT_SYMBOLS_BEGIN( delim1__InitSymbols ) -{ "_DELIM", HB_FS_PUBLIC, {HB_FUNCNAME( _DELIM )}, NULL }, -{ "DELIM_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( DELIM_GETFUNCTABLE )}, NULL } -HB_INIT_SYMBOLS_END( delim1__InitSymbols ) - -#if defined(HB_PRAGMA_STARTUP) - #pragma startup delim1__InitSymbols -#elif defined(HB_MSC_STARTUP) - #if _MSC_VER >= 1010 - #pragma data_seg( ".CRT$XIY" ) - #pragma comment( linker, "/Merge:.CRT=.data" ) - #else - #pragma data_seg( "XIY" ) - #endif - static HB_$INITSYM hb_vm_auto_delim1__InitSymbols = delim1__InitSymbols; - #pragma data_seg() -#endif +#include "rddsys.ch" static RDDFUNCS delimSuper; static RDDFUNCS delimTable = { hb_delimBof, @@ -191,7 +167,7 @@ static RDDFUNCS delimTable = { hb_delimBof, */ -HB_FUNC( _DELIM ) { ; } +HB_FUNC( DELIM ) { ; } HB_FUNC( DELIM_GETFUNCTABLE ) { @@ -209,3 +185,48 @@ HB_FUNC( DELIM_GETFUNCTABLE ) else hb_retni( FAILURE ); } + + +#define __PRG_SOURCE__ __FILE__ + +HB_FUNC( DELIM ); +HB_FUNC( DELIM_GETFUNCTABLE ); + +#ifdef HB_PCODE_VER + #undef HB_PRG_PCODE_VER + #define HB_PRG_PCODE_VER HB_PCODE_VER +#endif + +static void hb_delimRddInit( void * cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + + if( hb_rddRegister( "DELIM", RDT_TRANSFER ) > 1 ) + { + hb_errInternal( HB_EI_RDDINVALID, NULL, NULL, NULL ); + } +} + +HB_INIT_SYMBOLS_BEGIN( delim1__InitSymbols ) +{ "DELIM", HB_FS_PUBLIC, {HB_FUNCNAME( DELIM )}, NULL }, +{ "DELIM_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( DELIM_GETFUNCTABLE )}, NULL } +HB_INIT_SYMBOLS_END( delim1__InitSymbols ) + +HB_CALL_ON_STARTUP_BEGIN( _hb_delim_rdd_init_ ) + hb_vmAtInit( hb_delimRddInit, NULL ); +HB_CALL_ON_STARTUP_END( _hb_delim_rdd_init_ ) + +#if defined(HB_PRAGMA_STARTUP) + #pragma startup delim1__InitSymbols + #pragma startup _hb_delim_rdd_init_ +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_delim1__InitSymbols = delim1__InitSymbols; + static HB_$INITSYM hb_vm_auto_delim_rdd_init = _hb_delim_rdd_init_; + #pragma data_seg() +#endif diff --git a/harbour/source/rdd/hbsix/Makefile b/harbour/source/rdd/hbsix/Makefile index 80ecee79e2..4b93162f51 100644 --- a/harbour/source/rdd/hbsix/Makefile +++ b/harbour/source/rdd/hbsix/Makefile @@ -11,8 +11,4 @@ C_SOURCES=\ LIBNAME=hbsix -ifeq ($(HB_MT),MT) - MT_LIBNAME=$(LIBNAME)mt -endif - include $(TOP)$(ROOT)config/lib.cf diff --git a/harbour/source/rdd/hbsix/sxcompr.c b/harbour/source/rdd/hbsix/sxcompr.c index ba91aa0282..10a80ec7ce 100644 --- a/harbour/source/rdd/hbsix/sxcompr.c +++ b/harbour/source/rdd/hbsix/sxcompr.c @@ -121,9 +121,6 @@ */ -#ifdef HB_NO_DEFAULT_API_MACROS -#include "hbapiitm.h" -#endif #include "hbsxfunc.h" /* number of bits for encoded item (position,length) */ diff --git a/harbour/source/rdd/hbsix/sxcrypt.c b/harbour/source/rdd/hbsix/sxcrypt.c index c7fd4ab056..69de957c21 100644 --- a/harbour/source/rdd/hbsix/sxcrypt.c +++ b/harbour/source/rdd/hbsix/sxcrypt.c @@ -55,9 +55,6 @@ * */ -#ifdef HB_NO_DEFAULT_API_MACROS -#include "hbapiitm.h" -#endif #include "hbsxfunc.h" #define rnd_mul1 0x0de6d diff --git a/harbour/source/rdd/hsx/hsx.c b/harbour/source/rdd/hsx/hsx.c index 01ff5036c0..9bcf894c3d 100644 --- a/harbour/source/rdd/hsx/hsx.c +++ b/harbour/source/rdd/hsx/hsx.c @@ -220,9 +220,7 @@ */ #include "hbapi.h" -#ifdef HB_NO_DEFAULT_API_MACROS #include "hbapiitm.h" -#endif #include "hbapifs.h" #include "hbapirdd.h" #include "hbapierr.h" @@ -957,10 +955,10 @@ static int hb_hsxIfDel( int iHandle, ULONG ulRecord ) { iRetVal = hb_hsxRead( iHandle, ulRecord, &pRecPtr ); if ( iRetVal == HSX_SUCCESS ) - iRetVal = *pRecPtr & 0x80 ? HSX_SUCCESSFALSE : HSX_SUCCESS; + iRetVal = *pRecPtr & 0x80 ? HSX_SUCCESS : HSX_SUCCESSFALSE; } iRet = hb_hsxLock( iHandle, HSX_READUNLOCK, ulRecord ); - if ( iRetVal == HSX_SUCCESS ) + if ( iRet != HSX_SUCCESS ) iRetVal = iRet; return iRetVal; } @@ -1068,10 +1066,7 @@ static int hb_hsxAdd( int iHandle, ULONG *pulRecNo, PHB_ITEM pExpr, BOOL fDelete if ( ! pHSX ) return HSX_BADHANDLE; - if ( !pExpr ) - pExpr = pHSX->pKeyItem; - - if ( !pExpr ) + if ( !pExpr && !pHSX->pKeyItem ) return HSX_BADPARMS; iRetVal = hb_hsxLock( iHandle, HSX_APPENDLOCK, 0 ); diff --git a/harbour/source/rdd/nulsys/nulsys.prg b/harbour/source/rdd/nulsys/nulsys.prg index 12be68b3d2..bdd6977ce2 100644 --- a/harbour/source/rdd/nulsys/nulsys.prg +++ b/harbour/source/rdd/nulsys/nulsys.prg @@ -50,18 +50,10 @@ * */ -// Harbour without RDD +/* Harbour without RDD */ ANNOUNCE RDDSYS -PROCEDURE RDDInit - -RETURN - -PROCEDURE DBFInit - -RETURN - #pragma BEGINDUMP #include "hbrddwrk.h" diff --git a/harbour/source/rdd/rddsys.prg b/harbour/source/rdd/rddsys.prg index 3a800f195a..b4ab47bfbb 100644 --- a/harbour/source/rdd/rddsys.prg +++ b/harbour/source/rdd/rddsys.prg @@ -54,12 +54,6 @@ ANNOUNCE RDDSYS -PROCEDURE RddInit - - REQUEST _DBF - REQUEST DBFNTX - REQUEST DBFFPT - - rddSetDefault( "DBFNTX" ) - -return +REQUEST _DBF +REQUEST DBFNTX +REQUEST DBFFPT diff --git a/harbour/source/rdd/sdf0.prg b/harbour/source/rdd/sdf0.prg deleted file mode 100644 index 3ba3ab971f..0000000000 --- a/harbour/source/rdd/sdf0.prg +++ /dev/null @@ -1,63 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * SDF RDD module - * - * Copyright 1999 Bruno Cantero - * www - http://www.harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include "rddsys.ch" - -ANNOUNCE SDF - -init procedure SDFInit - - REQUEST _SDF - - rddRegister( "SDF", RDT_TRANSFER ) - -return diff --git a/harbour/source/rdd/sdf1.c b/harbour/source/rdd/sdf1.c index 4e3ebc6242..b501ae53e8 100644 --- a/harbour/source/rdd/sdf1.c +++ b/harbour/source/rdd/sdf1.c @@ -55,33 +55,9 @@ #include "hbvm.h" #include "hbapirdd.h" #include "hbapiitm.h" +#include "hbapierr.h" #include "hbrddsdf.h" - -#define __PRG_SOURCE__ __FILE__ - -HB_FUNC( _SDF ); -HB_FUNC( SDF_GETFUNCTABLE ); - -#undef HB_PRG_PCODE_VER -#define HB_PRG_PCODE_VER HB_PCODE_VER - -HB_INIT_SYMBOLS_BEGIN( sdf1__InitSymbols ) -{ "_SDF", HB_FS_PUBLIC, {HB_FUNCNAME( _SDF )}, NULL }, -{ "SDF_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( SDF_GETFUNCTABLE )}, NULL } -HB_INIT_SYMBOLS_END( sdf1__InitSymbols ) - -#if defined(HB_PRAGMA_STARTUP) - #pragma startup sdf1__InitSymbols -#elif defined(HB_MSC_STARTUP) - #if _MSC_VER >= 1010 - #pragma data_seg( ".CRT$XIY" ) - #pragma comment( linker, "/Merge:.CRT=.data" ) - #else - #pragma data_seg( "XIY" ) - #endif - static HB_$INITSYM hb_vm_auto_sdf1__InitSymbols = sdf1__InitSymbols; - #pragma data_seg() -#endif +#include "rddsys.ch" static RDDFUNCS sdfSuper; static RDDFUNCS sdfTable = { hb_sdfBof, @@ -192,7 +168,7 @@ static RDDFUNCS sdfTable = { hb_sdfBof, -HB_FUNC( _SDF ) { ; } +HB_FUNC( SDF ) { ; } HB_FUNC( SDF_GETFUNCTABLE ) { @@ -210,3 +186,45 @@ HB_FUNC( SDF_GETFUNCTABLE ) else hb_retni( FAILURE ); } + + +#define __PRG_SOURCE__ __FILE__ + +#ifdef HB_PCODE_VER + #undef HB_PRG_PCODE_VER + #define HB_PRG_PCODE_VER HB_PCODE_VER +#endif + +static void hb_sdfRddInit( void * cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + + if( hb_rddRegister( "SDF", RDT_TRANSFER ) > 1 ) + { + hb_errInternal( HB_EI_RDDINVALID, NULL, NULL, NULL ); + } +} + +HB_INIT_SYMBOLS_BEGIN( sdf1__InitSymbols ) +{ "SDF", HB_FS_PUBLIC, {HB_FUNCNAME( SDF )}, NULL }, +{ "SDF_GETFUNCTABLE", HB_FS_PUBLIC, {HB_FUNCNAME( SDF_GETFUNCTABLE )}, NULL } +HB_INIT_SYMBOLS_END( sdf1__InitSymbols ) + +HB_CALL_ON_STARTUP_BEGIN( _hb_sdf_rdd_init_ ) + hb_vmAtInit( hb_sdfRddInit, NULL ); +HB_CALL_ON_STARTUP_END( _hb_sdf_rdd_init_ ) + +#if defined(HB_PRAGMA_STARTUP) + #pragma startup sdf1__InitSymbols + #pragma startup _hb_sdf_rdd_init_ +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_sdf1__InitSymbols = sdf1__InitSymbols; + static HB_$INITSYM hb_vm_auto_sdf_rdd_init = _hb_sdf_rdd_init_; + #pragma data_seg() +#endif diff --git a/harbour/source/rtl/browdbx.prg b/harbour/source/rtl/browdbx.prg index 9e370bc2be..4fd6f2cabd 100644 --- a/harbour/source/rtl/browdbx.prg +++ b/harbour/source/rtl/browdbx.prg @@ -57,8 +57,11 @@ /* NOTE: This function is exactly the same as Skipped() in BROWDB.PRG */ + #ifdef HB_COMPAT_XPP +#ifdef HB_PRG_DBSKIPPER + FUNCTION dbSkipper( nRecs ) LOCAL nSkipped := 0 @@ -89,3 +92,5 @@ FUNCTION dbSkipper( nRecs ) RETURN nSkipped #endif + +#endif diff --git a/harbour/source/rtl/cdpapi.c b/harbour/source/rtl/cdpapi.c index 68b37742e0..3ddbf96863 100644 --- a/harbour/source/rtl/cdpapi.c +++ b/harbour/source/rtl/cdpapi.c @@ -754,8 +754,18 @@ HB_FUNC( HB_TRANSLATE ) HB_CALL_ON_STARTUP_BEGIN( hb_codepage_Init_EN ) hb_cdpRegister( &s_en_codepage ); HB_CALL_ON_STARTUP_END( hb_codepage_Init_EN ) -#if defined(HB_STATIC_STARTUP) || ( (! defined(__GNUC__)) && (! defined(_MSC_VER)) ) + +#if defined( HB_PRAGMA_STARTUP ) #pragma startup hb_codepage_Init_EN +#elif defined(HB_MSC_STARTUP) + #if _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto_hb_codepage_Init_EN = hb_codepage_Init_EN; + #pragma data_seg() #endif #endif /* HB_CDP_SUPPORT_OFF */ diff --git a/harbour/source/vm/arrays.c b/harbour/source/vm/arrays.c index 159d353e81..5e6f605169 100644 --- a/harbour/source/vm/arrays.c +++ b/harbour/source/vm/arrays.c @@ -68,6 +68,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbapiitm.h" #include "hbapierr.h" diff --git a/harbour/source/vm/arrayshb.c b/harbour/source/vm/arrayshb.c index 733ef10b7d..35c71989d1 100644 --- a/harbour/source/vm/arrayshb.c +++ b/harbour/source/vm/arrayshb.c @@ -52,6 +52,7 @@ #include +#include "hbvmopt.h" #include "hbapi.h" #include "hbstack.h" #include "hbapiitm.h" diff --git a/harbour/source/vm/asort.c b/harbour/source/vm/asort.c index 6bbeb18b0c..0453b19150 100644 --- a/harbour/source/vm/asort.c +++ b/harbour/source/vm/asort.c @@ -58,6 +58,7 @@ SORTING AND SEARCHING ALGORITHMS: A COOKBOOK, BY THOMAS NIEMANN http://members.xoom.com/_XMCM/thomasn/s_man.htm */ +#include "hbvmopt.h" #include "hbapiitm.h" #include "hbvm.h" #include "hbstack.h" diff --git a/harbour/source/vm/break.c b/harbour/source/vm/break.c index 477fc8213f..40b58511c6 100644 --- a/harbour/source/vm/break.c +++ b/harbour/source/vm/break.c @@ -50,6 +50,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbvm.h" diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index ffaf318b29..15bc07a3f2 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -138,8 +138,8 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" - #include "hbstack.h" #include "hbapierr.h" #include "hbapiitm.h" diff --git a/harbour/source/vm/cmdarg.c b/harbour/source/vm/cmdarg.c index accf923951..d963eaaabe 100644 --- a/harbour/source/vm/cmdarg.c +++ b/harbour/source/vm/cmdarg.c @@ -50,6 +50,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbvm.h" #include "hbmemory.ch" diff --git a/harbour/source/vm/codebloc.c b/harbour/source/vm/codebloc.c index 3e3ccfacee..3a7081c418 100644 --- a/harbour/source/vm/codebloc.c +++ b/harbour/source/vm/codebloc.c @@ -52,6 +52,7 @@ /* The Harbour implementation of codeblocks */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbapiitm.h" #include "hbvm.h" diff --git a/harbour/source/vm/debug.c b/harbour/source/vm/debug.c index a1c54d0f80..affe0b9289 100644 --- a/harbour/source/vm/debug.c +++ b/harbour/source/vm/debug.c @@ -50,6 +50,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbapiitm.h" #include "hbstack.h" diff --git a/harbour/source/vm/dynlibhb.c b/harbour/source/vm/dynlibhb.c index 656585a16f..0847d91e75 100644 --- a/harbour/source/vm/dynlibhb.c +++ b/harbour/source/vm/dynlibhb.c @@ -57,6 +57,7 @@ #define HB_OS_WIN_32_USED +#include "hbvmopt.h" #include "hbapi.h" #include "hbstack.h" #include "hbvm.h" diff --git a/harbour/source/vm/dynsym.c b/harbour/source/vm/dynsym.c index ce55a4d7a9..101d706454 100644 --- a/harbour/source/vm/dynsym.c +++ b/harbour/source/vm/dynsym.c @@ -50,6 +50,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #define SYM_ALLOCATED ( ( HB_SYMBOLSCOPE ) -1 ) diff --git a/harbour/source/vm/estack.c b/harbour/source/vm/estack.c index c2734aac3a..7e016419b4 100644 --- a/harbour/source/vm/estack.c +++ b/harbour/source/vm/estack.c @@ -54,12 +54,15 @@ #define HB_OS_WIN_32_USED #endif +#include "hbvmopt.h" #include "hbapi.h" #include "hbdefs.h" #include "hbstack.h" #include "hbapiitm.h" #include "hbapierr.h" +HB_EXTERN_BEGIN + /* ------------------------------- */ #if !defined( STACK_INITHB_ITEMS ) @@ -71,11 +74,6 @@ HB_STACK hb_stack; -HB_STACK HB_EXPORT hb_GetStack( void ) -{ - return hb_stack; -} - /* ------------------------------- */ #undef hb_stackPop @@ -501,3 +499,5 @@ ULONG _System OS2TermHandler(PEXCEPTIONREPORTRECORD p1, return XCPT_CONTINUE_SEARCH; /* Exception not resolved... */ } #endif + +HB_EXTERN_END diff --git a/harbour/source/vm/eval.c b/harbour/source/vm/eval.c index c38ff4fd2b..a609cf8697 100644 --- a/harbour/source/vm/eval.c +++ b/harbour/source/vm/eval.c @@ -62,6 +62,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbstack.h" #include "hbapiitm.h" diff --git a/harbour/source/vm/evalhb.c b/harbour/source/vm/evalhb.c index 62183c6478..ff19879f6d 100644 --- a/harbour/source/vm/evalhb.c +++ b/harbour/source/vm/evalhb.c @@ -50,6 +50,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbapiitm.h" #include "hbapierr.h" diff --git a/harbour/source/vm/extend.c b/harbour/source/vm/extend.c index 79c0f4a43e..2dcb8f601b 100644 --- a/harbour/source/vm/extend.c +++ b/harbour/source/vm/extend.c @@ -68,6 +68,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbapiitm.h" #include "hbset.h" @@ -77,6 +78,8 @@ /* NOTE: iParam = -1 can be used to access the return value. */ /* NOTE: iParam = 0 can be used to access the SELF object. */ +HB_EXTERN_BEGIN + PHB_ITEM HB_EXPORT hb_param( int iParam, int iMask ) { HB_TRACE(HB_TR_DEBUG, ("hb_param(%d, %d)", iParam, iMask)); @@ -675,7 +678,7 @@ void HB_EXPORT hb_reta( ULONG ulLen ) /* undocumented hb_reta() */ } #undef hb_retc -void HB_EXPORT hb_retc( char * szText ) +void HB_EXPORT hb_retc( const char * szText ) { HB_TRACE(HB_TR_DEBUG, ("hb_retc(%s)", szText)); @@ -691,7 +694,7 @@ void HB_EXPORT hb_retc_buffer( char * szText ) } #undef hb_retc_const -void HB_EXPORT hb_retc_const( char * szText ) +void HB_EXPORT hb_retc_const( const char * szText ) { HB_TRACE(HB_TR_DEBUG, ("hb_retc_const(%s)", szText)); @@ -699,7 +702,7 @@ void HB_EXPORT hb_retc_const( char * szText ) } #undef hb_retclen -void HB_EXPORT hb_retclen( char * szText, ULONG ulLen ) +void HB_EXPORT hb_retclen( const char * szText, ULONG ulLen ) { HB_TRACE(HB_TR_DEBUG, ("hb_retclen(%s, %lu)", szText, ulLen)); @@ -743,7 +746,7 @@ void HB_EXPORT hb_retcAdopt( char * szText ) /* szDate must have YYYYMMDD format */ #undef hb_retds -void HB_EXPORT hb_retds( char * szDate ) +void HB_EXPORT hb_retds( const char * szDate ) { HB_TRACE(HB_TR_DEBUG, ("hb_retds(%s)", szDate)); @@ -1219,3 +1222,4 @@ int HB_EXPORT hb_storptr( void * pointer, int iParam, ... ) return 0; } +HB_EXTERN_END diff --git a/harbour/source/vm/fm.c b/harbour/source/vm/fm.c index 035c8751fc..29fe5c42d4 100644 --- a/harbour/source/vm/fm.c +++ b/harbour/source/vm/fm.c @@ -79,6 +79,7 @@ #include */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbstack.h" #include "hbapierr.h" diff --git a/harbour/source/vm/garbage.c b/harbour/source/vm/garbage.c index dbde835833..95b213fc80 100644 --- a/harbour/source/vm/garbage.c +++ b/harbour/source/vm/garbage.c @@ -50,6 +50,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbstack.h" #include "hbapiitm.h" diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 440926e700..d37d0d9c42 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -69,6 +69,7 @@ #include #include +#include "hbvmopt.h" #include "hbapi.h" #include "hbstack.h" #include "hbapierr.h" @@ -288,6 +289,9 @@ char *hb_vm_acAscii[256] = { "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x "\xE0", "\xE1", "\xE2", "\xE3", "\xE4", "\xE5", "\xE6", "\xE7", "\xE8", "\xE9", "\xEA", "\xEB", "\xEC", "\xED", "\xEE", "\xEF", "\xF0", "\xF1", "\xF2", "\xF3", "\xF4", "\xF5", "\xF6", "\xF7", "\xF8", "\xF9", "\xFA", "\xFB", "\xFC", "\xFD", "\xFE", "\xFF" }; +static PHB_FUNC_LIST s_InitFunctions = NULL; +static PHB_FUNC_LIST s_ExitFunctions = NULL; + /* 21/10/00 - maurilio.longo@libero.it This Exception Handler gets called in case of an abnormal termination of an harbour program and displays a full stack trace at the harbour language level */ @@ -298,6 +302,67 @@ ULONG _System OS2TermHandler(PEXCEPTIONREPORTRECORD p1, PVOID pv); #endif +void HB_EXPORT hb_vmAtInit( HB_INIT_FUNC pFunc, void * cargo ) +{ + PHB_FUNC_LIST pLst = ( PHB_FUNC_LIST ) hb_xgrab( sizeof( HB_FUNC_LIST ) ); + + pLst->pFunc = pFunc; + pLst->cargo = cargo; + pLst->pNext = s_InitFunctions; + s_InitFunctions = pLst; +} + +void HB_EXPORT hb_vmAtExit( HB_INIT_FUNC pFunc, void * cargo ) +{ + PHB_FUNC_LIST pLst = ( PHB_FUNC_LIST ) hb_xgrab( sizeof( HB_FUNC_LIST ) ); + + pLst->pFunc = pFunc; + pLst->cargo = cargo; + pLst->pNext = s_ExitFunctions; + s_ExitFunctions = pLst; +} + +static void hb_vmCleanModuleFunctions( void ) +{ + PHB_FUNC_LIST pLst; + + while( s_InitFunctions ) + { + pLst = s_InitFunctions; + s_InitFunctions = pLst->pNext; + hb_xfree( pLst ); + } + while( s_ExitFunctions ) + { + pLst = s_ExitFunctions; + s_ExitFunctions = pLst->pNext; + hb_xfree( pLst ); + } +} + +static void hb_vmDoModuleInitFunctions( void ) +{ + PHB_FUNC_LIST pLst = s_InitFunctions; + + while( pLst ) + { + pLst->pFunc( pLst->cargo ); + pLst = pLst->pNext; + } +} + +static void hb_vmDoModuleExitFunctions( void ) +{ + PHB_FUNC_LIST pLst = s_ExitFunctions; + + while( pLst ) + { + pLst->pFunc( pLst->cargo ); + pLst = pLst->pNext; + } +} + + /* call CLIPINIT function to initialize ErrorBlock() and __SetHelpK() */ static void hb_vmDoInitClip( void ) { @@ -311,30 +376,6 @@ static void hb_vmDoInitClip( void ) } } -/* Initialize linked RDDs */ -static void hb_vmDoInitRdd( void ) -{ - PHB_DYNS pDynSym; - int i; - char * rddName[] = { "DBFDBTINIT", - "DBFFPTINIT", - "DBFNTXINIT", - "DBFCDXINIT", - "RDDINIT", - NULL }; - - for ( i = 0; rddName[i]; i++ ) - { - pDynSym = hb_dynsymFind( rddName[i] ); - if( pDynSym && pDynSym->pSymbol->value.pFunPtr ) - { - hb_vmPushSymbol( pDynSym->pSymbol ); - hb_vmPushNil(); - hb_vmDo(0); - } - } -} - /* application entry point */ void HB_EXPORT hb_vmInit( BOOL bStartMainProc ) @@ -402,8 +443,9 @@ void HB_EXPORT hb_vmInit( BOOL bStartMainProc ) * and not depends on INIT clause. */ hb_vmDoInitClip(); - hb_vmDoInitRdd(); /* initialize the Harbour's RDDs */ - hb_vmDoInitFunctions(); /* process defined INIT functions */ + + hb_vmDoModuleInitFunctions(); /* process AtInit registered functions */ + hb_vmDoInitFunctions(); /* process defined INIT functions */ /* This is undocumented CA-Clipper, if there's a function called _APPMAIN it will be executed first. [vszakats] */ @@ -493,6 +535,10 @@ void HB_EXPORT hb_vmQuit( void ) s_uiActionRequest = 0; /* EXIT procedures should be processed */ hb_vmDoExitFunctions(); /* process defined EXIT functions */ + /* process AtExit registered functions */ + hb_vmDoModuleExitFunctions(); + hb_vmCleanModuleFunctions(); + /* release all known items stored in subsystems */ hb_rddShutDown(); hb_idleShutDown(); @@ -3932,12 +3978,11 @@ HB_ITEM_PTR hb_vmEvalBlockV( HB_ITEM_PTR pBlock, ULONG ulArgCount, ... ) /* Evaluates a passed codeblock item or macro pointer item */ -HB_EXPORT HB_ITEM_PTR hb_vmEvalBlockOrMacro( HB_ITEM_PTR pItem ) +HB_EXPORT PHB_ITEM hb_vmEvalBlockOrMacro( PHB_ITEM pItem ) { - HB_TRACE(HB_TR_DEBUG, ("hb_vmEvalBlockOrMacro(%p)", pItem)); - if ( pItem->type == HB_IT_BLOCK ) + if( pItem->type == HB_IT_BLOCK ) { hb_vmPushSymbol( &hb_symEval ); hb_vmPush( pItem ); @@ -3946,20 +3991,38 @@ HB_EXPORT HB_ITEM_PTR hb_vmEvalBlockOrMacro( HB_ITEM_PTR pItem ) else { HB_MACRO_PTR pMacro = ( HB_MACRO_PTR ) hb_itemGetPtr( pItem ); - if ( pMacro ) + if( pMacro ) { hb_macroRun( pMacro ); - hb_itemCopy( &hb_stack.Return, hb_stackItemFromTop( - 1 ) ); + hb_itemForwardValue( hb_stackReturnItem(), hb_stackItemFromTop( - 1 ) ); hb_stackPop(); } else { - hb_itemClear( &hb_stack.Return ); + hb_itemClear( hb_stackReturnItem() ); } } - return &hb_stack.Return; + return hb_stackReturnItem(); } +/* + * destroy codeblock or macro in given item + */ +HB_EXPORT void hb_vmDestroyBlockOrMacro( PHB_ITEM pItem ) +{ + if( pItem->type == HB_IT_POINTER ) + { + HB_MACRO_PTR pMacro = ( HB_MACRO_PTR ) hb_itemGetPtr( pItem ); + if( pMacro ) + { + hb_macroDelete( pMacro ); + } + } + hb_itemRelease( pItem ); +} + + + void hb_vmFunction( USHORT uiParams ) { HB_TRACE(HB_TR_DEBUG, ("hb_vmFunction(%hu)", uiParams)); diff --git a/harbour/source/vm/initsymb.c b/harbour/source/vm/initsymb.c index ea8d656688..451436265b 100644 --- a/harbour/source/vm/initsymb.c +++ b/harbour/source/vm/initsymb.c @@ -50,6 +50,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbvm.h" diff --git a/harbour/source/vm/itemapi.c b/harbour/source/vm/itemapi.c index 7da7c20ac3..36bbbd6858 100644 --- a/harbour/source/vm/itemapi.c +++ b/harbour/source/vm/itemapi.c @@ -93,6 +93,7 @@ # include #endif +#include "hbvmopt.h" #include "hbapi.h" #include "hbstack.h" #include "hbapiitm.h" diff --git a/harbour/source/vm/macro.c b/harbour/source/vm/macro.c index d920b3ce55..b816706e01 100644 --- a/harbour/source/vm/macro.c +++ b/harbour/source/vm/macro.c @@ -54,6 +54,7 @@ */ #define HB_MACRO_SUPPORT +#include "hbvmopt.h" #include "hbmacro.h" #include "hbcomp.h" #include "hbstack.h" diff --git a/harbour/source/vm/maindllp.c b/harbour/source/vm/maindllp.c index e67d20908f..141b72019e 100644 --- a/harbour/source/vm/maindllp.c +++ b/harbour/source/vm/maindllp.c @@ -56,12 +56,12 @@ */ #define HB_OS_WIN_32_USED -#define HB_NO_DEFAULT_API_MACROS #include "hbtypes.h" #if defined(HB_OS_WIN_32) +HB_EXTERN_BEGIN BOOL HB_EXPORT WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved ) { @@ -851,4 +851,7 @@ ULONG hb_xsize( void * pMem ) /* returns the size of an alloc ulReturn= pXsize((void *)pMem); return ulReturn; } + +HB_EXTERN_END + #endif diff --git a/harbour/source/vm/memvars.c b/harbour/source/vm/memvars.c index 7af6902ed0..a956cd60ff 100644 --- a/harbour/source/vm/memvars.c +++ b/harbour/source/vm/memvars.c @@ -65,6 +65,7 @@ #include /* for toupper() function */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbapiitm.h" #include "hbapierr.h" diff --git a/harbour/source/vm/memvclip.c b/harbour/source/vm/memvclip.c index e26ae74278..2e76f61d9d 100644 --- a/harbour/source/vm/memvclip.c +++ b/harbour/source/vm/memvclip.c @@ -50,6 +50,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbapiitm.h" #include "hbcomp.h" /* for VS_* macros */ diff --git a/harbour/source/vm/pcount.c b/harbour/source/vm/pcount.c index 8243a8efc6..c48935636c 100644 --- a/harbour/source/vm/pcount.c +++ b/harbour/source/vm/pcount.c @@ -50,6 +50,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbstack.h" diff --git a/harbour/source/vm/proc.c b/harbour/source/vm/proc.c index dafb5dd1ba..b54393bed1 100644 --- a/harbour/source/vm/proc.c +++ b/harbour/source/vm/proc.c @@ -67,6 +67,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbstack.h" diff --git a/harbour/source/vm/pvalue.c b/harbour/source/vm/pvalue.c index f015abb126..ad5b483e4c 100644 --- a/harbour/source/vm/pvalue.c +++ b/harbour/source/vm/pvalue.c @@ -50,6 +50,7 @@ * */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbapiitm.h" #include "hbstack.h" diff --git a/harbour/source/vm/runner.c b/harbour/source/vm/runner.c index dd4dc7b9bc..80ebeb33bd 100644 --- a/harbour/source/vm/runner.c +++ b/harbour/source/vm/runner.c @@ -60,6 +60,7 @@ * __HRBDOFU() */ +#include "hbvmopt.h" #include "hbapi.h" #include "hbstack.h" #include "hbapiitm.h"