This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: FYI: PR java/21245


I'm checking this in on the trunk.

This fixes PR java/21245.  The bug was that gcjh was creating an
output file even if it ran into an error.  This confuses make, since
on a reinvocation make will see the (erroneous) file and not try to
rebuild it.  One fix is to delete the output file on failure, which is
what this patch implements.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

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

Index: gjavah.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gjavah.c,v
retrieving revision 1.130
diff -u -r1.130 gjavah.c
--- gjavah.c 26 Apr 2005 00:24:00 -0000 1.130
+++ gjavah.c 3 May 2005 19:35:03 -0000
@@ -2387,6 +2387,7 @@
   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 @@
       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 @@
       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;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]