From ae5ae6146128780f4cd85bfdbcaddfa15317350c Mon Sep 17 00:00:00 2001 From: Jeremiah Orians Date: Sat, 22 Jan 2022 13:55:09 -0500 Subject: [PATCH] Preserve __M2__ in output --- README | 2 ++ cc.c | 2 +- cc_macro.c | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README b/README index 19e0c5d..a0fac57 100644 --- a/README +++ b/README @@ -14,4 +14,6 @@ M2-Mesoplanet simplifies the bootstrappable stage0/M2-Planet toolchain by imitat - --max-string :: N is a number - --fuzz :: prevents execution of dangerous random garbage - --no-debug :: strip debug symbols from output + - --dirty-mode :: keep all temp files + - --debug-mode :: N is a number diff --git a/cc.c b/cc.c index dc05f68..7e3c432 100644 --- a/cc.c +++ b/cc.c @@ -44,7 +44,7 @@ int main(int argc, char** argv, char** envp) FILE* tempfile; char* destination_name = "a.out"; FILE* destination_file = stdout; - init_macro_env("__M2__", "42", "__INTERNAL_M2__", 0); /* Setup __M2__ */ + init_macro_env("__M2__", "__M2__", "__INTERNAL_M2__", 0); /* Setup __M2__ */ char* name; char* hold; int DUMP_MODE = FALSE; diff --git a/cc_macro.c b/cc_macro.c index f6419cf..e0a988c 100644 --- a/cc_macro.c +++ b/cc_macro.c @@ -86,7 +86,6 @@ void eat_current_token_without_space() struct token_list* lookup_token(struct token_list* token, struct token_list* arguments) { - char *s; if(NULL == token) { fputs("null token received in token\n", stderr); @@ -152,7 +151,7 @@ struct token_list* insert_tokens(struct token_list* point, struct token_list* to struct token_list* copy_list(struct token_list* token) { struct token_list* copy; - struct token_list* prev = NULL; + struct token_list* prev = NULL; while (NULL != token) { @@ -884,6 +883,8 @@ struct token_list* maybe_expand(struct token_list* token) return token->next; } + if(match("__M2__", token->s)) return token->next; + token = eat_token(token); if (NULL == hold->expansion)