changeset 528:4536f0e61425

Add \# macro expansion which expands to the number of arguments It seems useful to have a number of arguments in some macros. Add \# expansion tag which turns into the number of arguments.
author William Astle <lost@l-w.ca>
date Sun, 30 Jan 2022 14:13:34 -0700
parents 2c4d11da2afe
children 428039e88a0b
files lwasm/macro.c
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/macro.c	Sun Jan 30 14:12:40 2022 -0700
+++ b/lwasm/macro.c	Sun Jan 30 14:13:34 2022 -0700
@@ -247,6 +247,14 @@
 				}
 				p2++;
 			}
+			else if (*p2 == '\\' && p2[1] == '#')
+			{
+				char ctcbuf[25];
+				snprintf(ctcbuf, 25, "%d", nargs);
+				for (p3 = ctcbuf; *p3; p3++)
+					macro_add_to_buff(&linebuff, &bloc, &blen, *p3);
+				p2++;
+			}
 			else if (*p2 == '\\' && isdigit(p2[1]))
 			{
 				int n;