From 8d5d586d753687da0b70adacebf7c47071680028 Mon Sep 17 00:00:00 2001 From: Jeremiah Orians Date: Sun, 21 Nov 2021 17:54:39 -0500 Subject: [PATCH] Make -E behavior possible and unique to enable spawning --- cc.c | 25 ++++++++++++++++++------- test/test0000/run_test.sh | 1 + test/test0001/run_test.sh | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/cc.c b/cc.c index 9587d79..8c04eee 100644 --- a/cc.c +++ b/cc.c @@ -42,10 +42,8 @@ int main(int argc, char** argv) FILE* in = stdin; FILE* destination_file = stdout; init_macro_env("__M2__", "42", "__INTERNAL_M2__", 0); /* Setup __M2__ */ - char* arch; char* name; char* hold; - int env=0; int i = 1; while(i <= argc) @@ -54,6 +52,11 @@ int main(int argc, char** argv) { i += 1; } + else if(match(argv[i], "-E") || match(argv[i], "--preprocess-only")) + { + PREPROCESSOR_MODE = TRUE; + i += 1; + } else if(match(argv[i], "-f") || match(argv[i], "--file")) { if(NULL == hold_string) @@ -140,12 +143,20 @@ int main(int argc, char** argv) global_token = remove_line_comments(global_token); preprocess(); - fputs("\n/* Preprocessed source */\n", destination_file); - output_tokens(global_token, destination_file); - - if (destination_file != stdout) + if(PREPROCESSOR_MODE) { - fclose(destination_file); + fputs("\n/* Preprocessed source */\n", destination_file); + output_tokens(global_token, destination_file); + + if (destination_file != stdout) + { + fclose(destination_file); + } + } + else + { + /* Put tempfile and spawning info here */ + output_tokens(global_token, destination_file); } return EXIT_SUCCESS; } diff --git a/test/test0000/run_test.sh b/test/test0000/run_test.sh index be1dde2..db29a52 100755 --- a/test/test0000/run_test.sh +++ b/test/test0000/run_test.sh @@ -24,6 +24,7 @@ mkdir -p ${TMPDIR} # Build the test bin/M2-Mesoplanet \ + -E \ -f test/test0000/return.c \ -o ${TMPDIR}/return.c \ || exit 1 diff --git a/test/test0001/run_test.sh b/test/test0001/run_test.sh index d84dc22..2471803 100755 --- a/test/test0001/run_test.sh +++ b/test/test0001/run_test.sh @@ -24,6 +24,7 @@ mkdir -p ${TMPDIR} # Build the test bin/M2-Mesoplanet \ + -E \ -f test/test0001/return.c \ -o ${TMPDIR}/return.c \ || exit 1