Module Name:    src
Committed By:   sjg
Date:           Sat May 18 13:12:45 UTC 2013

Modified Files:
        src/usr.bin/make: var.c

Log Message:
Var_Delete: expand name if needed.


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.173 src/usr.bin/make/var.c:1.174
--- src/usr.bin/make/var.c:1.173	Sun Feb 24 19:43:37 2013
+++ src/usr.bin/make/var.c	Sat May 18 13:12:45 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.173 2013/02/24 19:43:37 christos Exp $	*/
+/*	$NetBSD: var.c,v 1.174 2013/05/18 13:12:45 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.173 2013/02/24 19:43:37 christos Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.174 2013/05/18 13:12:45 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.173 2013/02/24 19:43:37 christos Exp $");
+__RCSID("$NetBSD: var.c,v 1.174 2013/05/18 13:12:45 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -529,11 +529,20 @@ void
 Var_Delete(const char *name, GNode *ctxt)
 {
     Hash_Entry 	  *ln;
-
-    ln = Hash_FindEntry(&ctxt->context, name);
+    char *cp;
+    
+    if (strchr(name, '$')) {
+	cp = Var_Subst(NULL, name, VAR_GLOBAL, 0);
+    } else {
+	cp = (char *)name;
+    }
+    ln = Hash_FindEntry(&ctxt->context, cp);
     if (DEBUG(VAR)) {
 	fprintf(debug_file, "%s:delete %s%s\n",
-	    ctxt->name, name, ln ? "" : " (not found)");
+	    ctxt->name, cp, ln ? "" : " (not found)");
+    }
+    if (cp != name) {
+	free(cp);
     }
     if (ln != NULL) {
 	Var 	  *v;

Reply via email to