changeset 529:428039e88a0b

Fix macro definition to include all lines This may cause problems if anyone is doing "clever" things with conditionals and the like. However, it does fix the problem that lines without opcodes on them weren't being included in the macros definition. This needs to percolate for a while before being released.
author William Astle <lost@l-w.ca>
date Wed, 09 Feb 2022 21:44:28 -0700
parents 4536f0e61425
children 65c2085e0398
files lwasm/pass1.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/pass1.c	Sun Jan 30 14:13:34 2022 -0700
+++ b/lwasm/pass1.c	Wed Feb 09 21:44:28 2022 -0700
@@ -67,6 +67,7 @@
 	int opnum;
 	int lc = 1;
 	int nomacro;
+	int wasmacro;
 	
 	for (;;)
 	{
@@ -109,6 +110,7 @@
 		}
 		debug_message(as, 75, "Read line: %s", line);
 		
+		wasmacro = as -> inmacro;
 		cl = lw_alloc(sizeof(line_t));
 		memset(cl, 0, sizeof(line_t));
 		cl -> outputl = -1;
@@ -312,7 +314,6 @@
 			// add the line to the macro definition and continue
 			if (as -> inmacro && !(instab[opnum].flags & lwasm_insn_endm))
 			{
-				add_macro_line(as, line);
 				goto linedone;
 			}
 			
@@ -420,6 +421,8 @@
 		}
 	
 	linedone:
+		if (as -> inmacro && wasmacro)
+			add_macro_line(as, line);
 		if (!as -> skipcond && !as -> inmacro)
 		{
 			if (cl -> sym && cl -> symset == 0)