From 141bc9e49a9b0f2798e6c2feaf7a9d893d8764d8 Mon Sep 17 00:00:00 2001 From: pommicket Date: Sun, 9 Jan 2022 17:48:51 -0500 Subject: corrected fmacro rescanning --- 05/main.c | 16 ++++++++++++++-- 05/preprocess.b | 7 ++++--- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to '05') diff --git a/05/main.c b/05/main.c index 90f5b79..058573f 100644 --- a/05/main.c +++ b/05/main.c @@ -1,4 +1,16 @@ -#define TEST(x,y,z) x##y#z -TEST(22,4594,hello there folks) +#define STRINGIFY2(x) #x +#define STRINGIFY(x) STRINGIFY2(x) +#define X 22 +STRINGIFY(X) + + +#define E 5 +#define D E +#define C D +#define B C +#define A B + +int x = E; + main(void) { } diff --git a/05/preprocess.b b/05/preprocess.b index 9c66631..d932161 100644 --- a/05/preprocess.b +++ b/05/preprocess.b @@ -777,10 +777,11 @@ function macro_replacement goto done_replacement :fmacro_argument - ; write argument to *fmacro_out + ; write argument to *fmacro_out, performing any necessary macro substitutions q = fmacro_get_arg(filename, line_number, arguments, *1p) - fmacro_out = memccpy(fmacro_out, q, 255) - *1fmacro_out = 0 + :fmacro_arg_replace_loop + macro_replacement(filename, line_number, &q, &fmacro_out) + if *1q != 255 goto fmacro_arg_replace_loop p += 2 ; skip arg idx & null separator goto freplace_loop -- cgit v1.2.3