shithub: rgbds

Download patch

ref: a52a00a9ca7753ef41814b55878b510e8dc80b7b
parent: fa13611bbf6a1db1a439d9ba4ec9e6e8bb4f9f7c
author: Rangi <[email protected]>
date: Tue Aug 30 12:50:34 EDT 2022

`macro_UndefUniqueID` uses 0 to mean `\@` is undefined

--- a/include/asm/macro.h
+++ b/include/asm/macro.h
@@ -31,6 +31,7 @@
 char const *macro_GetUniqueIDStr(void);
 void macro_SetUniqueID(uint32_t id);
 uint32_t macro_UseNewUniqueID(void);
+uint32_t macro_UndefUniqueID(void);
 void macro_ShiftCurrentArgs(int32_t count);
 uint32_t macro_NbArgs(void);
 
--- a/src/asm/fstack.c
+++ b/src/asm/fstack.c
@@ -336,8 +336,7 @@
 		fatalerror("Failed to set up lexer for file include\n");
 	lexer_SetStateAtEOL(contextStack->lexerState);
 	// We're back at top-level, so most things are reset
-	contextStack->uniqueID = 0;
-	macro_SetUniqueID(0);
+	contextStack->uniqueID = macro_UndefUniqueID();
 }
 
 void fstk_RunMacro(char const *macroName, struct MacroArgs *args)
@@ -539,8 +538,7 @@
 
 	context->parent = NULL;
 	context->lexerState = state;
-	context->uniqueID = 0;
-	macro_SetUniqueID(0);
+	context->uniqueID = macro_UndefUniqueID();
 	context->nbReptIters = 0;
 	context->forValue = 0;
 	context->forStep = 0;
--- a/src/asm/macro.c
+++ b/src/asm/macro.c
@@ -166,7 +166,13 @@
 uint32_t macro_UseNewUniqueID(void)
 {
 	macro_SetUniqueID(++maxUniqueID);
-	return maxUniqueID;
+	return uniqueID;
+}
+
+uint32_t macro_UndefUniqueID(void)
+{
+	macro_SetUniqueID(0);
+	return uniqueID;
 }
 
 void macro_ShiftCurrentArgs(int32_t count)