From 6e1a0844d214493593ffda3be73204dcfa744fe6 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 26 Jan 2011 23:22:54 +0000 Subject: [PATCH] 2011-01-27 00:22 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbcompdf.h * harbour/src/compiler/hbmain.c * save and restore compiler settings when separated .prg files are compiled as different modules. Files compiled as single module (i.e. by .clp files, #included, added by DO ... [WITH ...], etc.) are still compiled using the same settings inheriting any modifications introduced by #pragma. It's intentional behavior. --- harbour/ChangeLog | 9 +++++++++ harbour/include/hbcompdf.h | 18 +++++++++++++++++ harbour/src/compiler/hbmain.c | 37 +++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3cce692db2..3f492a8c64 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,15 @@ The license applies to all entries newer than 2009-04-28. */ +2011-01-27 00:22 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbcompdf.h + * harbour/src/compiler/hbmain.c + * save and restore compiler settings when separated .prg files are + compiled as different modules. Files compiled as single module + (i.e. by .clp files, #included, added by DO ... [WITH ...], etc.) + are still compiled using the same settings inheriting any modifications + introduced by #pragma. It's intentional behavior. + 2011-01-26 23:56 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbpp.h * harbour/src/pp/ppcore.c diff --git a/harbour/include/hbcompdf.h b/harbour/include/hbcompdf.h index ac74fe1acd..5250dafa25 100644 --- a/harbour/include/hbcompdf.h +++ b/harbour/include/hbcompdf.h @@ -837,6 +837,24 @@ typedef struct _HB_COMP } HB_COMP, * HB_COMP_PTR; +typedef struct +{ + HB_BOOL fDebugInfo; + HB_BOOL fAutoMemvarAssume; + HB_BOOL fI18n; + HB_BOOL fLineNumbers; + HB_BOOL fPPO; + HB_BOOL fPPT; + HB_BOOL fQuiet; + HB_BOOL fForceMemvars; + int iStartProc; + int iWarnings; + int iExitLevel; + int iHidden; + int supported; +} +HB_COMP_SWITCHES, * PHB_COMP_SWITCHES; + extern HB_COMP_PTR hb_comp_new( void ); extern void hb_comp_free( HB_COMP_PTR ); diff --git a/harbour/src/compiler/hbmain.c b/harbour/src/compiler/hbmain.c index 86ef9ebd86..fa6adfcd8d 100644 --- a/harbour/src/compiler/hbmain.c +++ b/harbour/src/compiler/hbmain.c @@ -4038,9 +4038,44 @@ static void hb_compGenIncluded( HB_COMP_DECL ) } } +static void hb_compSaveSwitches( HB_COMP_DECL, PHB_COMP_SWITCHES pSwitches ) +{ + pSwitches->fDebugInfo = HB_COMP_PARAM->fDebugInfo; + pSwitches->fAutoMemvarAssume = HB_COMP_PARAM->fAutoMemvarAssume; + pSwitches->fI18n = HB_COMP_PARAM->fI18n; + pSwitches->fLineNumbers = HB_COMP_PARAM->fLineNumbers; + pSwitches->fPPO = HB_COMP_PARAM->fPPO; + pSwitches->fPPT = HB_COMP_PARAM->fPPT; + pSwitches->fQuiet = HB_COMP_PARAM->fQuiet; + pSwitches->fForceMemvars = HB_COMP_PARAM->fForceMemvars; + pSwitches->iStartProc = HB_COMP_PARAM->iStartProc; + pSwitches->iWarnings = HB_COMP_PARAM->iWarnings; + pSwitches->iExitLevel = HB_COMP_PARAM->iExitLevel; + pSwitches->iHidden = HB_COMP_PARAM->iHidden; + pSwitches->supported = HB_COMP_PARAM->supported; +} + +static void hb_compRestoreSwitches( HB_COMP_DECL, PHB_COMP_SWITCHES pSwitches ) +{ + HB_COMP_PARAM->fDebugInfo = pSwitches->fDebugInfo; + HB_COMP_PARAM->fAutoMemvarAssume = pSwitches->fAutoMemvarAssume; + HB_COMP_PARAM->fI18n = pSwitches->fI18n; + HB_COMP_PARAM->fLineNumbers = pSwitches->fLineNumbers; + HB_COMP_PARAM->fPPO = pSwitches->fPPO; + HB_COMP_PARAM->fPPT = pSwitches->fPPT; + HB_COMP_PARAM->fQuiet = pSwitches->fQuiet; + HB_COMP_PARAM->fForceMemvars = pSwitches->fForceMemvars; + HB_COMP_PARAM->iStartProc = pSwitches->iStartProc; + HB_COMP_PARAM->iWarnings = pSwitches->iWarnings; + HB_COMP_PARAM->iExitLevel = pSwitches->iExitLevel; + HB_COMP_PARAM->iHidden = pSwitches->iHidden; + HB_COMP_PARAM->supported = pSwitches->supported; +} + static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuffer ) { char buffer[ HB_PATH_MAX * 2 + 80 ]; + HB_COMP_SWITCHES switches; int iStatus = EXIT_SUCCESS; PHB_FNAME pFileName = NULL; PHB_MODULE pModule; @@ -4048,6 +4083,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuff HB_TRACE(HB_TR_DEBUG, ("hb_compCompile(%s,%p)", szPrg, szBuffer)); + hb_compSaveSwitches( HB_COMP_PARAM, &switches ); /* Initialize support variables */ hb_compInitVars( HB_COMP_PARAM ); @@ -4377,6 +4413,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuff hb_compOutStd( HB_COMP_PARAM, "\nNo code generated.\n" ); hb_compCompileEnd( HB_COMP_PARAM ); + hb_compRestoreSwitches( HB_COMP_PARAM, &switches ); return HB_COMP_PARAM->fExit ? EXIT_FAILURE : iStatus; }