Do not expand empty strings

Fixes #813
This commit is contained in:
Rangi
2021-03-31 10:21:04 -04:00
parent 49aac2961d
commit c7ed9a275e
5 changed files with 16 additions and 0 deletions

View File

@@ -751,6 +751,10 @@ static void beginExpansion(size_t distance, uint8_t skip,
char const *str, size_t size, bool owned, char const *str, size_t size, bool owned,
char const *name) char const *name)
{ {
/* Do not expand empty strings */
if (!size)
return;
distance += lexerState->expansionOfs; /* Distance argument is relative to read offset! */ distance += lexerState->expansionOfs; /* Distance argument is relative to read offset! */
/* Increase the total length of all parents, and return the topmost one */ /* Increase the total length of all parents, and return the topmost one */
struct Expansion *parent = NULL; struct Expansion *parent = NULL;

View File

@@ -0,0 +1,6 @@
test: MACRO
v equs "X"
X equs "" ; should not be expanded
\1
ENDM
test v 0

View File

@@ -0,0 +1,3 @@
ERROR: expand-empty-string.asm(6) -> expand-empty-string.asm::test(4):
syntax error, unexpected number
error: Assembly aborted (1 error)!

View File

View File

@@ -0,0 +1,3 @@
ERROR: expand-empty-string.asm(6) -> expand-empty-string.asm::test(4):
syntax error
error: Assembly aborted (1 error)!