diff options
-rw-r--r-- | 05/main.c | 16 | ||||
-rw-r--r-- | 05/preprocess.b | 7 |
2 files changed, 18 insertions, 5 deletions
@@ -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 |