Commit cb9be964 authored by Alexandre Julliard's avatar Alexandre Julliard

wrc: Move temp file management from wpp directly into the load_file function.

parent 74ad854e
...@@ -256,40 +256,50 @@ static int load_file( const char *input_name, const char *output_name ) ...@@ -256,40 +256,50 @@ static int load_file( const char *input_name, const char *output_name )
/* Run the preprocessor on the input */ /* Run the preprocessor on the input */
if(!no_preprocess) if(!no_preprocess)
{ {
FILE *output;
int ret, fd;
char *name;
/* /*
* Preprocess the input to a temp-file, or stdout if * Preprocess the input to a temp-file, or stdout if
* no output was given. * no output was given.
*/ */
chat("Starting preprocess\n"); if (preprocess_only)
if (!preprocess_only)
{
ret = wpp_parse_temp( input_name, output_name, &temp_name );
}
else if (output_name)
{ {
FILE *output; if (output_name)
{
if (!(output = fopen( output_name, "w" )))
fatal_perror( "Could not open %s for writing", output_name );
ret = wpp_parse( input_name, output );
fclose( output );
}
else ret = wpp_parse( input_name, stdout );
if (!(output = fopen( output_name, "w" ))) if (ret) return ret;
fatal_perror( "Could not open %s for writing", output_name ); output_name = NULL;
ret = wpp_parse( input_name, output ); exit(0);
fclose( output );
} }
else
if (output_name && output_name[0])
{ {
ret = wpp_parse( input_name, stdout ); name = xmalloc( strlen(output_name) + 8 );
strcpy( name, output_name );
strcat( name, ".XXXXXX" );
} }
else name = xstrdup( "wrc.XXXXXX" );
if (ret) return ret; if ((fd = mkstemps( name, 0 )) == -1)
error("Could not generate a temp name from %s\n", name);
if(preprocess_only) temp_name = name;
{ if (!(output = fdopen(fd, "wt")))
output_name = NULL; error("Could not open fd %s for writing\n", name);
exit(0);
}
input_name = temp_name; ret = wpp_parse( input_name, output );
fclose( output );
if (ret) return ret;
input_name = name;
} }
/* Reset the language */ /* Reset the language */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment