Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make: rename VarFreeEnv to VarFreeShortLived



details:   https://anonhg.NetBSD.org/src/rev/701aac4393e0
branches:  trunk
changeset: 1027607:701aac4393e0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Dec 13 02:07:58 2021 +0000

description:
make: rename VarFreeEnv to VarFreeShortLived

The newly added "variable" .SUFFIXES is short-lived as well, which makes
it necessary to distinguish between environment variables and
short-lived variables.

No binary change.

diffstat:

 usr.bin/make/var.c |  28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diffs (100 lines):

diff -r 0edf5f00b1f3 -r 701aac4393e0 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Dec 13 01:51:12 2021 +0000
+++ b/usr.bin/make/var.c        Mon Dec 13 02:07:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.976 2021/12/13 01:37:51 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.977 2021/12/13 02:07:58 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.976 2021/12/13 01:37:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.977 2021/12/13 02:07:58 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -155,8 +155,8 @@
  * not be possible to undefine a variable during the evaluation of an
  * expression, or Var.name might point nowhere.
  *
- * Environment variables are temporary.  They are returned by VarFind, and
- * after using them, they must be freed using VarFreeEnv.
+ * Environment variables are short-lived.  They are returned by VarFind, and
+ * after using them, they must be freed using VarFreeShortLived.
  *
  * Undefined variables occur during evaluation of variable expressions such
  * as ${UNDEF:Ufallback} in Var_Parse and ApplyModifiers.
@@ -391,8 +391,8 @@
  *
  * Results:
  *     The found variable, or NULL if the variable does not exist.
- *     If the variable is an environment variable, it must be freed using
- *     VarFreeEnv after use.
+ *     If the variable is short-lived (such as environment variables), it
+ *     must be freed using VarFreeShortLived after use.
  */
 static Var *
 VarFindSubstring(Substring name, GNode *scope, bool elsewhere)
@@ -455,11 +455,11 @@
        return VarFindSubstring(Substring_InitStr(name), scope, elsewhere);
 }
 
-/* If the variable is an environment variable, free it, including its value. */
+/* If the variable is short-lived, free it, including its value. */
 static void
-VarFreeEnv(Var *v)
+VarFreeShortLived(Var *v)
 {
-       if (!v->fromEnv)
+       if (!v->fromEnv)        /* TODO: replace with v->shortLived */
                return;
 
        FStr_Done(&v->name);
@@ -940,7 +940,7 @@
                return true;
        }
 
-       VarFreeEnv(v);
+       VarFreeShortLived(v);
        return false;
 }
 
@@ -1025,7 +1025,7 @@
                save_dollars = ParseBoolean(val, save_dollars);
 
        if (v != NULL)
-               VarFreeEnv(v);
+               VarFreeShortLived(v);
 }
 
 /* See Var_Set for documentation. */
@@ -1199,7 +1199,7 @@
        if (v == NULL)
                return false;
 
-       VarFreeEnv(v);
+       VarFreeShortLived(v);
        return true;
 }
 
@@ -3557,7 +3557,7 @@
                if (gv == NULL)
                        scope = SCOPE_GLOBAL;
                else
-                       VarFreeEnv(gv);
+                       VarFreeShortLived(gv);
        }
 
        switch (op[0]) {
@@ -4465,7 +4465,7 @@
                expr->value.freeIt = v->val.data;
                v->val.data = NULL;
        }
-       VarFreeEnv(v);
+       VarFreeShortLived(v);
 }
 
 #if __STDC_VERSION__ >= 199901L



Home | Main Index | Thread Index | Old Index