From 27af8d0dd377f14c498ba5a00a94f68034efba2e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 24 Feb 2010 19:07:18 +0000 Subject: [PATCH] 2010-02-24 20:04 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/pp/ppcore.c * src/compiler/cmdcheck.c * src/compiler/hbusage.c * include/hbpp.h + Marked "multiline strings" feature as deprecated, with HB_LEGACY_LEVEL3. It's recommended to fix such code to be compatible with Clipper (and other compatible) languages. F.e.: --- cVar := "line 1; line 2; line 3" --- to standard: --- F.e.: cVar := "line 1" +; "line 2" +; "line 3" --- or to another Harbour extension: --- #pragma __cstream|cVar := %s line 1 line 2 line 3 ENDTEXT --- ('+' operator will be optimized out by the compiler, so there won't be any performance drop.) * utils/hbmk2/hbmk2.prg * Formatting. --- harbour/ChangeLog | 35 +++++++++++++++++++++++++++++++++ harbour/include/hbpp.h | 4 ++++ harbour/src/compiler/cmdcheck.c | 3 ++- harbour/src/compiler/hbusage.c | 4 +++- harbour/src/pp/ppcore.c | 13 +++++++++--- harbour/utils/hbmk2/hbmk2.prg | 2 +- 6 files changed, 55 insertions(+), 6 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6f59b209dd..18e40a9ad6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,41 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-24 20:04 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * src/pp/ppcore.c + * src/compiler/cmdcheck.c + * src/compiler/hbusage.c + * include/hbpp.h + + Marked "multiline strings" feature as deprecated, + with HB_LEGACY_LEVEL3. + It's recommended to fix such code to be compatible + with Clipper (and other compatible) languages. + F.e.: + --- + cVar := "line 1; + line 2; + line 3" + --- + to standard: + --- F.e.: + cVar := "line 1" +; + "line 2" +; + "line 3" + --- + or to another Harbour extension: + --- + #pragma __cstream|cVar := %s + line 1 + line 2 + line 3 + ENDTEXT + --- + ('+' operator will be optimized out by the compiler, + so there won't be any performance drop.) + + * utils/hbmk2/hbmk2.prg + * Formatting. + 2010-02-24 16:10 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/pp/ppcore.c * src/compiler/cmdcheck.c diff --git a/harbour/include/hbpp.h b/harbour/include/hbpp.h index f27b24ccb6..8a4fe180a5 100644 --- a/harbour/include/hbpp.h +++ b/harbour/include/hbpp.h @@ -582,7 +582,9 @@ typedef struct HB_BOOL fWriteTrace; /* write translation to file (.ppt) */ HB_PATHNAMES * pIncludePath; /* search path(s) for included files */ +#ifdef HB_LEGACY_LEVEL3 HB_BOOL fMultiLine; /* 'multiline strings' compatibility feature enabled */ +#endif char * szOutFileName; /* output file name */ FILE * file_out; /* output file handle */ @@ -659,7 +661,9 @@ extern void hb_pp_readRules( PHB_PP_STATE pState, const char * szRulesFile ); extern void hb_pp_setStdRules( PHB_PP_STATE pState ); extern void hb_pp_setStdBase( PHB_PP_STATE pState ); extern void hb_pp_setStream( PHB_PP_STATE pState, int iMode ); +#ifdef HB_LEGACY_LEVEL3 extern void hb_pp_setMultiLine( PHB_PP_STATE pState, HB_BOOL fMultiLine ); +#endif extern void hb_pp_addSearchPath( PHB_PP_STATE pState, const char * szPath, HB_BOOL fReplace ); extern HB_BOOL hb_pp_inBuffer( PHB_PP_STATE pState, const char * pBuffer, HB_SIZE ulLen ); extern HB_BOOL hb_pp_inFile( PHB_PP_STATE pState, const char * szFileName, HB_BOOL fSearchPath, FILE * file_in, HB_BOOL fError ); diff --git a/harbour/src/compiler/cmdcheck.c b/harbour/src/compiler/cmdcheck.c index dd0f1ea61a..945cc020ce 100644 --- a/harbour/src/compiler/cmdcheck.c +++ b/harbour/src/compiler/cmdcheck.c @@ -407,6 +407,7 @@ static void hb_compChkEnvironVar( HB_COMP_DECL, const char *szSwitch ) HB_COMP_PARAM->supported &= ~HB_COMPFLAG_OPTJUMP; break; +#ifdef HB_LEGACY_LEVEL3 case 'L': case 'l': if( s[i] == '-' ) @@ -417,7 +418,7 @@ static void hb_compChkEnvironVar( HB_COMP_DECL, const char *szSwitch ) else hb_pp_setMultiLine( HB_COMP_PARAM->pLex->pPP, HB_TRUE ); break; - +#endif case 'm': case 'M': if( s[i] == '+' ) diff --git a/harbour/src/compiler/hbusage.c b/harbour/src/compiler/hbusage.c index 1357c72a77..94458a83fa 100644 --- a/harbour/src/compiler/hbusage.c +++ b/harbour/src/compiler/hbusage.c @@ -143,7 +143,9 @@ void hb_compPrintModes( HB_COMP_DECL ) "\n s[-] allow indexed assignment on all types", "\n x[-] extended Xbase++ mode", "\n j[+] turn off jump optimization in pcode", - "\n l[-] enable support for multiline strings in PP", +#ifdef HB_LEGACY_LEVEL3 + "\n l[-] enable support for multiline strings (deprecated)", +#endif "\n m[+] turn off macrotext substitution", "\n ? this info", "\n" diff --git a/harbour/src/pp/ppcore.c b/harbour/src/pp/ppcore.c index 9d8054408a..353e270215 100644 --- a/harbour/src/pp/ppcore.c +++ b/harbour/src/pp/ppcore.c @@ -50,7 +50,6 @@ * */ -/* #define HB_PP_MULTILINE_STRING */ /* #define HB_CLP_STRICT */ /* #define HB_PP_NO_LINEINFO_TOKEN */ /* #define HB_PP_STRICT_LINEINFO_TOKEN */ @@ -318,11 +317,13 @@ static void hb_membufFlush( PHB_MEM_BUFFER pBuffer ) pBuffer->ulLen = 0; } +#ifdef HB_LEGACY_LEVEL3 static void hb_membufRemove( PHB_MEM_BUFFER pBuffer, HB_SIZE ulLeft ) { if( ulLeft < pBuffer->ulLen ) pBuffer->ulLen = ulLeft; } +#endif static HB_SIZE hb_membufLen( const PHB_MEM_BUFFER pBuffer ) { @@ -1112,6 +1113,7 @@ static void hb_pp_getLine( PHB_PP_STATE pState ) } } +#ifdef HB_LEGACY_LEVEL3 if( pState->fMultiLine ) { while( ul == ulLen ) @@ -1141,7 +1143,7 @@ static void hb_pp_getLine( PHB_PP_STATE pState ) break; } } - +#endif u = ch != '"' ? 2 : 1; ulStrip = ul - u; hb_strRemEscSeq( pBuffer + u, &ulStrip ); @@ -1195,6 +1197,7 @@ static void hb_pp_getLine( PHB_PP_STATE pState ) if( ch == '`' ) ch = '\''; while( ++ul < ulLen && pBuffer[ ul ] != ch ) {}; +#ifdef HB_LEGACY_LEVEL3 if( pState->fMultiLine ) { while( ul == ulLen ) @@ -1220,7 +1223,7 @@ static void hb_pp_getLine( PHB_PP_STATE pState ) } } } - +#endif hb_pp_tokenAddNext( pState, pBuffer + 1, ul - 1, HB_PP_TOKEN_STRING ); if( ul == ulLen ) @@ -5395,6 +5398,8 @@ void hb_pp_reset( PHB_PP_STATE pState ) hb_pp_ruleListNonStdFree( &pState->pCommands ); } +#ifdef HB_LEGACY_LEVEL3 + /* * set compatibility flag for multiline strings concatenated by ';' * f.e.: @@ -5410,6 +5415,8 @@ void hb_pp_setMultiLine( PHB_PP_STATE pState, HB_BOOL fMultiLine ) pState->fMultiLine = fMultiLine; } +#endif + /* * add search path for included files */ diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 7ca78ce1fb..d1d513bbeb 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -7824,7 +7824,7 @@ STATIC FUNCTION MacOSXFiles( hbmk, nType, cPROGNAME ) SWITCH nType CASE 1 - #pragma __cstream|cString:=%s + #pragma __cstream|cString := %s