changeset 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 1744f2d1a821
children 28633fd513c4
files lwasm/macro.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
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)
 				{