From 83d21ef953530bbb8e7daae9c9c921376aa52433 Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Sat, 3 Mar 2001 06:58:01 +0000 Subject: [PATCH] 2001-03-02 22:50 UTC-0800 Ron Pinkas * contrib/dot/pp.prg ! Fixed handling of [Smart] Stringify of a period terminated macro. --- harbour/ChangeLog | 4 ++ harbour/contrib/dot/pp.prg | 102 +++++++++++++++++++++++++++---------- 2 files changed, 78 insertions(+), 28 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9534ea3d43..fb4d203b7a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,7 @@ +2001-03-02 22:50 UTC-0800 Ron Pinkas + * contrib/dot/pp.prg + ! Fixed handling of [Smart] Stringify of a period terminated macro. + 2001-03-02 09:10 UTC-0800 Ron Pinkas * source/pp/ppcore.c ! Fixed handling of [Smart] Stringify of a period terminated macro. diff --git a/harbour/contrib/dot/pp.prg b/harbour/contrib/dot/pp.prg index 564ac13ccf..8216521d0f 100644 --- a/harbour/contrib/dot/pp.prg +++ b/harbour/contrib/dot/pp.prg @@ -3254,6 +3254,53 @@ FUNCTION NextExp( sLine, cType, aWords, aExp, sNextAnchor ) IF Right( sExp, 1 ) == "&" + IF cType == 'A' + sExp += NextExp( @sLine, '<', NIL, NIL, sNextAnchor ) + ELSE + sTemp := NextExp( @sLine, cType, NIL, NIL, sNextAnchor ) // Content + IF sTemp == NIL + Alert( "ERROR! Invalid '&'" ) + ELSE + sExp += sTemp + ENDIF + ENDIF + + IF Left( sLine, 1 ) == '.' + // Get the macro terminator. + IF cType == 'A' + sExp += NextExp( @sLine, '<', NIL, NIL, sNextAnchor ) + ELSE + sTemp := NextExp( @sLine, cType, NIL, NIL, sNextAnchor ) // Content + IF sTemp == NIL + Alert( "ERROR! Invalid '&'" ) + ELSE + sExp += sTemp + ENDIF + ENDIF + + IF ( IsAlpha( SubStr( sLine, 2, 1 ) ) .OR. IsDigit( SubStr( sLine, 2, 1 ) ) ) + // Get the macro sufix. + IF cType == 'A' + sExp += NextExp( @sLine, '<', NIL, NIL, sNextAnchor ) + ELSE + sTemp := NextExp( @sLine, cType, NIL, NIL, sNextAnchor ) // Content + IF sTemp == NIL + Alert( "ERROR! Invalid '&'" ) + ELSE + sExp += sTemp + ENDIF + ENDIF + ENDIF + ENDIF + + LOOP // Might need other checks, like cType ',' or 'A' + + ELSEIF Right( sExp, 1 ) $ "}])." .AND. Left( sLine, 1 ) == '[' .AND. ( sNextAnchor != "[" ) /*.AND. At( ']', sLine ) < At( '[', SubStr( sLine, 2 ) ) */ + + sExp += Left( sLine, 1 ) // Open + sLine := SubStr( sLine, 2 ) + sExp += ExtractLeadingWS( @sLine ) + IF cType == 'A' sExp += NextExp( @sLine, '<', NIL, NIL, sNextAnchor ) ELSE @@ -3265,31 +3312,14 @@ FUNCTION NextExp( sLine, cType, aWords, aExp, sNextAnchor ) ENDIF ENDIF - ELSEIF Right( sExp, 1 ) $ "}])." .AND. Left( sLine, 1 ) == '[' .AND. ( sNextAnchor != "[" ) /*.AND. At( ']', sLine ) < At( '[', SubStr( sLine, 2 ) ) */ + sToken := NextToken( @sLine, .T. ) /* bCheckRules */ // Close + IF sToken == NIL .OR. Left( sToken, 1 ) != ']' + Alert( "ERROR! Unbalanced '['" ) + ELSE + sExp += sToken + ENDIF - sExp += Left( sLine, 1 ) // Open - sLine := SubStr( sLine, 2 ) - sExp += ExtractLeadingWS( @sLine ) - - IF cType == 'A' - sExp += NextExp( @sLine, '<', NIL, NIL, sNextAnchor ) - ELSE - sTemp := NextExp( @sLine, cType, NIL, NIL, sNextAnchor ) // Content - IF sTemp == NIL - Alert( "ERROR! Unbalanced '['" ) - ELSE - sExp += sTemp - ENDIF - ENDIF - - sToken := NextToken( @sLine, .T. ) /* bCheckRules */ // Close - IF sToken == NIL .OR. Left( sToken, 1 ) != ']' - Alert( "ERROR! Unbalanced '['" ) - ELSE - sExp += sToken - ENDIF - - LOOP // Might need other checks, like cType ',' or 'A' + LOOP // Might need other checks, like cType ',' or 'A' ELSEIF cType == 'A' .AND. Left( sLine, 1 ) == ',' //.AND. ( sNextAnchor != "," ) @@ -3646,7 +3676,11 @@ FUNCTION PPOut( aResults, aMarkers ) nMatches := Len( xValue ) FOR nMatch := 1 TO nMatches IF Left( xValue[nMatch], 1 ) == '&' - sResult += RTrim( SubStr( xValue[nMatch], 2 ) ) + IF Right( xValue[nMatch], 1 ) == '.' + sResult += SubStr( xValue[nMatch], 2, Len( xValue[nMatch] ) - 2 ) + ELSE + sResult += SubStr( xValue[nMatch], 2 ) + ENDIF ELSEIF '"' $ xValue[nMatch] .AND. "'" $ xValue[nMatch] .AND. ']' $ xValue[nMatch] .AND. Left( xValue[nMatch], 1 ) != '[' sResult += "[[" + RTrim( xValue[nMatch] ) + "]]" ELSEIF '"' $ xValue[nMatch] .AND. ['] $ xValue[nMatch] @@ -3664,7 +3698,11 @@ FUNCTION PPOut( aResults, aMarkers ) ELSE IF ! ( xValue == NIL ) IF Left( xValue, 1 ) == '&' - sResult += RTrim( SubStr( xValue, 2 ) ) + IF Right( xValue, 1 ) == '.' + sResult += SubStr( xValue, 2, Len( xValue ) - 2 ) + ELSE + sResult += SubStr( xValue, 2 ) + ENDIF ELSEIF '"' $ xValue .AND. "'" $ xValue .AND. ']' $ xValue .AND. Left( xValue, 1 ) != '[' sResult += "[[" + xValue + "]]" ELSEIF '"' $ xValue .AND. ['] $ xValue @@ -3686,7 +3724,11 @@ FUNCTION PPOut( aResults, aMarkers ) sResult += xValue[nMatch] ELSE IF Left( xValue[nMatch], 1 ) == '&' - sResult += RTrim( SubStr( xValue[nMatch], 2 ) ) + IF Right( xValue[nMatch], 1 ) == '.' + sResult += SubStr( xValue[nMatch], 2, Len( xValue[nMatch] ) - 2 ) + ELSE + sResult += SubStr( xValue[nMatch], 2 ) + ENDIF ELSE sResult += '"' + RTrim( xValue[nMatch] ) + '"' ENDIF @@ -3702,7 +3744,11 @@ FUNCTION PPOut( aResults, aMarkers ) sResult += xValue ELSE IF Left( xValue, 1 ) == '&' - sResult += RTrim( SubStr( xValue, 2 ) ) + IF Right( xValue, 1 ) == '.' + sResult += SubStr( xValue, 2, Len( xValue ) - 2 ) + ELSE + sResult += SubStr( xValue, 2 ) + ENDIF ELSE sResult += '"' + RTrim( xValue ) + '"' ENDIF