diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 115b627cfd..2534a65974 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,38 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ * fixed <-x-> match marker +2006-02-11 13:32 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/Makefile + * added missing header files + + * harbour/source/compiler/harbour.c + * added support for @filelst[.clp] - partially borrowed from xHarbour + It's not exactly the same as in Clipper because Clipper creates + one final file when [x]Harbour series of files. + To make it like in Clipper we will have to add support from more + then one symbol table in the final file. It will be also useful + for proper implementation of: + DO + Now in [x]Harbour it works like #include .prg when in Clipper + also new symbol table is created for included files. The difference + can be easy sync when current file has static functions with exactly + the same names as the one included by DO - compilation fails. + * add HB_P_ENDBLOCK to PCODE with codeblock body before run any + optimization - it fixes pcode tracing in jump optimization and + also allow to make some validation of generated PCODE + + * harbour/source/rdd/dbstrux.prg + * harbour/source/rdd/dbtotal.prg + * removed not longer necessary temporary alias creation. Harbour + support empty aliases ("") like Clipper. + + * harbour/source/rdd/dbffpt/dbffpt1.c + * harbour/source/rtl/hbgtcore.c + * casting + + * harbour/source/rtl/gtos2/gtos2.c + ! fixed hb_gt_os2_GetScreenContents() + 2006-02-11 12:40 UTC+0100 Ryszard Glab * source/compiler/harbour.c * source/compiler/harbour.y diff --git a/harbour/include/Makefile b/harbour/include/Makefile index e9ef06050b..1a4b680ccf 100644 --- a/harbour/include/Makefile +++ b/harbour/include/Makefile @@ -42,7 +42,9 @@ C_HEADERS=\ hbset.h \ hbsetup.h \ hbstack.h \ + hbsxfunc.h \ hbtrace.h \ + hbtypes.h \ hbver.h \ hbvm.h \ hbvmopt.h \ @@ -72,6 +74,7 @@ PRG_HEADERS=\ hbinkey.ch \ hblang.ch \ hbmacro.ch \ + hbmath.ch \ hbmemory.ch \ hbmemvar.ch \ hboo.ch \ diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 4303c83a9b..ee049497c1 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -83,6 +83,7 @@ static void hb_compGenVariablePCode( BYTE , char * ); /* generates the pcode static PFUNCTION hb_compFunctionNew( char *, HB_SYMBOLSCOPE ); /* creates and initialises the _FUNC structure */ static PINLINE hb_compInlineNew( char * ); /* creates and initialises the _INLINE structure */ static void hb_compCheckDuplVars( PVAR pVars, char * szVarName ); /*checks for duplicate variables definitions */ +static int hb_compProcessRSPFile( char *, int, char * argv[] ); /* process response file */ /* int hb_compSort_ULONG( ULONG * ulLeft, ULONG * ulRight ); */ static void hb_compOptimizeJumps( void ); @@ -274,7 +275,10 @@ int main( int argc, char * argv[] ) hb_pp_Init(); } - iStatus = hb_compCompile( argv[ i ], argc, argv ); + if( argv[ i ][ 0 ] == '@' ) + iStatus = hb_compProcessRSPFile( argv[ i ] + 1, argc, argv ); + else + iStatus = hb_compCompile( argv[ i ], argc, argv ); if( iStatus != EXIT_SUCCESS ) break; @@ -305,6 +309,83 @@ int main( int argc, char * argv[] ) return iStatus; } +static int hb_compProcessRSPFile( char * szRspName, int argc, char * argv[] ) +{ + char szFile[ _POSIX_PATH_MAX + 1 ]; + int iStatus = EXIT_SUCCESS; + PHB_FNAME pFileName; + FILE *inFile; + + pFileName = hb_fsFNameSplit( szRspName ); + + if( !pFileName->szExtension ) + { + pFileName->szExtension = ".clp"; + hb_fsFNameMerge( szFile, pFileName ); + szRspName = szFile; + } + hb_xfree( pFileName ); + + inFile = fopen( szRspName, "r" ); + if( !inFile ) + { + fprintf( hb_comp_errFile, "Cannot open input file: %s\n", szRspName ); + iStatus = EXIT_FAILURE; + } + else + { + int iProcess = 1, i = 0, ch; + + do + { + ch = fgetc( inFile ); + + /* + * '"' - quoting file names is Harbour extension - + * Clipper does not serve it, [druzus] + */ + if( ch == '"' ) + { + while( ( ch = fgetc ( inFile ) ) != EOF && ch != '"' && ch != '\n' ) + { + if( i < _POSIX_PATH_MAX ) + szFile[ i++ ] = (char) ch; + } + if( ch == '"' ) + continue; + } + + if( ch == EOF || HB_ISSPACE( ch ) || ch == '#' ) + { + szFile[ i ] = '\0'; + + if( i > 0 ) + { + if( iProcess > 1 ) + hb_pp_Init(); + + iStatus = hb_compCompile( szFile, argc, argv ); + + if( iStatus != EXIT_SUCCESS ) + break; + + iProcess ++; + i = 0; + } + while( ch != EOF && ch != '\n' ) + ch = fgetc( inFile ); + } + else if( i < _POSIX_PATH_MAX ) + szFile[ i++ ] = (char) ch; + } + while( ch != EOF ); + + fclose ( inFile ); + } + + return iStatus; +} + #if defined(__IBMCPP__) || defined(_MSC_VER) || (defined(__BORLANDC__) && defined(__cplusplus)) int isatty( int handle ) { @@ -4107,6 +4188,8 @@ void hb_compCodeBlockEnd( void ) int iLocalPos; PVAR pVar, pFree; + hb_compGenPCode1( HB_P_ENDBLOCK ); /* finish the codeblock */ + hb_compOptimizeJumps(); pCodeblock = hb_comp_functions.pLast; @@ -4142,8 +4225,8 @@ void hb_compCodeBlockEnd( void ) } wLocalsCnt = wLocals; - /* NOTE: 3 = HB_P_PUSHBLOCK + BYTE( size ) + _ENDBLOCK */ - wSize = ( USHORT ) pCodeblock->lPCodePos + 3 ; + /* NOTE: 2 = HB_P_PUSHBLOCK + BYTE( size ) */ + wSize = ( USHORT ) pCodeblock->lPCodePos + 2; if( hb_comp_bDebugInfo ) { wSize += (3 + strlen( hb_comp_files.pLast->szFileName ) + strlen( pFunc->szName )); @@ -4213,7 +4296,6 @@ void hb_compCodeBlockEnd( void ) } hb_compGenPCodeN( pCodeblock->pCode, pCodeblock->lPCodePos, ( BOOL ) 0 ); - hb_compGenPCode1( HB_P_ENDBLOCK ); /* finish the codeblock */ /* this fake-function is no longer needed */ hb_xfree( ( void * ) pCodeblock->pCode ); diff --git a/harbour/source/rdd/dbffpt/dbffpt1.c b/harbour/source/rdd/dbffpt/dbffpt1.c index be1b298b0b..71b74bc0ea 100644 --- a/harbour/source/rdd/dbffpt/dbffpt1.c +++ b/harbour/source/rdd/dbffpt/dbffpt1.c @@ -3881,7 +3881,7 @@ static ERRCODE hb_fptPutValueFile( FPTAREAP pArea, USHORT uiIndex, BYTE * szFile ULONG ulSize, ulBlock, ulType, ulOldSize, ulOldType; HB_FOFFSET size = hb_fsSeekLarge( hFile, 0, FS_END ); - if( ( size & 0xFFFFFFFF ) == size ) + if( ( HB_FOFFSET ) ( size & 0xFFFFFFFF ) == size ) { ulSize = HB_MIN( ( ULONG ) size, 0xFFFFFFFFUL - sizeof( FPTBLOCK ) ); } diff --git a/harbour/source/rdd/dbstrux.prg b/harbour/source/rdd/dbstrux.prg index 12ad710f38..336190955c 100644 --- a/harbour/source/rdd/dbstrux.prg +++ b/harbour/source/rdd/dbstrux.prg @@ -62,7 +62,6 @@ FUNCTION __dbCopyXStruct( cFileName ) LOCAL nOldArea LOCAL oError LOCAL aStruct - local cTmpAlias IF Empty( aStruct := dbStruct() ) RETURN .F. @@ -71,10 +70,9 @@ FUNCTION __dbCopyXStruct( cFileName ) nOldArea := Select() BEGIN SEQUENCE - cTmpAlias := __rddGetTempAlias() dbSelectArea( 0 ) - __dbCreate( cFileName, NIL, NIL, .F., cTmpAlias ) + __dbCreate( cFileName, NIL, NIL, .F., "" ) AEval( aStruct, {| aField | iif( aField[ DBS_TYPE ] == "C" .AND. aField[ DBS_LEN ] > 255, ; ( aField[ DBS_DEC ] := Int( aField[ DBS_LEN ] / 256 ), aField[ DBS_LEN ] := aField[ DBS_LEN ] % 256 ), NIL ) } ) @@ -106,7 +104,6 @@ FUNCTION __dbCreate( cFileName, cFileFrom, cRDDName, lNew, cAlias, cdpId, nConne LOCAL nOldArea := Select() LOCAL aStruct := {} LOCAL oError - local cTmpAlias DEFAULT lNew TO .F. @@ -127,9 +124,7 @@ FUNCTION __dbCreate( cFileName, cFileFrom, cRDDName, lNew, cAlias, cdpId, nConne ELSE - cTmpAlias := __rddGetTempAlias() - - dbUseArea( lNew,, cFileFrom, cTmpAlias ) + dbUseArea( lNew,, cFileFrom, "" ) dbEval( {|| AAdd( aStruct, { Rtrim(FIELD->FIELD_NAME) ,; Rtrim(FIELD->FIELD_TYPE) ,; diff --git a/harbour/source/rdd/dbtotal.prg b/harbour/source/rdd/dbtotal.prg index 1db8577efb..12082e8bbe 100644 --- a/harbour/source/rdd/dbtotal.prg +++ b/harbour/source/rdd/dbtotal.prg @@ -71,11 +71,9 @@ FUNCTION __DBTOTAL( cFile, xKey, aFields, ; LOCAL cset LOCAL flag_err LOCAL err_block - LOCAL cAlias LOCAL wRec LOCAL err - cAlias := TmpAlias() err_block := Errorblock( { | x | Break( x ) } ) flag_err := .F. cset := Set( _SET_CANCEL, .f. ) @@ -161,7 +159,7 @@ FUNCTION __DBTOTAL( cFile, xKey, aFields, ; Aeval( aFields, { | _1 | Aadd( aGetField, getfield( _1 ) ) } ) aFieldsSum := Array( Len( aGetField ) ) - dbCreate( cFile, aNewDbStruct, rdd, .T., cAlias, cdpId, nConnection ) + dbCreate( cFile, aNewDbStruct, rdd, .T., "", cdpId, nConnection ) NewSelect := SELECT() SELECT( CurSelect ) @@ -223,17 +221,6 @@ FUNCTION __DBTOTAL( cFile, xKey, aFields, ; RETURN ( .t. ) -STATIC FUNCTION TMPALIAS() - - LOCAL i - LOCAL alias := "_tmp" - i := 1 - WHILE SELECT( alias ) != 0 - alias += Alltrim( Str( i ) ) - i ++ - ENDDO -RETURN alias - STATIC FUNCTION GETFIELD( cField ) LOCAL nPos @@ -277,7 +264,6 @@ RETURN nil STATIC FUNCTION DbRead() - LOCAL cAlias := Alias() LOCAL aRec := {} LOCAL nCount diff --git a/harbour/source/rtl/gtos2/gtos2.c b/harbour/source/rtl/gtos2/gtos2.c index 4ac5d9f872..f3daf58ae2 100644 --- a/harbour/source/rtl/gtos2/gtos2.c +++ b/harbour/source/rtl/gtos2/gtos2.c @@ -477,6 +477,7 @@ static void hb_gt_os2_GetScreenContents( void ) { for( iCol = 0; iCol < s_vi.col; ++iCol ) { + usSize = 2; VioReadCellStr( ( PBYTE ) Cell, &usSize, iRow, iCol, 0 ); hb_gt_PutChar( iRow, iCol, Cell[ 1 ], 0, Cell[ 0 ] ); } diff --git a/harbour/source/rtl/hbgtcore.c b/harbour/source/rtl/hbgtcore.c index 493baacd1d..0d0f07ffef 100644 --- a/harbour/source/rtl/hbgtcore.c +++ b/harbour/source/rtl/hbgtcore.c @@ -1751,7 +1751,7 @@ static int hb_gt_def_MouseReadKey( int iEventMask ) if( iEventMask & INKEY_LDOWN && hb_mouse_ButtonPressed( 0, &iRow, &iCol ) ) { clock_t timer = clock(); - if( timer - s_iMouseLeftTimer <= hb_mouse_GetDoubleClickSpeed() * 1000 / CLOCKS_PER_SEC ) + if( timer - s_iMouseLeftTimer <= ( clock_t ) hb_mouse_GetDoubleClickSpeed() * 1000 / CLOCKS_PER_SEC ) iKey = K_LDBLCLK; else iKey = K_LBUTTONDOWN; @@ -1764,7 +1764,7 @@ static int hb_gt_def_MouseReadKey( int iEventMask ) else if( iEventMask & INKEY_RDOWN && hb_mouse_ButtonPressed( 1, &iRow, &iCol ) ) { clock_t timer = clock(); - if( timer - s_iMouseRightTimer <= hb_mouse_GetDoubleClickSpeed() * 1000 / CLOCKS_PER_SEC ) + if( timer - s_iMouseRightTimer <= ( clock_t ) hb_mouse_GetDoubleClickSpeed() * 1000 / CLOCKS_PER_SEC ) iKey = K_RDBLCLK; else iKey = K_RBUTTONDOWN; @@ -1777,7 +1777,7 @@ static int hb_gt_def_MouseReadKey( int iEventMask ) else if( iEventMask & INKEY_MMIDDLE && hb_mouse_ButtonPressed( 2, &iRow, &iCol ) ) { clock_t timer = clock(); - if( timer - s_iMouseMiddleTimer <= hb_mouse_GetDoubleClickSpeed() * 1000 / CLOCKS_PER_SEC ) + if( timer - s_iMouseMiddleTimer <= ( clock_t ) hb_mouse_GetDoubleClickSpeed() * 1000 / CLOCKS_PER_SEC ) iKey = K_MDBLCLK; else iKey = K_MBUTTONDOWN;