From f08b186373c23a547c0ef5571dd7862e4dd456b9 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 27 Aug 2002 22:29:26 +0000 Subject: [PATCH] Try to derive temp file names from output file names for better portability. --- tools/widl/parser.l | 2 +- tools/widl/widl.c | 2 +- tools/winebuild/import.c | 23 +++++++++++------------ tools/wpp/wpp.c | 15 +++++++++------ tools/wpp/wpp.h | 2 +- tools/wrc/wrc.c | 2 +- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/tools/widl/parser.l b/tools/widl/parser.l index 2f3e6022aa0..872fd3552c9 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -296,7 +296,7 @@ void do_import(char *fname) import_stack[ptr].temp_name = temp_name; import_stack_ptr++; - ret = wpp_parse_temp( path, &temp_name ); + ret = wpp_parse_temp( path, NULL, &temp_name ); free( path ); if (ret) exit(1); diff --git a/tools/widl/widl.c b/tools/widl/widl.c index 9c26b82b4e0..349d1c79f40 100644 --- a/tools/widl/widl.c +++ b/tools/widl/widl.c @@ -166,7 +166,7 @@ int main(int argc,char *argv[]) if (!preprocess_only) { - ret = wpp_parse_temp( input_name, &temp_name ); + ret = wpp_parse_temp( input_name, header_name, &temp_name ); } else { diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 282af81aae4..5fd70c6eef4 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -47,7 +47,6 @@ struct import int nb_exports; /* number of exported functions */ struct func *imports; /* functions we want to import from this dll */ int nb_imports; /* number of imported functions */ - int lineno; /* line in .spec file where import is defined */ }; static char **undef_symbols; /* list of undefined symbols */ @@ -58,7 +57,7 @@ static char **ignore_symbols; /* list of symbols to ignore */ static int nb_ignore_symbols; static int ignore_size; -static const char *ld_tmp_file; /* ld temp file name */ +static char *ld_tmp_file; /* ld temp file name */ static struct import **dll_imports = NULL; static int nb_imports = 0; /* number of imported dlls (delayed or not) */ @@ -232,8 +231,6 @@ void add_import_dll( const char *name, int delay ) imp->delay = delay; imp->imports = NULL; imp->nb_imports = 0; - /* GetToken for the file name has swallowed the '\n', hence pointing to next line */ - imp->lineno = current_line - 1; if (delay) nb_delayed++; read_exported_symbols( fullname, imp ); @@ -376,7 +373,7 @@ static void add_extra_undef_symbols(void) /* warn if a given dll is not used, but check forwards first */ static void warn_unused( const struct import* imp ) { - int i, curline; + int i; size_t len = strlen(imp->dll); const char *p = strchr( imp->dll, '.' ); if (p && !strcasecmp( p, ".dll" )) len = p - imp->dll; @@ -389,11 +386,7 @@ static void warn_unused( const struct import* imp ) odp->link_name[len] == '.') return; /* found an import, do not warn */ } - /* switch current_line temporarily to the line of the import declaration */ - curline = current_line; - current_line = imp->lineno; warning( "%s imported but no symbols used\n", imp->dll ); - current_line = curline; } /* combine a list of object files with ld into a single object file */ @@ -403,11 +396,17 @@ static const char *ldcombine_files( char **argv ) int i, len = 0; char *cmd; int fd, err; - char buffer[] = "/tmp/winebuild.tmp.XXXXXX"; - if ((fd = mkstemp( buffer ) == -1)) fatal_error( "could not generate a temp file\n" ); + if (output_file_name && output_file_name[0]) + { + ld_tmp_file = xmalloc( strlen(output_file_name) + 8 ); + strcpy( ld_tmp_file, output_file_name ); + strcat( ld_tmp_file, ".XXXXXX" ); + } + else ld_tmp_file = xstrdup( "/tmp/winebuild.tmp.XXXXXX" ); + + if ((fd = mkstemp( ld_tmp_file ) == -1)) fatal_error( "could not generate a temp file\n" ); close( fd ); - ld_tmp_file = xstrdup( buffer ); atexit( remove_ld_tmp_file ); for (i = 0; argv[i]; i++) len += strlen(argv[i]) + 1; diff --git a/tools/wpp/wpp.c b/tools/wpp/wpp.c index 6d9ef5a678d..d4b5465a71f 100644 --- a/tools/wpp/wpp.c +++ b/tools/wpp/wpp.c @@ -110,20 +110,23 @@ int wpp_parse( const char *input, FILE *output ) /* parse into a temporary file */ -int wpp_parse_temp( const char *input, char **output_name ) +int wpp_parse_temp( const char *input, const char *output_base, char **output_name ) { FILE *output; int ret, fd; - char tmpfn[20], *temp_name; + char *temp_name; - strcpy(tmpfn,"/tmp/wpp.XXXXXX"); + if (!output_base || !output_base[0]) output_base = "wpptmp"; - if((fd = mkstemp(tmpfn)) == -1) + temp_name = pp_xmalloc( strlen(output_base) + 8 ); + strcpy( temp_name, output_base ); + strcat( temp_name, ".XXXXXX" ); + + if((fd = mkstemp( temp_name )) == -1) { - fprintf(stderr, "Could not generate a temp-name\n"); + fprintf(stderr, "Could not generate a temp name from %s\n", temp_name); exit(2); } - temp_name = pp_xstrdup(tmpfn); if (!(output = fdopen(fd, "wt"))) { diff --git a/tools/wpp/wpp.h b/tools/wpp/wpp.h index 1815ad6a467..79abf72eeec 100644 --- a/tools/wpp/wpp.h +++ b/tools/wpp/wpp.h @@ -30,6 +30,6 @@ extern void wpp_set_pedantic( int on ); extern void wpp_add_include_path( const char *path ); extern char *wpp_find_include( const char *name, int search ); extern int wpp_parse( const char *input, FILE *output ); -extern int wpp_parse_temp( const char *input, char **output_name ); +extern int wpp_parse_temp( const char *input, const char *output_base, char **output_name ); #endif /* __WINE_WPP_H */ diff --git a/tools/wrc/wrc.c b/tools/wrc/wrc.c index de3a0ccc6ad..f41272777a0 100644 --- a/tools/wrc/wrc.c +++ b/tools/wrc/wrc.c @@ -627,7 +627,7 @@ int main(int argc,char *argv[]) if (!preprocess_only) { atexit(rm_tempfile); - ret = wpp_parse_temp( input_name, &temp_name ); + ret = wpp_parse_temp( input_name, output_name, &temp_name ); } else if (output_name) {