From 0a05f78d47c8a6ea20b97fd570d0f5db054aa387 Mon Sep 17 00:00:00 2001 From: mvax Date: Sat, 25 Feb 2023 13:38:02 -0500 Subject: [PATCH] Fix .endmacro not at the start of the line. --- src/ca65/macro.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ca65/macro.c b/src/ca65/macro.c index 24cdcad38..c09b2412f 100644 --- a/src/ca65/macro.c +++ b/src/ca65/macro.c @@ -391,7 +391,7 @@ void MacDef (unsigned Style) Macro* M; TokNode* N; int HaveParams; - int DefineActive = 0; + int LastTokWasSep = 0; /* We expect a macro name here */ if (CurTok.Tok != TOK_IDENT) { @@ -493,7 +493,7 @@ void MacDef (unsigned Style) /* Check for end of macro */ if (Style == MAC_STYLE_CLASSIC) { /* In classic macros, only .endmacro is allowed, but ignore it if it is in a .define */ - if (CurTok.Tok == TOK_ENDMACRO && !DefineActive) { + if (CurTok.Tok == TOK_ENDMACRO && LastTokWasSep) { /* Done */ break; } @@ -574,12 +574,8 @@ void MacDef (unsigned Style) } ++M->TokCount; - /* Mark if .define has been read until end of line has been reached */ - if (CurTok.Tok == TOK_DEFINE) { - DefineActive = 1; - } else if (TokIsSep(CurTok.Tok)) { - DefineActive = 0; - } + /* Save if last token was a separator to know if .endmacro is valid */ + LastTokWasSep = TokIsSep(CurTok.Tok); /* Read the next token */ NextTok ();