From ca31045bcf2bef44910779c842b7862e1814433f Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Tue, 1 Jun 1999 08:40:05 +0000 Subject: [PATCH] June 1st. 1999 00:30 Ron Pinkas Harbour.y -> modified pcode generation to move the push of the counter variable to the NEXT rather than the FOR so loop code may manipulate the counter vaiable. TEST/WORKING/TestFor.prg -> added this file --- harbour/ChangeLog | 8 ++++---- harbour/source/compiler/harbour.y | 6 +++--- harbour/tests/working/inifiles.prg | 6 +++--- harbour/tests/working/testfor.prg | 19 +++++++++++++++++++ 4 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 harbour/tests/working/testfor.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0a3762d695..7766762c6c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1546,11 +1546,11 @@ May 31, 1999 Ron Pinkas Added "Sysntax error :" message for the macro operator (&) when followed by a string delimiter. +June 1st. 1999 00:30 Ron Pinkas + Harbour.y -> modified pcode generation to move the push of the counter variable to the NEXT rather than the FOR + so loop code may manipulate the counter vaiable. - - - - + TEST/WORKING/TestFor.prg -> added this file * source/pp/pragma.c * contrib/dot/pp_harb.ch * tests/inline_c.prg diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 03ae5fcd6e..c3e73cdbfb 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -842,7 +842,7 @@ EndCase : ENDCASE { --_wCaseCounter; } | END { --_wCaseCounter; } ; -DoCaseBegin : DOCASE { ++_wCaseCounter; } Crlf +DoCaseBegin : DOCASE { ++_wCaseCounter; } Crlf ; Cases : CASE Expression Crlf { $$ = JumpFalse( 0 ); Line(); } CaseStmts { $$ = GenElseIf( 0, Jump( 0 ) ); JumpHere( $4 ); Line(); } @@ -878,8 +878,8 @@ EndWhile : END ForNext : FOR IDENTIFIER ForAssign Expression { PopId( $2 ); $$ = functions.pLast->lPCodePos; ++_wForCounter; } TO Expression { PushId( $2 ); } - StepExpr Crlf { GenPCode1( _FORTEST ); $$ = JumpTrue( 0 ); PushId( $2 ); } - ForStatements { GenPCode1( _PLUS ); PopId( $2 ); Jump( $5 - functions.pLast->lPCodePos ); JumpHere( $11 ); } + StepExpr Crlf { GenPCode1( _FORTEST ); $$ = JumpTrue( 0 ); /*PushId( $2 )*/; } + ForStatements { PushId( $2 ); GenPCode1( _PLUS ); PopId( $2 ); Jump( $5 - functions.pLast->lPCodePos ); JumpHere( $11 ); } ; ForAssign : '=' diff --git a/harbour/tests/working/inifiles.prg b/harbour/tests/working/inifiles.prg index a88e5b9953..0cf48d9407 100644 --- a/harbour/tests/working/inifiles.prg +++ b/harbour/tests/working/inifiles.prg @@ -181,7 +181,7 @@ static procedure Commit() fwrite(hFile, ::Contents[i][2][j][1] + '=' +; ::Contents[i][2][j][2] + Chr(13) + Chr(10)) endif - next j + next //j fwrite(hFile, Chr(13) + Chr(10)) elseif ValType(::Contents[i][2]) == 'C' @@ -189,8 +189,8 @@ static procedure Commit() Chr(10)) endif - next i + next //i fclose(hFile) return - + diff --git a/harbour/tests/working/testfor.prg b/harbour/tests/working/testfor.prg new file mode 100644 index 0000000000..e334169333 --- /dev/null +++ b/harbour/tests/working/testfor.prg @@ -0,0 +1,19 @@ +FUNCTION MAIN + + LOCAL i + + FOR i := 1 TO 10 + + qout( i ) + + IF i = 4 + __Accept("") + qout(i) + i := 9 + qout(i) + __Accept("") + ENDIF + + NEXT + + RETURN( NIL )