From cf992164f79a0e5c0fd49b445d698be2361a9b67 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Sat, 15 Aug 2020 15:10:32 +0200 Subject: [PATCH] Fix lexer capture sometimes not being reset --- src/asm/lexer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/asm/lexer.c b/src/asm/lexer.c index f11453e8..e143745d 100644 --- a/src/asm/lexer.c +++ b/src/asm/lexer.c @@ -1674,7 +1674,7 @@ static int skipIfBlock(bool toEndc) token = yylex(); if (token == 0) { /* Pass EOF through */ - return token; + break; } else if (atLineStart && token == T_POP_IF) { /* Increase nesting */ nIFDepth++; } else if (atLineStart && nIFDepth == startingDepth) { /* An occasion to finish? */ @@ -1811,6 +1811,7 @@ void lexer_CaptureRept(char **capture, size_t *size) for (;;) { if (c == EOF) { error("Unterminated REPT block\n"); + lexerState->capturing = false; goto finish; } else if (c == '\n') { break; @@ -1824,6 +1825,7 @@ void lexer_CaptureRept(char **capture, size_t *size) } finish: + assert(!lexerState->capturing); *capture = captureStart; *size = lexerState->captureSize - strlen("ENDR"); lexerState->captureBuf = NULL; @@ -1847,6 +1849,7 @@ void lexer_CaptureMacroBody(char **capture, size_t *size) for (;;) { if (c == EOF) { error("Unterminated macro definition\n"); + lexerState->capturing = false; goto finish; } else if (c == '\n') { break; @@ -1905,6 +1908,7 @@ void lexer_CaptureMacroBody(char **capture, size_t *size) } finish: + assert(!lexerState->capturing); *capture = captureStart; *size = lexerState->captureSize - strlen("ENDM"); lexerState->captureBuf = NULL;