aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/gjavah.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2005-05-03 20:51:30 +0000
committerTom Tromey <tromey@gcc.gnu.org>2005-05-03 20:51:30 +0000
commita67aa338b6d94b54e36b310cdcc31465841ea9cb (patch)
treeff17c37a6bfbab73aa5bd203a5ad7f6176e056a5 /gcc/java/gjavah.c
parent78d27a0690ddc873d2dfab6e7223a3d53c4ad6e2 (diff)
downloadgcc-a67aa338b6d94b54e36b310cdcc31465841ea9cb.zip
gcc-a67aa338b6d94b54e36b310cdcc31465841ea9cb.tar.gz
gcc-a67aa338b6d94b54e36b310cdcc31465841ea9cb.tar.bz2
re PR java/21245 (gcjh creates invalid/empty header files)
PR java/21245: * gjavah.c (main): Unlink output file on error. From-SVN: r99182
Diffstat (limited to 'gcc/java/gjavah.c')
-rw-r--r--gcc/java/gjavah.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/gcc/java/gjavah.c b/gcc/java/gjavah.c
index f8ae732..5606f25 100644
--- a/gcc/java/gjavah.c
+++ b/gcc/java/gjavah.c
@@ -2387,6 +2387,7 @@ main (int argc, char** argv)
char *output_file = NULL;
int emit_dependencies = 0, suppress_output = 0;
int opt;
+ int local_found_error;
/* Unlock the stdio streams. */
unlock_std_streams ();
@@ -2521,12 +2522,18 @@ main (int argc, char** argv)
exit (1);
}
+ local_found_error = 0;
for (argi = optind; argi < argc; argi++)
{
char *classname = argv[argi];
- char *current_output_file;
+ char *current_output_file = NULL;
const char *classfile_name;
+ /* We reset the error state here so that we can detect errors
+ that occur when processing this file, so the output can be
+ unlinked if need be. */
+ found_error = 0;
+
if (verbose)
printf (_("Processing %s\n"), classname);
if (! output_file)
@@ -2602,13 +2609,22 @@ main (int argc, char** argv)
free_method_name_list ();
process_file (&jcf, out);
JCF_FINISH (&jcf);
+
+ /* If we found an error and we're writing to a real file,
+ delete it. */
+ if (found_error && ! suppress_output && current_output_file != NULL
+ && strcmp (current_output_file, "-"))
+ unlink (current_output_file);
+
if (current_output_file != output_file)
free (current_output_file);
jcf_dependency_write ();
+
+ local_found_error |= found_error;
}
if (out != NULL && out != stdout)
fclose (out);
- return found_error;
+ return local_found_error;
}