Alexandre Julliard : widl: Move temp file management from wpp to widl.
Alexandre Julliard
julliard at winehq.org
Tue Mar 30 10:39:46 CDT 2010
Module: wine
Branch: master
Commit: 4d55592540c7cd1e8f6e0e449402930fbf6d38fb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4d55592540c7cd1e8f6e0e449402930fbf6d38fb
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Mar 30 15:34:12 2010 +0200
widl: Move temp file management from wpp to widl.
---
tools/widl/parser.l | 18 ++++++++++++++----
tools/widl/widl.c | 17 ++++++++++++++++-
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/tools/widl/parser.l b/tools/widl/parser.l
index 5db9560..e7673d1 100644
--- a/tools/widl/parser.l
+++ b/tools/widl/parser.l
@@ -42,6 +42,7 @@ double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)*
%{
#include "config.h"
+#include "wine/port.h"
#include <stdio.h>
#include <stdlib.h>
@@ -442,10 +443,10 @@ struct imports {
int do_import(char *fname)
{
FILE *f;
- char *path;
+ char *path, *name;
struct imports *import;
int ptr = import_stack_ptr;
- int ret;
+ int ret, fd;
import = first_import;
while (import && strcmp(import->name, fname))
@@ -460,7 +461,7 @@ int do_import(char *fname)
/* don't search for a file name with a path in the include directories,
* for compatibility with MIDL */
if (strchr( fname, '/' ) || strchr( fname, '\\' ))
- path = strdup( fname );
+ path = xstrdup( fname );
else if (!(path = wpp_find_include( fname, input_name )))
error_loc("Unable to open include file %s\n", fname);
@@ -471,7 +472,16 @@ int do_import(char *fname)
input_name = path;
line_number = 1;
- ret = wpp_parse_temp( path, NULL, &temp_name );
+ name = xstrdup( "widl.XXXXXX" );
+ if((fd = mkstemps( name, 0 )) == -1)
+ error("Could not generate a temp name from %s\n", name);
+
+ temp_name = name;
+ if (!(f = fdopen(fd, "wt")))
+ error("Could not open fd %s for writing\n", name);
+
+ ret = wpp_parse( path, f );
+ fclose( f );
if (ret) exit(1);
if((f = fopen(temp_name, "r")) == NULL)
diff --git a/tools/widl/widl.c b/tools/widl/widl.c
index 8c76c24..8c0d0c9 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -701,7 +701,22 @@ int main(int argc,char *argv[])
if (!preprocess_only)
{
- ret = wpp_parse_temp( input_name, header_name, &temp_name );
+ FILE *output;
+ int fd;
+ char *name = xmalloc( strlen(header_name) + 8 );
+
+ strcpy( name, header_name );
+ strcat( name, ".XXXXXX" );
+
+ if ((fd = mkstemps( name, 0 )) == -1)
+ error("Could not generate a temp name from %s\n", name);
+
+ temp_name = name;
+ if (!(output = fdopen(fd, "wt")))
+ error("Could not open fd %s for writing\n", name);
+
+ ret = wpp_parse( input_name, output );
+ fclose( output );
}
else
{
More information about the wine-cvs
mailing list