2006-03-02 18:00 UTC+0100 Ryszard Glab <rglab//imid.med.pl>
* source/compiler/harbour.l
* source/pp/ppcomp.c
* source/pp/ppcore.c
* source/pp/pptable.c
* fixed compilation of included files in cases when the file
ends with ';' (with no LF or CR)
* fixed translation of nested command/translate
* fixed translation of TEXT/ENDTEXT to be more Clipper compatible
(added new hidden preprocessor directive
__text|ParseBlockCode|EndBlockCode|StartBlockCode
currently TEXT is preprocessed using:
#command TEXT => __text|Qout(%s)|QQOut()
#command TEXT TO FILE <f> => ;
__text|Qout(%s)|__TextRestore()|__TextSave(<f>)
ParseBlockCode is called for every line beetwen TEXT/ENDTEXT,
%s is replaced with the text enclosed with []
This commit is contained in:
@@ -8,6 +8,26 @@
|
||||
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
* harbour/makefile.vc
|
||||
* harbour/contrib/mysql/tmysql.prg
|
||||
+ added functions sql_commit(), sql_rollback()(CLASS TMySQLServer)
|
||||
to support transactions with InnoDB table types
|
||||
+ added function sql_version() (CLASS TMySQLServer)
|
||||
returns 5 digit numeric version of MySQL server
|
||||
|
||||
* harbour/source/codepage/cdpsl437.c
|
||||
* harbour/source/codepage/cdpsl852.c
|
||||
* harbour/source/codepage/cdpslwin.c
|
||||
* harbour/source/codepage/cdpsliso.c
|
||||
+ Update startup code to work with MSC
|
||||
|
||||
2006-03-02 18:00 UTC+0100 Ryszard Glab <rglab//imid.med.pl>
|
||||
* source/compiler/harbour.l
|
||||
* source/pp/ppcomp.c
|
||||
* source/pp/ppcore.c
|
||||
+added new hidden preprocessor directive
|
||||
* fixed compilation of included files in cases when the file
|
||||
|
||||
* fixed translation of nested command/translate
|
||||
* fixed translation of TEXT/ENDTEXT to be more Clipper compatible
|
||||
+added new hidden preprocessor directive
|
||||
__text|ParseBlockCode|EndBlockCode|StartBlockCode
|
||||
|
||||
@@ -165,39 +165,6 @@ Separator {SpaceTab}
|
||||
return '[';
|
||||
}
|
||||
}
|
||||
|
||||
"QOUT([" {
|
||||
/* preprocessed TEXT/ENDTEXT line
|
||||
NOTE: Clipper preprocesses TEXT/ENDTEXT block into a series of QOUT calls
|
||||
QOUT("...")<EndOfLine>
|
||||
or
|
||||
QOUT([...])<EndOfLine>
|
||||
[] is used if text contains any string delimiters "'[]
|
||||
NOTE: Clipper allows for \[\[nested\]\] only if it is preprocessed from
|
||||
TEXT/ENDTEXT block - in normal code the preprocesor uses the first
|
||||
closing ] as a string terminator.
|
||||
However we have to get some information from the preprocessor about
|
||||
TEXT/ENDTEXT block start/end condition to distinguish code:
|
||||
TEXT
|
||||
some string]) ; qout([some more
|
||||
ENDTEXT
|
||||
from direct calls for qout function
|
||||
QOUT([some string]) ; QOUT([some more])
|
||||
*/
|
||||
if( hb_ppInsideTextBlock )
|
||||
{
|
||||
BEGIN STRING4START;
|
||||
unput( '(' );
|
||||
}
|
||||
else
|
||||
|
||||
yyless( 4 ); /* len of QOUT */
|
||||
|
||||
yylval.string = hb_compIdentifierNew( "QOUT", TRUE );
|
||||
hb_comp_iState = IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
|
||||
<STRING1>[^\x27\n]*\n { BEGIN 0;
|
||||
unput( '\n' );
|
||||
yytext[--yyleng] = '\0';
|
||||
|
||||
@@ -67,13 +67,16 @@
|
||||
#include "hbcomp.h"
|
||||
|
||||
static int strncmp_nocase( char* s1, char* s2, int n );
|
||||
static char *hb_pp_TextCommand( char * ptr, int *pLen );
|
||||
|
||||
BOOL hb_pp_bInline = FALSE;
|
||||
|
||||
static char s_szLine[ HB_PP_STR_SIZE ];
|
||||
static char s_szOutLine[ HB_PP_STR_SIZE ];
|
||||
int hb_pp_LastOutLine = 1;
|
||||
|
||||
static char *s_TextOutFunc = NULL;
|
||||
static char *s_TextEndFunc = NULL;
|
||||
static char *s_TextStartFunc = NULL;
|
||||
/*
|
||||
BOOL bDebug = FALSE;
|
||||
*/
|
||||
@@ -113,38 +116,52 @@ int hb_pp_Internal( FILE * handl_o, char * sOut )
|
||||
|
||||
if( hb_ppInsideTextBlock )
|
||||
{
|
||||
char cQuote;
|
||||
int i;
|
||||
|
||||
ptr = s_szLine;
|
||||
HB_SKIPTABSPACES( ptr );
|
||||
if( !strncmp_nocase( ptr,"ENDTEXT",7 ) && *(ptr+7) <= ' ' )
|
||||
{
|
||||
hb_ppInsideTextBlock = FALSE;
|
||||
strcpy( s_szLine,"__TextRestore()" );
|
||||
if( s_TextEndFunc )
|
||||
{
|
||||
strcpy( s_szLine, s_TextEndFunc );
|
||||
hb_xfree( (void *)s_TextEndFunc );
|
||||
}
|
||||
else
|
||||
{
|
||||
s_szLine[ 0 ] = '\0';
|
||||
}
|
||||
if( s_TextOutFunc )
|
||||
{
|
||||
hb_xfree( (void *)s_TextOutFunc );
|
||||
}
|
||||
if( s_TextStartFunc )
|
||||
{
|
||||
hb_xfree( (void *)s_TextStartFunc );
|
||||
}
|
||||
hb_ppNestedLiteralString = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if( !strchr( s_szLine,'\"' ) )
|
||||
cQuote = '\"';
|
||||
else if( !strchr( s_szLine,'\'' ) )
|
||||
cQuote = '\'';
|
||||
if( s_TextOutFunc )
|
||||
{
|
||||
memmove( s_szLine+1, s_szLine, lens++ );
|
||||
s_szLine[ 0 ] = '[';
|
||||
s_szLine[ lens++ ] = ']';
|
||||
s_szLine[ lens ] = '\0';
|
||||
lens = snprintf( s_szOutLine, HB_PP_STR_SIZE, s_TextOutFunc, s_szLine );
|
||||
memcpy( s_szLine, s_szOutLine, lens+1 );
|
||||
hb_ppNestedLiteralString = TRUE;
|
||||
}
|
||||
else
|
||||
cQuote = '[';
|
||||
|
||||
s_szLine[ lens++ ] = ( cQuote == '[' )? ']':cQuote;
|
||||
s_szLine[ lens++ ] = ')';
|
||||
s_szLine[ lens ] = '\0';
|
||||
for( i=lens;i>=0;i-- )
|
||||
*( s_szLine+i+6 ) = *( s_szLine+i );
|
||||
s_szLine[0] = 'Q'; s_szLine[1] = 'O'; s_szLine[2] = 'u';
|
||||
s_szLine[3] = 't'; s_szLine[4] = '('; s_szLine[5] = cQuote;
|
||||
{
|
||||
s_szLine[ 0 ] = '\0'; /* discard text */
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if( s_szLine[ lens - 1 ] == ';' )
|
||||
{
|
||||
lContinue = 1;
|
||||
lContinue = pFile->lenBuffer ? 1 : 0;
|
||||
lens--;
|
||||
lens--;
|
||||
while( s_szLine[ lens ] == ' ' || s_szLine[ lens ] == '\t' ) lens--;
|
||||
@@ -203,10 +220,20 @@ int hb_pp_Internal( FILE * handl_o, char * sOut )
|
||||
hb_pp_LastOutLine = hb_comp_iLine;
|
||||
*/
|
||||
hb_pp_ParseExpression( ptr, s_szOutLine );
|
||||
if( !strncmp( ptr,"text QOut;",10 ) )
|
||||
if( !strncmp( ptr,"__text|",7 ) )
|
||||
{
|
||||
/* printf( "\ntext QOut %d\n",strlen(ptr) ); */
|
||||
memcpy( ptr, ptr+10, strlen(ptr)-9 );
|
||||
/* internal handling of TEXT/ENDTEXT command
|
||||
* __text;functionOut;functionEnd;functionStart
|
||||
*/
|
||||
int len;
|
||||
|
||||
len = strlen(ptr) - 6;
|
||||
memcpy( ptr, ptr+7, len );
|
||||
s_TextOutFunc = hb_pp_TextCommand( ptr, &len );
|
||||
s_TextEndFunc = hb_pp_TextCommand( ptr, &len );
|
||||
s_TextStartFunc = hb_pp_TextCommand( ptr, &len );
|
||||
if( s_TextStartFunc )
|
||||
memcpy( s_szLine, s_TextStartFunc, strlen(s_TextStartFunc)+1 );
|
||||
hb_ppInsideTextBlock = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -300,6 +327,44 @@ int hb_pp_Internal( FILE * handl_o, char * sOut )
|
||||
return lens;
|
||||
}
|
||||
|
||||
static char *hb_pp_TextCommand( char * ptr, int *pLen )
|
||||
{
|
||||
int i;
|
||||
char *cCommand = NULL;
|
||||
|
||||
i = 0;
|
||||
while( ptr[i] && ptr[i] != '|' )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
if( i > 0 )
|
||||
{
|
||||
cCommand = (char *)hb_xgrab( i+1 );
|
||||
i = 0;
|
||||
while( ptr[i] && ptr[i] != '|' )
|
||||
{
|
||||
cCommand[ i ] = ptr[ i ];
|
||||
i++;
|
||||
}
|
||||
cCommand[ i ] = '\0';
|
||||
*pLen -= i+1;
|
||||
if( *pLen )
|
||||
memcpy( ptr, ptr+i+1, *pLen );
|
||||
else
|
||||
ptr[ 0 ] ='\0';
|
||||
}
|
||||
else if( i == 0 && *ptr == '|' )
|
||||
{
|
||||
(*pLen)--;
|
||||
if( *pLen )
|
||||
memcpy( ptr, ptr+1, *pLen );
|
||||
else
|
||||
*ptr ='\0';
|
||||
}
|
||||
|
||||
return cCommand;
|
||||
}
|
||||
|
||||
int hb_pp_ReadRules( void )
|
||||
{
|
||||
PFILE pFile;
|
||||
|
||||
@@ -91,7 +91,7 @@ int hb_pp_ParseDefine( char * ); /* Process #define dire
|
||||
|
||||
static COMMANDS * AddCommand( char * ); /* Add new #command to an array */
|
||||
static COMMANDS * AddTranslate( char * ); /* Add new #translate to an array */
|
||||
static DEFINES * DefSearch( char *, BOOL * );
|
||||
static DEFINES * DefSearch( char *, int, BOOL * );
|
||||
static COMMANDS * ComSearch( char *, COMMANDS * );
|
||||
static COMMANDS * TraSearch( char *, COMMANDS * );
|
||||
|
||||
@@ -263,35 +263,6 @@ void hb_pp_SetRules( HB_INCLUDE_FUNC_PTR hb_compInclude, BOOL hb_comp_bQuiet )
|
||||
|
||||
hb_pp_ReadRules();
|
||||
|
||||
/*
|
||||
{
|
||||
COMMANDS * stcmd;
|
||||
DEFINES * stdef;
|
||||
|
||||
stcmd = hb_pp_topCommand;
|
||||
while ( stcmd )
|
||||
{
|
||||
printf( "Command: %s Pattern: %s\n", stcmd->name, stcmd->mpatt );
|
||||
stcmd = stcmd->last;
|
||||
}
|
||||
|
||||
stcmd = hb_pp_topTranslate;
|
||||
while ( stcmd )
|
||||
{
|
||||
printf( "Translate: %s \nPattern: %s\n", stcmd->name, stcmd->mpatt );
|
||||
stcmd = stcmd->last;
|
||||
}
|
||||
|
||||
stdef = hb_pp_topDefine;
|
||||
while ( stdef && s_kolAddDefs > 3 )
|
||||
{
|
||||
printf( "Define: %s Value: %s\n", stdef->name, stdef->value );
|
||||
stdef = stdef->last;
|
||||
s_kolAddDefs--;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if ( s_kolAddComs || s_kolAddTras || s_kolAddDefs > 3 )
|
||||
{
|
||||
if( ! hb_comp_bQuiet )
|
||||
@@ -735,10 +706,11 @@ DEFINES * hb_pp_AddDefine( char * defname, char * value )
|
||||
{
|
||||
BOOL isNew;
|
||||
DEFINES * stdef;
|
||||
int len = strlen( defname );
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_pp_AddDefine(%s, %s)", defname, value));
|
||||
|
||||
stdef = DefSearch( defname, &isNew );
|
||||
stdef = DefSearch( defname, len, &isNew );
|
||||
|
||||
if( stdef != NULL )
|
||||
{
|
||||
@@ -756,7 +728,7 @@ DEFINES * hb_pp_AddDefine( char * defname, char * value )
|
||||
stdef->last = hb_pp_topDefine;
|
||||
hb_pp_topDefine = stdef;
|
||||
stdef->name = hb_strdup( defname );
|
||||
stdef->namelen = strlen( defname );
|
||||
stdef->namelen = len;
|
||||
stdef->npars = -1;
|
||||
|
||||
s_kolAddDefs++;
|
||||
@@ -773,12 +745,14 @@ static int ParseUndef( char * sLine )
|
||||
char defname[ MAX_NAME ];
|
||||
DEFINES * stdef;
|
||||
BOOL isNew;
|
||||
int len;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("ParseUndef(%s)", sLine));
|
||||
|
||||
NextWord( &sLine, defname, FALSE );
|
||||
|
||||
if( ( stdef = DefSearch(defname, &isNew ) ) != NULL )
|
||||
|
||||
len = strlen( defname );
|
||||
if( ( stdef = DefSearch(defname, len, &isNew ) ) != NULL )
|
||||
{
|
||||
if( isNew )
|
||||
{
|
||||
@@ -799,12 +773,13 @@ static int ParseIfdef( char * sLine, int usl )
|
||||
{
|
||||
char defname[ MAX_NAME ];
|
||||
DEFINES * stdef;
|
||||
int len;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("ParseIfdef(%s, %d)", sLine, usl));
|
||||
|
||||
if( hb_pp_nCondCompile==0 || hb_pp_aCondCompile[hb_pp_nCondCompile-1])
|
||||
{
|
||||
NextWord( &sLine, defname, FALSE );
|
||||
len = NextWord( &sLine, defname, FALSE );
|
||||
if( *defname == '\0' )
|
||||
hb_compGenError( hb_pp_szErrors, 'F', HB_PP_ERR_DEFINE_ABSENT, NULL, NULL );
|
||||
}
|
||||
@@ -815,7 +790,7 @@ static int ParseIfdef( char * sLine, int usl )
|
||||
}
|
||||
if( hb_pp_nCondCompile==0 || hb_pp_aCondCompile[hb_pp_nCondCompile-1])
|
||||
{
|
||||
if( ( (stdef = DefSearch(defname,NULL)) != NULL && usl )
|
||||
if( ( (stdef = DefSearch(defname,len,NULL)) != NULL && usl )
|
||||
|| ( stdef == NULL && !usl ) ) hb_pp_aCondCompile[hb_pp_nCondCompile] = 1;
|
||||
else hb_pp_aCondCompile[hb_pp_nCondCompile] = 0;
|
||||
}
|
||||
@@ -827,7 +802,7 @@ static int ParseIfdef( char * sLine, int usl )
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DEFINES * DefSearch( char * defname, BOOL * isNew )
|
||||
static DEFINES * DefSearch( char * defname, int len, BOOL * isNew )
|
||||
{
|
||||
int kol = 0,j;
|
||||
DEFINES * stdef = hb_pp_topDefine;
|
||||
@@ -837,7 +812,7 @@ static DEFINES * DefSearch( char * defname, BOOL * isNew )
|
||||
while( stdef != NULL )
|
||||
{
|
||||
kol++;
|
||||
if( stdef->name != NULL )
|
||||
if( stdef->name != NULL && stdef->namelen == len )
|
||||
{
|
||||
for( j=0; *(stdef->name+j) == *(defname+j) &&
|
||||
*(stdef->name+j) != '\0'; j++ );
|
||||
@@ -1413,7 +1388,7 @@ int hb_pp_ParseExpression( char * sLine, char * sOutLine )
|
||||
printf( "Token: >%s< Line: >%s<\n", sToken, sLine );
|
||||
#endif
|
||||
|
||||
if( (stdef=DefSearch(sToken,NULL)) != NULL )
|
||||
if( (stdef=DefSearch(sToken,lenToken,NULL)) != NULL )
|
||||
{
|
||||
ptrb = ptri - lenToken;
|
||||
|
||||
@@ -2676,23 +2651,26 @@ static int getExpReal( char * expreal, char ** ptri, BOOL prlist, int maxrez, BO
|
||||
State = STATE_BRACKET;
|
||||
StBr3 = 1;
|
||||
}
|
||||
/* Ron Pinkas added 2001-01-08 */
|
||||
else if( **ptri == ')' && StBr1 == 0 )
|
||||
{
|
||||
rez = TRUE;
|
||||
}
|
||||
/* Ron Pinkas added 2000-06-02 */
|
||||
else if( **ptri == ']' && StBr2 == 0 )
|
||||
{
|
||||
rez = TRUE;
|
||||
}
|
||||
else if( **ptri == '}' && StBr3 == 0 )
|
||||
{
|
||||
rez = TRUE;
|
||||
}
|
||||
else if( **ptri == '&' )
|
||||
{
|
||||
bMacro = TRUE;
|
||||
}
|
||||
/* Ron Pinkas end 2000-06-02 */
|
||||
else if( **ptri == ' ' )
|
||||
{
|
||||
State = STATE_ID_END;
|
||||
/* Ron Pinkas added 2000-06-02 */
|
||||
bMacro = FALSE;
|
||||
/* Ron Pinkas end 2000-06-02 */
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -195,9 +195,9 @@ void hb_pp_Table( void )
|
||||
static COMMANDS sC___64 = {0,"?",1,"\2 \1A10\3","QOut( \1A00 )",&sC___63 };
|
||||
static COMMANDS sC___65 = {0,"?",1,"? \2 \1A10\3","QQOut( \1A00 )",&sC___64 };
|
||||
static COMMANDS sC___66 = {0,"EJECT",5,"","__Eject()",&sC___65 };
|
||||
static COMMANDS sC___67 = {0,"TEXT",4,"","text QOut;",&sC___66 };
|
||||
static COMMANDS sC___68 = {0,"TEXT",4,"TO FILE \1A40","text QOut; __TextSave( \1A30 )",&sC___67 };
|
||||
static COMMANDS sC___69 = {0,"TEXT",4,"TO PRINTER","text QOut;__TextSave('PRINTER')",&sC___68 };
|
||||
static COMMANDS sC___67 = {0,"TEXT",4,"","__text|QOut(%s)|QQOut()",&sC___66 };
|
||||
static COMMANDS sC___68 = {0,"TEXT",4,"TO FILE \1A40","__text|QOut(%s)|__TextRestore()|__TextSave( \1A30 )",&sC___67 };
|
||||
static COMMANDS sC___69 = {0,"TEXT",4,"TO PRINTER","__text|QOut(%s)|__TextRestore()|__TextSave('PRINTER')",&sC___68 };
|
||||
static COMMANDS sC___70 = {0,"CLS",3,"","Scroll() ; SetPos(0,0)",&sC___69 };
|
||||
static COMMANDS sC___71 = {0,"CLEAR",5,"SCREEN","CLS",&sC___70 };
|
||||
static COMMANDS sC___72 = {0,"@",1,"\1A00, \1B00","Scroll( \1A00, \1B00, \1A00 ) ; SetPos( \1A00, \1B00 )",&sC___71 };
|
||||
|
||||
Reference in New Issue
Block a user