Make -E behavior possible and unique to enable spawning

This commit is contained in:
Jeremiah Orians 2021-11-21 17:54:39 -05:00
parent bb12da2fc9
commit 8d5d586d75
No known key found for this signature in database
GPG Key ID: 6B3A3F198708F894
3 changed files with 20 additions and 7 deletions

25
cc.c
View File

@ -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;
}

View File

@ -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

View File

@ -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