Don't dump binary data to stdout

This commit is contained in:
Jeremiah Orians 2021-11-23 06:48:52 -05:00
parent 295b323996
commit 7d4c9dcabb
No known key found for this signature in database
GPG Key ID: 6B3A3F198708F894
2 changed files with 26 additions and 15 deletions

8
cc.c
View File

@ -46,7 +46,7 @@ int main(int argc, char** argv, char** envp)
int debug_flag = TRUE;
FILE* in = stdin;
FILE* tempfile;
char* destination_name = "/dev/stdout";
char* destination_name = "a.out";
FILE* destination_file = stdout;
init_macro_env("__M2__", "42", "__INTERNAL_M2__", 0); /* Setup __M2__ */
char* name;
@ -174,11 +174,7 @@ int main(int argc, char** argv, char** envp)
{
fputs("\n/* Preprocessed source */\n", destination_file);
output_tokens(global_token, destination_file);
if (destination_file != stdout)
{
fclose(destination_file);
}
fclose(destination_file);
}
else
{

View File

@ -653,17 +653,32 @@ void macro_directive()
{
handle_error();
}
else if(match("#include", macro_token->s))
{
eat_current_token();
if(match("<", macro_token->s))
{
eat_current_token();
if(match("stdio", macro_token->s))
{
eat_current_token();
STDIO_USED = TRUE;
}
eat_current_token();
eat_current_token();
eat_current_token();
}
else
eat_current_token();
}
else
{
if(!match("#include", macro_token->s))
{
/* Put a big fat warning but see if we can just ignore */
fputs(">>WARNING<<\n>>WARNING<<\n", stderr);
line_error_token(macro_token);
fputs("feature: ", stderr);
fputs(macro_token->s, stderr);
fputs(" unsupported in M2-Planet\nIgnoring line, may result in bugs\n>>WARNING<<\n>>WARNING<<\n\n", stderr);
}
/* Put a big fat warning but see if we can just ignore */
fputs(">>WARNING<<\n>>WARNING<<\n", stderr);
line_error_token(macro_token);
fputs("feature: ", stderr);
fputs(macro_token->s, stderr);
fputs(" unsupported in M2-Planet\nIgnoring line, may result in bugs\n>>WARNING<<\n>>WARNING<<\n\n", stderr);
/* unhandled macro directive; let's eat until a newline; om nom nom */
while(TRUE)