Alexandre Julliard : wrc: Move temp file management from wpp directly into the load_file function.
Alexandre Julliard
julliard at winehq.org
Tue Mar 30 10:39:46 CDT 2010
Module: wine
Branch: master
Commit: cb9be96437a82639e61b712721bf89ec6b62a2df
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cb9be96437a82639e61b712721bf89ec6b62a2df
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Mar 30 15:33:54 2010 +0200
wrc: Move temp file management from wpp directly into the load_file function.
---
tools/wrc/wrc.c | 52 +++++++++++++++++++++++++++++++---------------------
1 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/tools/wrc/wrc.c b/tools/wrc/wrc.c
index 931af46..2919d38 100644
--- a/tools/wrc/wrc.c
+++ b/tools/wrc/wrc.c
@@ -256,40 +256,50 @@ static int load_file( const char *input_name, const char *output_name )
/* Run the preprocessor on the input */
if(!no_preprocess)
{
+ FILE *output;
+ int ret, fd;
+ char *name;
+
/*
* Preprocess the input to a temp-file, or stdout if
* no output was given.
*/
- chat("Starting preprocess\n");
-
- if (!preprocess_only)
- {
- ret = wpp_parse_temp( input_name, output_name, &temp_name );
- }
- else if (output_name)
+ if (preprocess_only)
{
- 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" )))
- fatal_perror( "Could not open %s for writing", output_name );
- ret = wpp_parse( input_name, output );
- fclose( output );
+ if (ret) return ret;
+ output_name = NULL;
+ exit(0);
}
- 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)
- {
- output_name = NULL;
- exit(0);
- }
+ temp_name = name;
+ if (!(output = fdopen(fd, "wt")))
+ error("Could not open fd %s for writing\n", name);
- input_name = temp_name;
+ ret = wpp_parse( input_name, output );
+ fclose( output );
+ if (ret) return ret;
+ input_name = name;
}
/* Reset the language */
More information about the wine-cvs
mailing list