Commit a67aa338 by Tom Tromey Committed by Tom Tromey

re PR java/21245 (gcjh creates invalid/empty header files)

	PR java/21245:
	* gjavah.c (main): Unlink output file on error.

From-SVN: r99182
parent 78d27a06
2005-05-03 Tom Tromey <tromey@redhat.com>
PR java/21245:
* gjavah.c (main): Unlink output file on error.
2005-05-03 Kazu Hirata <kazu@cs.umass.edu> 2005-05-03 Kazu Hirata <kazu@cs.umass.edu>
* constants.c, jvgenmain.c, lang.opt, resource.c: Update * constants.c, jvgenmain.c, lang.opt, resource.c: Update
......
...@@ -2387,6 +2387,7 @@ main (int argc, char** argv) ...@@ -2387,6 +2387,7 @@ main (int argc, char** argv)
char *output_file = NULL; char *output_file = NULL;
int emit_dependencies = 0, suppress_output = 0; int emit_dependencies = 0, suppress_output = 0;
int opt; int opt;
int local_found_error;
/* Unlock the stdio streams. */ /* Unlock the stdio streams. */
unlock_std_streams (); unlock_std_streams ();
...@@ -2521,12 +2522,18 @@ main (int argc, char** argv) ...@@ -2521,12 +2522,18 @@ main (int argc, char** argv)
exit (1); exit (1);
} }
local_found_error = 0;
for (argi = optind; argi < argc; argi++) for (argi = optind; argi < argc; argi++)
{ {
char *classname = argv[argi]; char *classname = argv[argi];
char *current_output_file; char *current_output_file = NULL;
const char *classfile_name; 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) if (verbose)
printf (_("Processing %s\n"), classname); printf (_("Processing %s\n"), classname);
if (! output_file) if (! output_file)
...@@ -2602,13 +2609,22 @@ main (int argc, char** argv) ...@@ -2602,13 +2609,22 @@ main (int argc, char** argv)
free_method_name_list (); free_method_name_list ();
process_file (&jcf, out); process_file (&jcf, out);
JCF_FINISH (&jcf); 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) if (current_output_file != output_file)
free (current_output_file); free (current_output_file);
jcf_dependency_write (); jcf_dependency_write ();
local_found_error |= found_error;
} }
if (out != NULL && out != stdout) if (out != NULL && out != stdout)
fclose (out); fclose (out);
return found_error; return local_found_error;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment