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(1): align names of VarExportMode with the ...



details:   https://anonhg.NetBSD.org/src/rev/3b9359e0ecfb
branches:  trunk
changeset: 948325:3b9359e0ecfb
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 27 05:06:17 2020 +0000

description:
make(1): align names of VarExportMode with the directives

diffstat:

 usr.bin/make/nonints.h |   6 +++---
 usr.bin/make/parse.c   |   8 ++++----
 usr.bin/make/var.c     |  35 ++++++++++++++++++++---------------
 3 files changed, 27 insertions(+), 22 deletions(-)

diffs (181 lines):

diff -r b15d6adcfacf -r 3b9359e0ecfb usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Sat Dec 26 22:28:35 2020 +0000
+++ b/usr.bin/make/nonints.h    Sun Dec 27 05:06:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nonints.h,v 1.181 2020/12/22 20:10:21 rillig Exp $     */
+/*     $NetBSD: nonints.h,v 1.182 2020/12/27 05:06:17 rillig Exp $     */
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -387,9 +387,9 @@
 
 typedef enum VarExportMode {
        /* .export-env */
-       VEM_NORMAL,
+       VEM_ENV,
        /* .export: Initial export or update an already exported variable. */
-       VEM_PARENT,
+       VEM_PLAIN,
        /* .export-literal: Do not expand the variable value. */
        VEM_LITERAL
 } VarExportMode;
diff -r b15d6adcfacf -r 3b9359e0ecfb usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Dec 26 22:28:35 2020 +0000
+++ b/usr.bin/make/parse.c      Sun Dec 27 05:06:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.516 2020/12/23 14:13:49 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.517 2020/12/27 05:06:17 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.516 2020/12/23 14:13:49 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.517 2020/12/27 05:06:17 rillig Exp $");
 
 /* types and constants */
 
@@ -3056,10 +3056,10 @@
                Var_Undef(cp);
                return TRUE;
        } else if (IsDirective(dir, dirlen, "export")) {
-               Var_Export(VEM_PARENT, arg);
+               Var_Export(VEM_PLAIN, arg);
                return TRUE;
        } else if (IsDirective(dir, dirlen, "export-env")) {
-               Var_Export(VEM_NORMAL, arg);
+               Var_Export(VEM_ENV, arg);
                return TRUE;
        } else if (IsDirective(dir, dirlen, "export-literal")) {
                Var_Export(VEM_LITERAL, arg);
diff -r b15d6adcfacf -r 3b9359e0ecfb usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Dec 26 22:28:35 2020 +0000
+++ b/usr.bin/make/var.c        Sun Dec 27 05:06:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.764 2020/12/23 13:50:54 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.765 2020/12/27 05:06:17 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.764 2020/12/23 13:50:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.765 2020/12/27 05:06:17 rillig Exp $");
 
 typedef enum VarFlags {
        VAR_NONE        = 0,
@@ -586,7 +586,11 @@
 static Boolean
 ExportVar(const char *name, VarExportMode mode)
 {
-       Boolean parent = mode == VEM_PARENT;
+       /*
+        * XXX: It sounds wrong to handle VEM_PLAIN and VEM_LITERAL
+        * differently here.
+        */
+       Boolean plain = mode == VEM_PLAIN;
        Var *v;
        char *val;
 
@@ -597,14 +601,14 @@
        if (v == NULL)
                return FALSE;
 
-       if (!parent && (v->flags & VAR_EXPORTED) && !(v->flags & VAR_REEXPORT))
+       if (!plain && (v->flags & VAR_EXPORTED) && !(v->flags & VAR_REEXPORT))
                return FALSE;   /* nothing to do */
 
        val = Buf_GetAll(&v->val, NULL);
        if (mode != VEM_LITERAL && strchr(val, '$') != NULL) {
                char *expr;
 
-               if (parent) {
+               if (plain) {
                        /*
                         * Flag the variable as something we need to re-export.
                         * No point actually exporting it now though,
@@ -629,21 +633,22 @@
                free(val);
                free(expr);
        } else {
-               if (parent)
+               if (plain)
                        v->flags &= ~(unsigned)VAR_REEXPORT; /* once will do */
-               if (parent || !(v->flags & VAR_EXPORTED))
+               if (plain || !(v->flags & VAR_EXPORTED))
                        setenv(name, val, 1);
        }
 
        /* This is so Var_Set knows to call Var_Export again. */
-       if (parent)
+       if (plain)
                v->flags |= VAR_EXPORTED;
 
        return TRUE;
 }
 
 /*
- * This gets called from our child processes.
+ * Actually export the variables that have been marked as needing to be
+ * re-exported.
  */
 void
 Var_ReexportVars(void)
@@ -670,7 +675,7 @@
                HashIter_Init(&hi, &VAR_GLOBAL->vars);
                while (HashIter_Next(&hi) != NULL) {
                        Var *var = hi.entry->value;
-                       ExportVar(var->name.str, VEM_NORMAL);
+                       ExportVar(var->name.str, VEM_ENV);
                }
                return;
        }
@@ -683,7 +688,7 @@
                size_t i;
 
                for (i = 0; i < words.len; i++)
-                       ExportVar(words.words[i], VEM_NORMAL);
+                       ExportVar(words.words[i], VEM_ENV);
                Words_Free(words);
        }
        free(val);
@@ -706,7 +711,7 @@
                if (var_exportedVars == VAR_EXPORTED_NONE)
                        var_exportedVars = VAR_EXPORTED_SOME;
 
-               if (isExport && mode == VEM_PARENT)
+               if (isExport && mode == VEM_PLAIN)
                        Var_Append(MAKE_EXPORTED, varname, VAR_GLOBAL);
        }
        Words_Free(words);
@@ -727,7 +732,7 @@
 void
 Var_Export(VarExportMode mode, const char *varnames)
 {
-       if (mode == VEM_PARENT && varnames[0] == '\0') {
+       if (mode == VEM_PLAIN && varnames[0] == '\0') {
                var_exportedVars = VAR_EXPORTED_ALL; /* use with caution! */
                return;
        }
@@ -738,7 +743,7 @@
 void
 Var_ExportVars(const char *varnames)
 {
-       ExportVarsExpand(varnames, FALSE, VEM_PARENT);
+       ExportVarsExpand(varnames, FALSE, VEM_PLAIN);
 }
 
 
@@ -915,7 +920,7 @@
 
                DEBUG3(VAR, "%s:%s = %s\n", ctxt->name, name, val);
                if (v->flags & VAR_EXPORTED)
-                       ExportVar(name, VEM_PARENT);
+                       ExportVar(name, VEM_PLAIN);
        }
        /*
         * Any variables given on the command line are automatically exported



Home | Main Index | Thread Index | Old Index