Fix .endmacro in a .define in a macro body

This commit is contained in:
mvax
2023-02-25 12:39:36 -05:00
parent a299ef4210
commit e87325033d

View File

@@ -391,6 +391,7 @@ void MacDef (unsigned Style)
Macro* M; Macro* M;
TokNode* N; TokNode* N;
int HaveParams; int HaveParams;
int DefineActive = 0;
/* We expect a macro name here */ /* We expect a macro name here */
if (CurTok.Tok != TOK_IDENT) { if (CurTok.Tok != TOK_IDENT) {
@@ -491,8 +492,8 @@ void MacDef (unsigned Style)
while (1) { while (1) {
/* 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 */ /* In classic macros, only .endmacro is allowed, but ignore it if it is in a .define */
if (CurTok.Tok == TOK_ENDMACRO) { if (CurTok.Tok == TOK_ENDMACRO && !DefineActive) {
/* Done */ /* Done */
break; break;
} }
@@ -573,6 +574,13 @@ void MacDef (unsigned Style)
} }
++M->TokCount; ++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;
}
/* Read the next token */ /* Read the next token */
NextTok (); NextTok ();
} }
@@ -582,7 +590,7 @@ void MacDef (unsigned Style)
NextTok (); NextTok ();
} }
/* Reset the Incomplete flag now that parsing is done */ /* Reset the Incomplete flag now that parsing is done */
M->Incomplete = 0; M->Incomplete = 0;
Done: Done: