From d0b4b7597055cf7e47ce550a5b03cf01b6dc8f66 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sat, 17 Dec 2016 22:34:21 -0600 Subject: [PATCH] Fix problem where if a macro's name appeared inside the macro, it would be expanded repeatedly, leading to a crash. This is a problem introduced by the scanner changes between ORCA/C 2.1.0 and ORCA/C 2.1.1 B3. The following examples demonstrate the problem: #define m m m #define f(x) f(x) f(a) --- Scanner.pas | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Scanner.pas b/Scanner.pas index 8204834..4c68397 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -1308,7 +1308,7 @@ if macro^.parameters >= 0 then begin {find the values of the parameters} if not gettingFileName then {put back the source stream token} PutBackToken(token, true); Error(12); - end; + end; {if} end {if} else begin Error(13); @@ -3552,6 +3552,7 @@ var expandEnabled: boolean; {can a token be expanded?} i: 0..maxint; {loop/index counter} inhibit: boolean; {inhibit macro expansion?} + lExpandMacros: boolean; {local copy of expandMacros} lPrintMacroExpansions: boolean; {local copy of printMacroExpansions} mPtr: macroRecordPtr; {for checking list of macros} setLength: boolean; {is the current string a p-string?} @@ -3652,7 +3653,10 @@ if tokenList <> nil then begin {get a token put back by a macro} token.kind := ident; if token.kind = ident then begin CopyString(@workString, token.name); + lExpandMacros := expandMacros; + expandMacros := false; CheckIdentifier; + expandMacros := lExpandMacros; end; {if} { dead code if token.kind = ident then