2010-02-24 16:10 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* src/pp/ppcore.c
  * src/compiler/cmdcheck.c
  * src/compiler/hbusage.c
  * include/hbpp.h
  * include/hbsetup.h
    * HB_USER_CFLAGS=-DHB_PP_MULTILINE_STRING feature converted
      to compiler switch '-kl'.
      INCOMPATIBLE. Users needing this feature now can use
      standard Harbour builds by simply adding -kl Harbour
      compiler flag. Old build-time macro is not supported 
      anymore.
This commit is contained in:
Viktor Szakats
2010-02-24 15:11:45 +00:00
parent dfa37c743b
commit aede2707a1
6 changed files with 92 additions and 59 deletions

View File

@@ -17,6 +17,19 @@
past entries belonging to author(s): Viktor Szakats.
*/
2010-02-24 16:10 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* src/pp/ppcore.c
* src/compiler/cmdcheck.c
* src/compiler/hbusage.c
* include/hbpp.h
* include/hbsetup.h
* HB_USER_CFLAGS=-DHB_PP_MULTILINE_STRING feature converted
to compiler switch '-kl'.
INCOMPATIBLE. Users needing this feature now can use
standard Harbour builds by simply adding -kl Harbour
compiler flag. Old build-time macro is not supported
anymore.
2010-02-24 14:33 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* include/hbdefs.h
* include/hbapigt.h

View File

@@ -582,6 +582,7 @@ typedef struct
HB_BOOL fWriteTrace; /* write translation to file (.ppt) */
HB_PATHNAMES * pIncludePath; /* search path(s) for included files */
HB_BOOL fMultiLine; /* 'multiline strings' compatibility feature enabled */
char * szOutFileName; /* output file name */
FILE * file_out; /* output file handle */
@@ -658,6 +659,7 @@ 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 );
extern void hb_pp_setMultiLine( PHB_PP_STATE pState, HB_BOOL fMultiLine );
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 );

View File

@@ -142,18 +142,6 @@
/* #define HB_MAIN_STD */
/* #define HB_MAIN_WIN */
/* ***********************************************************************
* You can enable here support for multiline strings concatenated by ';'
* f.e.:
* cVar := "line 1;
* line 2;
* line 3"
* It's not Clipper compatible extension and it's not enabled by default
* anyhow old Harbour PP worked in such way and people may have some code
* which needs it
*/
/* #define HB_PP_MULTILINE_STRING */
/* NOTE:
Compiler _MSC_VER value
-------- --------------

View File

@@ -407,6 +407,17 @@ static void hb_compChkEnvironVar( HB_COMP_DECL, const char *szSwitch )
HB_COMP_PARAM->supported &= ~HB_COMPFLAG_OPTJUMP;
break;
case 'L':
case 'l':
if( s[i] == '-' )
{
i++;
hb_pp_setMultiLine( HB_COMP_PARAM->pLex->pPP, HB_FALSE );
}
else
hb_pp_setMultiLine( HB_COMP_PARAM->pLex->pPP, HB_TRUE );
break;
case 'm':
case 'M':
if( s[i] == '+' )
@@ -1077,7 +1088,7 @@ void hb_compChkCompilerSwitch( HB_COMP_DECL, int iArg, const char * const Args[]
if( !szStrEnv || szStrEnv[0] == '\0' )
{
if( szStrEnv )
hb_xfree( ( void * ) szStrEnv );
hb_xfree( szStrEnv );
szStrEnv = hb_getenv( "CLIPPERCMD" );
}
@@ -1105,7 +1116,7 @@ void hb_compChkCompilerSwitch( HB_COMP_DECL, int iArg, const char * const Args[]
hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );
}
}
hb_xfree( ( void * ) szStrEnv );
hb_xfree( szStrEnv );
}
}
}
@@ -1118,7 +1129,7 @@ void hb_compChkPaths( HB_COMP_DECL )
{
if( szInclude[0] != '\0' )
hb_pp_addSearchPath( HB_COMP_PARAM->pLex->pPP, szInclude, HB_FALSE );
hb_xfree( ( void * ) szInclude );
hb_xfree( szInclude );
}
}
@@ -1176,7 +1187,7 @@ void hb_compChkDefines( HB_COMP_DECL, int iArg, const char * const Args[] )
if( !szStrEnv || szStrEnv[0] == '\0' )
{
if( szStrEnv )
hb_xfree( ( void * ) szStrEnv );
hb_xfree( szStrEnv );
szStrEnv = hb_getenv( "CLIPPERCMD" );
}
@@ -1204,7 +1215,7 @@ void hb_compChkDefines( HB_COMP_DECL, int iArg, const char * const Args[] )
hb_compChkDefineSwitch( HB_COMP_PARAM, szSwitch );
}
}
hb_xfree( ( void * ) szStrEnv );
hb_xfree( szStrEnv );
}
}

View File

@@ -143,6 +143,7 @@ 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",
"\n m[+] turn off macrotext substitution",
"\n ? this info",
"\n"

View File

@@ -318,13 +318,11 @@ static void hb_membufFlush( PHB_MEM_BUFFER pBuffer )
pBuffer->ulLen = 0;
}
#ifdef HB_PP_MULTILINE_STRING
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 )
{
@@ -1113,34 +1111,37 @@ static void hb_pp_getLine( PHB_PP_STATE pState )
break;
}
}
#ifdef HB_PP_MULTILINE_STRING
while( ul == ulLen )
if( pState->fMultiLine )
{
u = 1;
while( ul > u && pBuffer[ ul - u ] == ' ' ) ++u;
if( ul >= u && pBuffer[ ul - u ] == ';' )
while( ul == ulLen )
{
ul -= u;
ulLen -= u;
u = hb_membufLen( pState->pBuffer ) - u;
hb_membufRemove( pState->pBuffer, u );
hb_pp_readLine( pState );
ulLen += hb_membufLen( pState->pBuffer ) - u;
pBuffer = hb_membufPtr( pState->pBuffer ) + u - ul;
--ul;
while( ++ul < ulLen && pBuffer[ ul ] != '"' )
u = 1;
while( ul > u && pBuffer[ ul - u ] == ' ' ) ++u;
if( ul >= u && pBuffer[ ul - u ] == ';' )
{
if( pBuffer[ ul ] == '\\' )
ul -= u;
ulLen -= u;
u = hb_membufLen( pState->pBuffer ) - u;
hb_membufRemove( pState->pBuffer, u );
hb_pp_readLine( pState );
ulLen += hb_membufLen( pState->pBuffer ) - u;
pBuffer = hb_membufPtr( pState->pBuffer ) + u - ul;
--ul;
while( ++ul < ulLen && pBuffer[ ul ] != '"' )
{
if( ++ul == ulLen )
break;
if( pBuffer[ ul ] == '\\' )
{
if( ++ul == ulLen )
break;
}
}
}
else
break;
}
else
break;
}
#endif
u = ch != '"' ? 2 : 1;
ulStrip = ul - u;
hb_strRemEscSeq( pBuffer + u, &ulStrip );
@@ -1194,30 +1195,32 @@ static void hb_pp_getLine( PHB_PP_STATE pState )
if( ch == '`' )
ch = '\'';
while( ++ul < ulLen && pBuffer[ ul ] != ch ) {};
#ifdef HB_PP_MULTILINE_STRING
while( ul == ulLen )
if( pState->fMultiLine )
{
HB_SIZE u = 1;
while( ul > u && pBuffer[ ul - u ] == ' ' ) ++u;
if( ul >= u && pBuffer[ ul - u ] == ';' )
while( ul == ulLen )
{
ul -= u;
ulLen -= u;
u = hb_membufLen( pState->pBuffer ) - u;
hb_membufRemove( pState->pBuffer, u );
hb_pp_readLine( pState );
ulLen += hb_membufLen( pState->pBuffer ) - u;
pBuffer = hb_membufPtr( pState->pBuffer ) + u - ul;
--ul;
while( ++ul < ulLen && pBuffer[ ul ] != ch );
}
else
{
ul = ulLen;
break;
HB_SIZE u = 1;
while( ul > u && pBuffer[ ul - u ] == ' ' ) ++u;
if( ul >= u && pBuffer[ ul - u ] == ';' )
{
ul -= u;
ulLen -= u;
u = hb_membufLen( pState->pBuffer ) - u;
hb_membufRemove( pState->pBuffer, u );
hb_pp_readLine( pState );
ulLen += hb_membufLen( pState->pBuffer ) - u;
pBuffer = hb_membufPtr( pState->pBuffer ) + u - ul;
--ul;
while( ++ul < ulLen && pBuffer[ ul ] != ch );
}
else
{
ul = ulLen;
break;
}
}
}
#endif
hb_pp_tokenAddNext( pState, pBuffer + 1, ul - 1,
HB_PP_TOKEN_STRING );
if( ul == ulLen )
@@ -5392,6 +5395,21 @@ void hb_pp_reset( PHB_PP_STATE pState )
hb_pp_ruleListNonStdFree( &pState->pCommands );
}
/*
* set compatibility flag for multiline strings concatenated by ';'
* f.e.:
* cVar := "line 1;
* line 2;
* line 3"
* It's not Clipper compatible extension and it's not enabled by default
* anyhow old Harbour PP worked in such way and people may have some code
* which needs it
*/
void hb_pp_setMultiLine( PHB_PP_STATE pState, HB_BOOL fMultiLine )
{
pState->fMultiLine = fMultiLine;
}
/*
* add search path for included files
*/