Module Name:    src
Committed By:   rillig
Date:           Tue Sep 22 06:23:33 UTC 2020

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

Log Message:
make(1): remove remaining references to VAR_JUNK and VAR_KEEP


To generate a diff of this commit:
cvs rdiff -u -r1.527 -r1.528 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.527 src/usr.bin/make/var.c:1.528
--- src/usr.bin/make/var.c:1.527	Tue Sep 22 06:13:38 2020
+++ src/usr.bin/make/var.c	Tue Sep 22 06:23:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.527 2020/09/22 06:13:38 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.528 2020/09/22 06:23:33 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include    "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.527 2020/09/22 06:13:38 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.528 2020/09/22 06:23:33 rillig Exp $");
 
 #define VAR_DEBUG_IF(cond, fmt, ...)	\
     if (!(DEBUG(VAR) && (cond)))	\
@@ -1880,8 +1880,8 @@ VarStrftime(const char *fmt, Boolean zul
  *
  * Housekeeping
  *
- * Some modifiers such as :D and :U turn undefined variables into useful
- * variables (VAR_JUNK, VAR_KEEP).
+ * Some modifiers such as :D and :U turn undefined expressions into defined
+ * expressions (see VEF_UNDEF, VEF_DEF).
  *
  * Some modifiers need to free some memory.
  */
@@ -3604,15 +3604,15 @@ Var_Parse(const char **pp, GNode *ctxt, 
 
 	    /* The variable expression is based on an undefined variable.
 	     * Nevertheless it needs a Var, for modifiers that access the
-	     * variable name, such as :L or :?, and for modifiers that access
-	     * the variable flags (VAR_JUNK, VAR_KEEP).
+	     * variable name, such as :L or :?.
 	     *
 	     * Most modifiers leave this expression in the "undefined" state
-	     * (VAR_JUNK), only a few modifiers like :D, :U, :L, :P turn this
-	     * undefined expression into a defined expression (VAR_KEEP).
+	     * (VEF_UNDEF), only a few modifiers like :D, :U, :L, :P turn this
+	     * undefined expression into a defined expression (VEF_DEF).
 	     *
 	     * At the end, after applying all modifiers, if the expression
-	     * is still !VAR_KEEP, Var_Parse will return var_Error. */
+	     * is still undefined, Var_Parse will return an empty string
+	     * instead of the actually computed value. */
 	    v = bmake_malloc(sizeof(Var));
 	    v->name = varname;
 	    Buf_Init(&v->val, 1);
@@ -3685,11 +3685,6 @@ Var_Parse(const char **pp, GNode *ctxt, 
 	(void)VarFreeEnv(v, !keepValue);
 
     } else if (exprFlags & VEF_UNDEF) {
-	/*
-	 * Perform any freeing needed and set *freePtr to NULL so the caller
-	 * doesn't try to free a static pointer.
-	 * If VAR_KEEP is also set then we want to keep str(?) as is.
-	 */
 	if (!(exprFlags & VEF_DEF)) {
 	    if (*freePtr != NULL) {
 		free(*freePtr);
@@ -3699,6 +3694,8 @@ Var_Parse(const char **pp, GNode *ctxt, 
 		nstr = bmake_strsedup(start, p);
 		*freePtr = nstr;
 	    } else {
+		/* The expression is still undefined, therefore discard the
+		 * actual value and return an empty string instead. */
 		nstr = (eflags & VARE_UNDEFERR) ? var_Error : varNoError;
 	    }
 	}

Reply via email to