gcj/89 patch: emit dependencies in preferred order

Anthony Green green@cygnus.com
Sun Feb 13 11:46:00 GMT 2000


This patch fixes PR gcj/89.  It changes `gcj -M' to emit dependencies
in the preferred order.

http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&database=java&pr=89


2000-02-13  Anthony Green  <green@cygnus.com>

        * jcf-depend.c (add_entry): Add entries to the end of the list.

Index: gcc/java/jcf-depend.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/jcf-depend.c,v
retrieving revision 1.7
diff -u -r1.7 jcf-depend.c
--- jcf-depend.c	2000/01/21 20:57:00	1.7
+++ jcf-depend.c	2000/02/13 19:40:11
@@ -78,22 +78,30 @@
   *entp = NULL;
 }
 
-/* Helper to add to entry list.  */
+/* Helper to add to the end of the entry list.  */
 static void
 add_entry (entp, name)
      struct entry **entp;
      const char *name;
 {
-  struct entry *ent;
+  struct entry *ent, *last;
 
-  for (ent = *entp; ent != NULL; ent = ent->next)
+  for (last = ent = *entp; ent != NULL; last = ent, ent = ent->next)
     if (! strcmp (ent->file, name))
       return;
 
   ent = (struct entry *) xmalloc (sizeof (struct entry));
   ent->file = xstrdup (name);
-  ent->next = *entp;
-  *entp = ent;
+  ent->next = NULL;
+
+  if (last == NULL)
+    {
+      // This is only true the first time through, when the entry list
+      // is empty.
+      *entp = ent;
+    }     
+  else
+    last->next = ent;
 }
 
 /* Call this to reset the dependency module.  This is required if

-- 
Anthony Green                                                        Red Hat
                                                       Sunnyvale, California


More information about the Gcc-patches mailing list