Minor fix and code rework.
authorBoris Kolpackov <boris@kolpackov.net>
Wed, 7 Oct 2009 09:34:42 +0000 (09:34 +0000)
committerBoris Kolpackov <boris@kolpackov.net>
Wed, 7 Oct 2009 09:34:42 +0000 (09:34 +0000)
ChangeLog
commands.c
read.c

index 49375217616389291d348cd372fd4573e7504cd4..351953836825578b5ac6d5bcb0583262e96f282e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-10-07  Boris Kolpackov  <boris@codesynthesis.com>
+
+       * read.c (do_undefine): Free the expanded variable name.
+
+       * commands.c (dep_hash_cmp, set_file_variables): Move the order-only
+       to normal upgrade logic from  dep_hash_cmp to set_file_variables.
+
 2009-10-06  Boris Kolpackov  <boris@codesynthesis.com>
 
        * dep.h (uniquize_deps): Remove.
index 8a7bb6c423d989b57376fd8174e845239f595704..19cb7b4a8d1b8895ce480a2c6410e6a30f4ed4e1 100644 (file)
@@ -57,16 +57,7 @@ dep_hash_cmp (const void *x, const void *y)
 {
   struct dep *dx = (struct dep *) x;
   struct dep *dy = (struct dep *) y;
-  int cmp = strcmp (dep_name (dx), dep_name (dy));
-
-  /* If the names are the same but ignore_mtimes are not equal, one of these
-     is an order-only prerequisite and one isn't.  That means that we should
-     remove the one that isn't and keep the one that is.  */
-
-  if (!cmp && dx->ignore_mtime != dy->ignore_mtime)
-    dx->ignore_mtime = dy->ignore_mtime = 0;
-
-  return cmp;
+  return strcmp (dep_name (dx), dep_name (dy));
 }
 
 /* Set FILE's automatic variables up.  */
@@ -74,7 +65,7 @@ dep_hash_cmp (const void *x, const void *y)
 void
 set_file_variables (struct file *file)
 {
-  const struct dep *d;
+  struct dep *d;
   const char *at, *percent, *star, *less;
 
 #ifndef        NO_ARCHIVES
@@ -252,7 +243,7 @@ set_file_variables (struct file *file)
     /* Make sure that no dependencies are repeated in $^, $?, and $|.  It
        would be natural to combine the next two loops but we can't do it
        because of a situation where we have two dep entries, the first
-       is order-only and the second is normal (see dep_hash_cmp).  */
+       is order-only and the second is normal (see below).  */
 
     hash_init (&dep_hash, 500, dep_hash_1, dep_hash_2, dep_hash_cmp);
 
@@ -264,6 +255,16 @@ set_file_variables (struct file *file)
         slot = hash_find_slot (&dep_hash, d);
         if (HASH_VACANT (*slot))
           hash_insert_at (&dep_hash, d, slot);
+        else
+          {
+            /* Check if the two prerequisites have different ignore_mtime.
+               If so then we need to "upgrade" one that is order-only.  */
+
+            struct dep* hd = (struct dep*) *slot;
+
+            if (d->ignore_mtime != hd->ignore_mtime)
+              d->ignore_mtime = hd->ignore_mtime = 0;
+          }
       }
 
     for (d = file->deps; d != 0; d = d->next)
diff --git a/read.c b/read.c
index 3a022d6cc356d75d9cdd0d706ffad0186235dabb..aa27701dd4bf27acde15a6703dbe7bf35e9a79da 100644 (file)
--- a/read.c
+++ b/read.c
@@ -1341,6 +1341,7 @@ do_undefine (char *name, enum variable_origin origin, struct ebuffer *ebuf)
   p[1] = '\0';
 
   undefine_variable_global (name, p - name + 1, origin);
+  free (var);
 }
 
 /* Execute a `define' directive.