diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6f8b7c1fb3..b6304befec 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,16 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-17 14:06 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/compiler/hbmain.c + * extended -n2 to work also with code without starup procedure but with + local variables + + * harbour/utils/hbrun/hbrun.prg + + added -n2 to compiler parameters when .prg file is compiled and + executed. It allows to use with hbrun .prg files with and without + startup procedure + 2009-06-17 13:08 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * source/rtl/hbinet.c ! Typo in 2009-06-13 23:51 UTC+0200 fixed. diff --git a/harbour/source/compiler/hbmain.c b/harbour/source/compiler/hbmain.c index 5ef505a577..f3b750d700 100644 --- a/harbour/source/compiler/hbmain.c +++ b/harbour/source/compiler/hbmain.c @@ -64,6 +64,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, int iFileType ); static int hb_compProcessRSPFile( HB_COMP_DECL, const char * ); /* process response file */ static int hb_compAutoOpen( HB_COMP_DECL, const char * szPrg, BOOL * bSkipGen, int iFileType ); +static BOOL hb_compRegisterFunc( HB_COMP_DECL, const char * szFunName, HB_SYMBOLSCOPE cScope, BOOL fError ); /* ************************************************************************* */ @@ -385,14 +386,21 @@ void hb_compVariableAdd( HB_COMP_DECL, const char * szVarName, PHB_VARTYPE pVarT PVAR pVar; BOOL bFreeVar = TRUE; - if( ( HB_COMP_PARAM->functions.pLast->funFlags & FUN_FILE_DECL ) != 0 && + if( ( pFunc->funFlags & FUN_FILE_DECL ) != 0 && ( HB_COMP_PARAM->iVarScope == VS_LOCAL || HB_COMP_PARAM->iVarScope == ( VS_PRIVATE | VS_PARAMETER ) ) ) { - /* Variable declaration is outside of function/procedure body. - In this case only STATICs, MEMVARs and FIELDs declarations are allowed. */ - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_OUTSIDE, NULL, NULL ); - return; + if( HB_COMP_PARAM->iStartProc == 2 && + HB_COMP_PARAM->functions.iCount == 1 && pFunc->szName[0] && + hb_compRegisterFunc( HB_COMP_PARAM, pFunc->szName, pFunc->cScope, FALSE ) ) + pFunc->funFlags &= ~FUN_FILE_DECL; + else + { + /* Variable declaration is outside of function/procedure body. + In this case only STATICs, MEMVARs and FIELDs declarations are allowed. */ + hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_OUTSIDE, NULL, NULL ); + return; + } } /* check if we are declaring local/static variable after some diff --git a/harbour/utils/hbrun/hbrun.prg b/harbour/utils/hbrun/hbrun.prg index 91320b5827..f67e8ca051 100644 --- a/harbour/utils/hbrun/hbrun.prg +++ b/harbour/utils/hbrun/hbrun.prg @@ -107,7 +107,7 @@ PROCEDURE _APPMAIN( cFile, ... ) OTHERWISE hb_FNameSplit( cFile, NIL, NIL, @cExt ) IF Lower( cExt ) == ".prg" - cFile := HB_COMPILEBUF( HB_ARGV( 0 ), "-n", "-w", "-es2", "-q0", ; + cFile := HB_COMPILEBUF( HB_ARGV( 0 ), "-n2", "-w", "-es2", "-q0", ; s_aIncDir, cFile ) IF cFile == NIL ERRORLEVEL( 1 )