ref: 4d1333e124369a63f69ee9ef4bc94bd6073f9b41
parent: 35396e6410e471626db52c917f405fcf65034373
author: ISSOtm <eldredhabert0@gmail.com>
date: Mon Aug 17 08:00:28 EDT 2020
Fix incorrect error reporting of `INCLUDE`d files
--- a/src/asm/fstack.c
+++ b/src/asm/fstack.c
@@ -33,6 +33,7 @@
struct LexerState *lexerState;
uint32_t uniqueID;
char const *fileName;
+ char *fileNameBuf;
uint32_t lineNo; /* Line number at which the context was EXITED */
struct Symbol const *macro;
uint32_t nbReptIters; /* If zero, this isn't a REPT block */
@@ -153,6 +154,10 @@
}
dbgPrint("Popping context\n");
+ /* Free an `INCLUDE`'s path */
+ if (contextStack->fileNameBuf)
+ free(contextStack->fileNameBuf);
+
contextStack = contextStack->parent;
contextDepth--;
@@ -206,7 +211,8 @@
/* We're back at top-level, so most things are reset */
contextStack->uniqueID = 0;
macro_SetUniqueID(0);
- contextStack->fileName = lexer_GetFileName();
+ contextStack->fileName = fullPath;
+ contextStack->fileNameBuf = fullPath;
contextStack->macro = NULL;
contextStack->nbReptIters = 0;
}
@@ -236,6 +242,7 @@
lexer_SetStateAtEOL(contextStack->lexerState);
contextStack->uniqueID = macro_UseNewUniqueID();
contextStack->fileName = macro->fileName;
+ contextStack->fileNameBuf = NULL;
contextStack->macro = macro;
contextStack->nbReptIters = 0;
}
@@ -253,6 +260,7 @@
lexer_SetStateAtEOL(contextStack->lexerState);
contextStack->uniqueID = macro_UseNewUniqueID();
contextStack->fileName = contextStack->parent->fileName;
+ contextStack->fileNameBuf = NULL;
contextStack->macro = contextStack->parent->macro; /* Inherit */
contextStack->nbReptIters = count;
/* Copy all of parent's iters, and add ours */
@@ -354,6 +362,7 @@
topLevelContext->uniqueID = 0;
macro_SetUniqueID(0);
topLevelContext->fileName = lexer_GetFileName();
+ topLevelContext->fileNameBuf = NULL;
topLevelContext->macro = NULL;
topLevelContext->nbReptIters = 0;
topLevelContext->reptDepth = 0;