widl [1/2]: Improve file cleanup when errors occur
Dan Hipschman
dsh at linux.ucla.edu
Tue Oct 16 22:19:22 CDT 2007
This patch improves cleanup when errors happen. First off, we were
missing a few files that should be deleted if there are errors (proxy,
typelib, uuid). Second, we could accidentally delete a file even if
we weren't generating it since we were only checking the name. For
example: If there was an error with "widl -C foo -H bar -p x.idl"
widl would delete foo and bar even though we weren't touching those.
---
tools/widl/utils.c | 3 +++
tools/widl/widl.c | 31 +++++++++++++++++--------------
tools/widl/widl.h | 1 +
3 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/tools/widl/utils.c b/tools/widl/utils.c
index 007d1cb..3b8d20e 100644
--- a/tools/widl/utils.c
+++ b/tools/widl/utils.c
@@ -71,6 +71,7 @@ int parser_error(const char *s, ...)
{
va_list ap;
va_start(ap, s);
+ ++nerrors;
generic_msg(s, "Error", parser_text, ap);
va_end(ap);
exit(1);
@@ -90,6 +91,7 @@ void internal_error(const char *file, int line, const char *s, ...)
{
va_list ap;
va_start(ap, s);
+ ++nerrors;
fprintf(stderr, "Internal error (please report) %s %d: ", file, line);
vfprintf(stderr, s, ap);
va_end(ap);
@@ -100,6 +102,7 @@ void error(const char *s, ...)
{
va_list ap;
va_start(ap, s);
+ ++nerrors;
fprintf(stderr, "error: ");
vfprintf(stderr, s, ap);
va_end(ap);
diff --git a/tools/widl/widl.c b/tools/widl/widl.c
index c5e9d40..8b4e397 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -89,6 +89,7 @@ static const char version_string[] = "Wine IDL Compiler version " PACKAGE_VERSIO
int win32 = 1;
int debuglevel = DEBUGLEVEL_NONE;
int parser_debug, yy_flex_debug;
+int nerrors;
int pedantic = 0;
int do_everything = 1;
@@ -403,7 +404,7 @@ int main(int argc,char *argv[])
}
init_types();
- ret = parser_parse();
+ parser_parse();
if(do_header) {
fprintf(header, "/* Begin additional prototypes for all interfaces */\n");
@@ -431,13 +432,7 @@ int main(int argc,char *argv[])
fclose(parser_in);
- if(ret) {
- exit(1);
- }
- header_name = NULL;
- client_name = NULL;
- server_name = NULL;
- idfile_name = NULL;
+ exit(nerrors != 0);
return 0;
}
@@ -446,10 +441,18 @@ static void rm_tempfile(void)
abort_import();
if(temp_name)
unlink(temp_name);
- if (header_name)
- unlink(header_name);
- if (client_name)
- unlink(client_name);
- if (server_name)
- unlink(server_name);
+ if (nerrors) {
+ if (do_header)
+ unlink(header_name);
+ if (do_client)
+ unlink(client_name);
+ if (do_server)
+ unlink(server_name);
+ if (do_idfile)
+ unlink(idfile_name);
+ if (do_proxies)
+ unlink(proxy_name);
+ if (do_typelib)
+ unlink(typelib_name);
+ }
}
diff --git a/tools/widl/widl.h b/tools/widl/widl.h
index a2b905c..497e05a 100644
--- a/tools/widl/widl.h
+++ b/tools/widl/widl.h
@@ -36,6 +36,7 @@ extern int debuglevel;
extern int win32;
extern int pedantic;
+extern int nerrors;
extern int do_everything;
extern int do_header;
extern int do_typelib;
More information about the wine-patches
mailing list