diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5d1445e168..80aa6cd026 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,25 @@ +20000425-12:40 GMT+1 Ryszard Glab + + *include/hbcomp.h + *source/compiler/harbour.c + *source/compiler/harbour.l + *source/compiler/harbour.y + *source/compiler/hbgenerr.c + *source/pp/ppcore.c + * fixed STATIC var[ ] declaration + * fixed DO &() WITH ... syntax + * fixed reporting of line numbers in errors/warnings messages + NOTE: fix in ppcore.c needs Alexander to review it - anyway + empty lines cannot be buffered by a preprocessor (see + hb_pp_nEmptyStrings) + + *source/rtl/gtstd/gtstd.c + * removed atexit() call when HB_OS_UNIX is defined + + *source/vm/hvm.c + * can be included only if HB_OS_WIN_32 is defined + + 20000425-11:36 GMT+1 Antonio Linares + source/vm/startup.asm Harbour startup for Win32 when not using any C compiler startup diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index 3f7cb20d44..cde0ec4cc0 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -375,6 +375,8 @@ extern USHORT hb_comp_wIfCounter; extern USHORT hb_comp_wWhileCounter; extern USHORT hb_comp_wCaseCounter; +extern BOOL hb_comp_EOL; + extern char * hb_comp_szErrors[]; extern char * hb_comp_szWarnings[]; diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index f41b31173c..7d8d1ea0a8 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -107,7 +107,6 @@ int hb_comp_iErrorCount; char hb_comp_cVarType; /* current declared variable type */ BOOL hb_comp_bDontGenLineNum = FALSE; /* suppress line number generation */ ULONG hb_comp_ulLastLinePos; /* position of last opcode with line number */ -ULONG hb_comp_ulMessageFix; /* Position of the message which needs to be changed */ int hb_comp_iStaticCnt; /* number of defined statics variables on the PRG */ int hb_comp_iVarScope; /* holds the scope for next variables to be defined */ PHB_FNAME hb_comp_pOutPath = NULL; @@ -116,6 +115,7 @@ BOOL hb_comp_bLogo = TRUE; /* print logo */ BOOL hb_comp_bSyntaxCheckOnly = FALSE; /* syntax check only */ int hb_comp_iLanguage = LANG_C; /* default Harbour generated output language */ int hb_comp_iJumpOptimize = 1; +BOOL hb_comp_EOL; typedef struct __EXTERN { @@ -427,7 +427,6 @@ void hb_compVariableAdd( char * szVarName, char cValueType ) { /* Variable declaration is outside of function/procedure body. In this case only STATIC and PARAMETERS variables are allowed. */ - --hb_comp_iLine; hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_OUTSIDE, NULL, NULL ); return; } @@ -438,7 +437,6 @@ void hb_compVariableAdd( char * szVarName, char cValueType ) */ if( ( hb_comp_functions.pLast->bFlags & FUN_STATEMENTS ) && !( hb_comp_iVarScope == VS_FIELD || ( hb_comp_iVarScope & VS_MEMVAR ) ) ) { - --hb_comp_iLine; hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_FOLLOWS_EXEC, ( hb_comp_iVarScope == VS_LOCAL ? "LOCAL" : "STATIC" ), NULL ); } @@ -448,7 +446,10 @@ void hb_compVariableAdd( char * szVarName, char cValueType ) /* variable defined in a function/procedure */ hb_compCheckDuplVars( pFunc->pFields, szVarName, hb_comp_iVarScope ); hb_compCheckDuplVars( pFunc->pStatics, szVarName, hb_comp_iVarScope ); - if( !( hb_comp_iVarScope & VS_PRIVATE || hb_comp_iVarScope == VS_PUBLIC ) ) + /*NOTE: Clipper warns if PARAMETER variable duplicates the MEMVAR + * declaration + */ + if( !( hb_comp_iVarScope == VS_PRIVATE || hb_comp_iVarScope == VS_PUBLIC ) ) hb_compCheckDuplVars( pFunc->pMemvars, szVarName, hb_comp_iVarScope ); } else @@ -2310,8 +2311,6 @@ static void hb_compCheckDuplVars( PVAR pVar, char * szVarName, int iVarScope ) { if( ! strcmp( pVar->szName, szVarName ) ) { - if( ! ( iVarScope & VS_PARAMETER ) ) - --hb_comp_iLine; hb_compErrorDuplVar( szVarName ); break; } @@ -2883,9 +2882,9 @@ static void hb_compInitVars( void ) hb_comp_iErrorCount = 0; hb_comp_cVarType = ' '; hb_comp_ulLastLinePos = 0; - hb_comp_ulMessageFix = 0; hb_comp_iStaticCnt = 0; hb_comp_iVarScope = VS_LOCAL; + hb_comp_EOL = FALSE; } static void hb_compGenOutput( int iLanguage ) diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index 9c2b8ab052..355f5aaa86 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -1264,10 +1264,11 @@ Separator {SpaceTab} if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; unput( yytext[ yyleng-1 ] ); if( hb_comp_iState == WHILE || - hb_comp_iState == DO || - hb_comp_iState == MACROVAR || - hb_comp_iState == MACROTEXT || - hb_comp_iState == IDENTIFIER ) + hb_comp_iState == DO || + hb_comp_iState == MACROVAR || + hb_comp_iState == MACROTEXT || + hb_comp_iState == IDENTIFIER || + hb_comp_iState == SEPARATOR ) { /* DO WITH */ hb_comp_iState =WITH; return WITH; diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index f43a1830aa..6bfb155b70 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -237,21 +237,21 @@ Main : { hb_compLinePush(); } Source { } | /* empty file */ ; -Source : Crlf - | VarDefs - | FieldsDef - | MemvarDef - | Function - | Statement - | Line - | Source Crlf - | Source Function - | Source Statement - | Source VarDefs - | Source FieldsDef - | Source MemvarDef - | Source Line - | Source error Crlf { yyclearin; } +Source : Crlf { hb_comp_EOL = FALSE; } + | VarDefs { hb_comp_EOL = FALSE; } + | FieldsDef { hb_comp_EOL = FALSE; } + | MemvarDef { hb_comp_EOL = FALSE; } + | Function { hb_comp_EOL = FALSE; } + | Statement { hb_comp_EOL = FALSE; } + | Line { hb_comp_EOL = FALSE; } + | Source Crlf { hb_comp_EOL = FALSE; } + | Source Function { hb_comp_EOL = FALSE; } + | Source Statement { hb_comp_EOL = FALSE; } + | Source VarDefs { hb_comp_EOL = FALSE; } + | Source FieldsDef { hb_comp_EOL = FALSE; } + | Source MemvarDef { hb_comp_EOL = FALSE; } + | Source Line { hb_comp_EOL = FALSE; } + | Source error Crlf { hb_comp_EOL = FALSE; yyclearin; } ; Line : LINE NUM_INTEGER LITERAL Crlf @@ -303,7 +303,7 @@ Statement : ExecFlow CrlfStmnt { } | ExprPostOp CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } | ExprOperEq CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } | ExprEqual CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ExprAssign CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } + | ExprAssign CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } | DoProc CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } | BREAK CrlfStmnt { hb_compGenBreak(); hb_compGenPCode2( HB_P_DOSHORT, 0 ); hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } @@ -1128,8 +1128,8 @@ IfEndif : IfBegin EndIf { hb_compGenJumpHere( $1 ); } | IfBegin IfElseIf IfElse EndIf { hb_compGenJumpHere( $1 ); hb_compElseIfFix( $2 ); } ; -EmptyStats : /* empty */ { hb_comp_bDontGenLineNum = TRUE; } - | Statements +EmptyStats : /* empty */ { hb_comp_bDontGenLineNum = TRUE; hb_comp_EOL = FALSE; } + | Statements { hb_comp_EOL = FALSE; } ; IfBegin : IF SimpleExpression { ++hb_comp_wIfCounter; hb_compLinePush(); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2 ) ); $$ = hb_compGenJumpFalse( 0 ); hb_compLinePush(); } @@ -1202,7 +1202,6 @@ DoCaseBegin : DoCaseStart { } | DoCaseStart Statements { if( $2 > 0 ) { - --hb_comp_iLine; hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_MAYHEM_IN_CASE, NULL, NULL ); } } @@ -1413,7 +1412,7 @@ DoArgument : IdentName { $$ = hb_compExprNewVarRef( $1 ); } | PareExpList { $$ = $1; } ; -Crlf : '\n' { ++hb_comp_iLine; } +Crlf : '\n' { ++hb_comp_iLine; hb_comp_EOL = TRUE; } | ';' { hb_comp_bDontGenLineNum = TRUE; } ; @@ -1477,6 +1476,7 @@ int hb_compYACCMain( char * szName ) void yyerror( char * s ) { + hb_comp_EOL = FALSE; /* we are in the middle of a line */ if( yytext[ 0 ] == '\n' ) hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_YACC, s, "" ); else @@ -1863,9 +1863,9 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue ) HB_EXPR_PTR pVar = hb_compExprNewVar( szName ); HB_EXPR_PTR pAssign; - hb_compStaticDefStart(); /* switch to statics pcode buffer */ /* create a static variable */ hb_compVariableAdd( szName, 'A' ); + hb_compStaticDefStart(); /* switch to statics pcode buffer */ /* create an array */ hb_compExprGenPush( pInitValue ); hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) ); diff --git a/harbour/source/compiler/hbgenerr.c b/harbour/source/compiler/hbgenerr.c index 65894fbd17..b59176c756 100644 --- a/harbour/source/compiler/hbgenerr.c +++ b/harbour/source/compiler/hbgenerr.c @@ -113,9 +113,12 @@ char * hb_comp_szWarnings[] = void hb_compGenError( char * szErrors[], char cPrefix, int iError, char * szError1, char * szError2 ) { + int iLine = hb_comp_iLine; + + if( hb_comp_EOL ) + --iLine; if( hb_comp_files.pLast != NULL && hb_comp_files.pLast->szFileName != NULL ) - printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, hb_comp_iLine + hb_pp_nEmptyStrings ); - + printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, iLine + hb_pp_nEmptyStrings ); printf( "Error %c%04i ", cPrefix, iError ); printf( szErrors[ iError - 1 ], szError1, szError2 ); printf( "\n" ); @@ -130,11 +133,15 @@ void hb_compGenError( char * szErrors[], char cPrefix, int iError, char * szErro void hb_compGenWarning( char * szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2) { char * szText = szWarnings[ iWarning - 1 ]; + int iLine = hb_comp_iLine; + + if( hb_comp_EOL ) + --iLine; if( ( szText[ 0 ] - '0' ) <= hb_comp_iWarnings ) { if( hb_comp_files.pLast != NULL && hb_comp_files.pLast->szFileName != NULL ) - printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, hb_comp_iLine + hb_pp_nEmptyStrings ); + printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, iLine + hb_pp_nEmptyStrings ); printf( "Warning %c%04i ", cPrefix, iWarning ); printf( szText + 1, szWarning1, szWarning2 ); printf( "\n" ); diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index 20859d793f..9dc4103a3a 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -2047,6 +2047,13 @@ int hb_pp_RdStr( FILE * handl_i, char * buffer, int maxlen, BOOL lDropSpaces, ch } } while(--readed >= 0 && ( buffer[readed] == ' ' || buffer[readed] == '\t') ); + /* rglab: start */ + if( cha == '\n' && readed < 0 ) + { + readed = 0; + buffer[ readed ] = ' '; /* return an empty line */ + } + /* rglab: end */ if( buffer[readed] != ';' && s_ParseState != STATE_COMMENT ) s_ParseState = STATE_NORMAL; readed++; diff --git a/harbour/source/rtl/gtstd/gtstd.c b/harbour/source/rtl/gtstd/gtstd.c index d1bac0b3eb..98f8fe04e4 100644 --- a/harbour/source/rtl/gtstd/gtstd.c +++ b/harbour/source/rtl/gtstd/gtstd.c @@ -70,7 +70,7 @@ void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr ) struct termios ta; tcgetattr( STDIN_FILENO, &startup_attributes ); - atexit( restore_input_mode ); +// atexit( restore_input_mode ); tcgetattr( STDIN_FILENO, &ta ); ta.c_lflag &= ~( ICANON | ECHO ); diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 65ed18eeeb..0dabfdbb7e 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -69,7 +69,10 @@ #include "hbpcode.h" #include "hbset.h" -#include +#ifdef HB_OS_WIN_32 + /* do not include it on U*ix and pure DOS */ + #include +#endif typedef struct _SYMBOLS {