From 04cd884f8f08e98cd9826287d2d272a23f68510f Mon Sep 17 00:00:00 2001 From: Marco Aurelio da Costa Date: Tue, 27 Apr 2021 08:21:06 -0300 Subject: [PATCH] Prevent missed .ENDMACRO in included file --- src/ca65/macro.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/ca65/macro.c b/src/ca65/macro.c index 56791eb66..34d87e65f 100644 --- a/src/ca65/macro.c +++ b/src/ca65/macro.c @@ -491,6 +491,23 @@ void MacDef (unsigned Style) */ while (1) { + /* Check for include */ + if (CurTok.Tok == TOK_INCLUDE) { + /* Include another file */ + NextTok (); + /* Name must follow */ + if (CurTok.Tok != TOK_STRCON) { + ErrorSkip ("String constant expected"); + } else { + SB_Terminate (&CurTok.SVal); + if (NewInputFile (SB_GetConstBuf (&CurTok.SVal)) == 0) { + /* Error opening the file, skip remainder of line */ + SkipUntilSep (); + } + } + NextTok (); + } + /* Check for end of macro */ if (Style == MAC_STYLE_CLASSIC) { /* In classic macros, only .endmacro is allowed */ @@ -510,22 +527,6 @@ void MacDef (unsigned Style) } } - if (CurTok.Tok == TOK_INCLUDE) { - /* Include another file */ - NextTok (); - /* Name must follow */ - if (CurTok.Tok != TOK_STRCON) { - ErrorSkip ("String constant expected"); - } else { - SB_Terminate (&CurTok.SVal); - if (NewInputFile (SB_GetConstBuf (&CurTok.SVal)) == 0) { - /* Error opening the file, skip remainder of line */ - SkipUntilSep (); - } - } - NextTok (); - } - /* Check for a .LOCAL declaration */ if (CurTok.Tok == TOK_LOCAL && Style == MAC_STYLE_CLASSIC) {