Fix .endmacro not at the start of the line.

This commit is contained in:
mvax
2023-02-25 13:38:02 -05:00
parent 429e90dffd
commit 0a05f78d47

View File

@@ -391,7 +391,7 @@ void MacDef (unsigned Style)
Macro* M; Macro* M;
TokNode* N; TokNode* N;
int HaveParams; int HaveParams;
int DefineActive = 0; int LastTokWasSep = 0;
/* We expect a macro name here */ /* We expect a macro name here */
if (CurTok.Tok != TOK_IDENT) { if (CurTok.Tok != TOK_IDENT) {
@@ -493,7 +493,7 @@ void MacDef (unsigned Style)
/* Check for end of macro */ /* Check for end of macro */
if (Style == MAC_STYLE_CLASSIC) { if (Style == MAC_STYLE_CLASSIC) {
/* In classic macros, only .endmacro is allowed, but ignore it if it is in a .define */ /* 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 */ /* Done */
break; break;
} }
@@ -574,12 +574,8 @@ void MacDef (unsigned Style)
} }
++M->TokCount; ++M->TokCount;
/* Mark if .define has been read until end of line has been reached */ /* Save if last token was a separator to know if .endmacro is valid */
if (CurTok.Tok == TOK_DEFINE) { LastTokWasSep = TokIsSep(CurTok.Tok);
DefineActive = 1;
} else if (TokIsSep(CurTok.Tok)) {
DefineActive = 0;
}
/* Read the next token */ /* Read the next token */
NextTok (); NextTok ();