diff lwasm/macro.c @ 524:a4a58c4c7a41

Fix parsing {} macro argument expansion sequences {nn} sequences were consuming one too many characters which caused unpredictable and definitely incorrect behaviour if the {nn} sequence terminated the line. It also caused the next character after the } to be ignored if used in the middle of an argument sequence.
author William Astle <lost@l-w.ca>
date Tue, 25 Jan 2022 21:25:12 -0700
parents 5524649f4784
children 4536f0e61425
line wrap: on
line diff
--- a/lwasm/macro.c	Mon Jan 24 13:55:40 2022 -0700
+++ b/lwasm/macro.c	Tue Jan 25 21:25:12 2022 -0700
@@ -277,8 +277,10 @@
 					n = n * 10 + n2;
 					p2++;
 				}
-				if (*p2 == '}')
-					p2++;
+				// compensate for the autoinc on p2 if no } is present
+				// to prevent overconsuming input characters
+				if (*p2 != '}')
+					p2--;
 				 
 				if (n == 0)
 				{