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 constants for VarFlags



details:   https://anonhg.NetBSD.org/src/rev/47d980e773ad
branches:  trunk
changeset: 959518:47d980e773ad
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Feb 16 16:28:41 2021 +0000

description:
make: rename constants for VarFlags

The old prefix was "VAR_" and this prefix is used for several other
constants as well, which made it ambiguous.

diffstat:

 usr.bin/make/unit-tests/directive-export-impl.exp |   8 +-
 usr.bin/make/unit-tests/directive-export-impl.mk  |  12 +-
 usr.bin/make/var.c                                |  76 +++++++++++-----------
 3 files changed, 48 insertions(+), 48 deletions(-)

diffs (truncated from 354 to 300 lines):

diff -r 1c696df11254 -r 47d980e773ad usr.bin/make/unit-tests/directive-export-impl.exp
--- a/usr.bin/make/unit-tests/directive-export-impl.exp Tue Feb 16 16:14:27 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-export-impl.exp Tue Feb 16 16:28:41 2021 +0000
@@ -5,10 +5,10 @@
 ParseReadLine (32): ': ${UT_VAR:N*}'
 Var_Parse: ${UT_VAR:N*} with VARE_UNDEFERR|VARE_WANTRES
 Var_Parse: ${REF}> with VARE_UNDEFERR|VARE_WANTRES
-Applying ${UT_VAR:N...} to "<>" (VARE_UNDEFERR|VARE_WANTRES, VAR_EXPORTED|VAR_REEXPORT, regular)
+Applying ${UT_VAR:N...} to "<>" (VARE_UNDEFERR|VARE_WANTRES, VFL_EXPORTED|VFL_REEXPORT, regular)
 Pattern[UT_VAR] for [<>] is [*]
 ModifyWords: split "<>" into 1 words
-Result of ${UT_VAR:N*} is "" (VARE_UNDEFERR|VARE_WANTRES, VAR_EXPORTED|VAR_REEXPORT, regular)
+Result of ${UT_VAR:N*} is "" (VARE_UNDEFERR|VARE_WANTRES, VFL_EXPORTED|VFL_REEXPORT, regular)
 ParseDoDependency(: )
 CondParser_Eval: ${:!echo "\$UT_VAR"!} != "<>"
 Var_Parse: ${:!echo "\$UT_VAR"!} != "<>" with VARE_UNDEFERR|VARE_WANTRES
@@ -26,10 +26,10 @@
 ParseReadLine (49): ': ${UT_VAR:N*}'
 Var_Parse: ${UT_VAR:N*} with VARE_UNDEFERR|VARE_WANTRES
 Var_Parse: ${REF}> with VARE_UNDEFERR|VARE_WANTRES
-Applying ${UT_VAR:N...} to "<>" (VARE_UNDEFERR|VARE_WANTRES, VAR_EXPORTED|VAR_REEXPORT, regular)
+Applying ${UT_VAR:N...} to "<>" (VARE_UNDEFERR|VARE_WANTRES, VFL_EXPORTED|VFL_REEXPORT, regular)
 Pattern[UT_VAR] for [<>] is [*]
 ModifyWords: split "<>" into 1 words
-Result of ${UT_VAR:N*} is "" (VARE_UNDEFERR|VARE_WANTRES, VAR_EXPORTED|VAR_REEXPORT, regular)
+Result of ${UT_VAR:N*} is "" (VARE_UNDEFERR|VARE_WANTRES, VFL_EXPORTED|VFL_REEXPORT, regular)
 ParseDoDependency(: )
 ParseReadLine (53): 'REF=              defined'
 Global:REF = defined
diff -r 1c696df11254 -r 47d980e773ad usr.bin/make/unit-tests/directive-export-impl.mk
--- a/usr.bin/make/unit-tests/directive-export-impl.mk  Tue Feb 16 16:14:27 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-export-impl.mk  Tue Feb 16 16:28:41 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: directive-export-impl.mk,v 1.1 2020/12/29 01:45:06 rillig Exp $
+# $NetBSD: directive-export-impl.mk,v 1.2 2021/02/16 16:28:41 rillig Exp $
 #
 # Test for the implementation of exporting variables to child processes.
 # This involves marking variables for export, actually exporting them,
@@ -8,8 +8,8 @@
 #      Var_Export
 #      ExportVar
 #      VarExportedMode (global)
-#      VAR_EXPORTED (per variable)
-#      VAR_REEXPORT (per variable)
+#      VFL_EXPORTED (per variable)
+#      VFL_REEXPORT (per variable)
 #      VarExportMode (per call of Var_Export and ExportVar)
 
 : ${:U:sh}                     # side effect: initialize .SHELL
@@ -22,13 +22,13 @@
 
 # At this point, ExportVar("UT_VAR", VEM_PLAIN) is called.  Since the
 # variable value refers to another variable, ExportVar does not actually
-# export the variable but only marks it as VAR_EXPORTED and VAR_REEXPORT.
+# export the variable but only marks it as VFL_EXPORTED and VFL_REEXPORT.
 # After that, ExportVars registers the variable name in .MAKE.EXPORTED.
 # That's all for now.
 .export UT_VAR
 
 # Evaluating this expression shows the variable flags in the debug log,
-# which are VAR_EXPORTED|VAR_REEXPORT.
+# which are VFL_EXPORTED|VFL_REEXPORT.
 : ${UT_VAR:N*}
 
 # At the last moment before actually forking off the child process for the
@@ -44,7 +44,7 @@
 .endif
 
 # Evaluating this expression shows the variable flags in the debug log,
-# which are still VAR_EXPORTED|VAR_REEXPORT, which means that the variable
+# which are still VFL_EXPORTED|VFL_REEXPORT, which means that the variable
 # is still marked as being re-exported for each child process.
 : ${UT_VAR:N*}
 
diff -r 1c696df11254 -r 47d980e773ad usr.bin/make/var.c
--- a/usr.bin/make/var.c        Tue Feb 16 16:14:27 2021 +0000
+++ b/usr.bin/make/var.c        Tue Feb 16 16:28:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.827 2021/02/16 16:14:27 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.828 2021/02/16 16:28:41 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,29 +140,29 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.827 2021/02/16 16:14:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.828 2021/02/16 16:28:41 rillig Exp $");
 
 typedef enum VarFlags {
-       VAR_NONE        = 0,
+       VFL_NONE        = 0,
 
        /*
         * The variable's value is currently being used by Var_Parse or
         * Var_Subst.  This marker is used to avoid endless recursion.
         */
-       VAR_IN_USE = 0x01,
+       VFL_IN_USE = 0x01,
 
        /*
         * The variable comes from the environment.
         * These variables are not registered in any GNode, therefore they
         * must be freed as soon as they are not used anymore.
         */
-       VAR_FROM_ENV = 0x02,
+       VFL_FROM_ENV = 0x02,
 
        /*
         * The variable is exported to the environment, to be used by child
         * processes.
         */
-       VAR_EXPORTED = 0x10,
+       VFL_EXPORTED = 0x10,
 
        /*
         * At the point where this variable was exported, it contained an
@@ -170,17 +170,17 @@
         * process is started, it needs to be exported again, in the hope
         * that the referenced variable can then be resolved.
         */
-       VAR_REEXPORT = 0x20,
+       VFL_REEXPORT = 0x20,
 
        /* The variable came from the command line. */
-       VAR_FROM_CMD = 0x40,
+       VFL_FROM_CMD = 0x40,
 
        /*
         * The variable value cannot be changed anymore, and the variable
         * cannot be deleted.  Any attempts to do so are silently ignored,
         * they are logged with -dv though.
         */
-       VAR_READONLY = 0x80
+       VFL_READONLY = 0x80
 } VarFlags;
 
 /*
@@ -315,8 +315,8 @@
 GNode *SCOPE_INTERNAL;
 
 ENUM_FLAGS_RTTI_6(VarFlags,
-                 VAR_IN_USE, VAR_FROM_ENV,
-                 VAR_EXPORTED, VAR_REEXPORT, VAR_FROM_CMD, VAR_READONLY);
+                 VFL_IN_USE, VFL_FROM_ENV,
+                 VFL_EXPORTED, VFL_REEXPORT, VFL_FROM_CMD, VFL_READONLY);
 
 static VarExportedMode var_exportedVars = VAR_EXPORTED_NONE;
 
@@ -437,7 +437,7 @@
 
                if ((env = getenv(name)) != NULL) {
                        char *varname = bmake_strdup(name);
-                       return VarNew(FStr_InitOwn(varname), env, VAR_FROM_ENV);
+                       return VarNew(FStr_InitOwn(varname), env, VFL_FROM_ENV);
                }
 
                if (opts.checkEnvFirst && scope != SCOPE_GLOBAL) {
@@ -467,7 +467,7 @@
 static Boolean
 VarFreeEnv(Var *v, Boolean freeValue)
 {
-       if (!(v->flags & VAR_FROM_ENV))
+       if (!(v->flags & VFL_FROM_ENV))
                return FALSE;
 
        FStr_Done(&v->name);
@@ -488,7 +488,7 @@
 {
        HashEntry *he = HashTable_CreateEntry(&scope->vars, name, NULL);
        Var *v = VarNew(FStr_InitRefer(/* aliased to */ he->key), val,
-           flags & VAR_SET_READONLY ? VAR_READONLY : VAR_NONE);
+           flags & VAR_SET_READONLY ? VFL_READONLY : VFL_NONE);
        HashEntry_Set(he, v);
        DEBUG3(VAR, "%s:%s = %s\n", scope->name, name, val);
 }
@@ -510,7 +510,7 @@
 
        DEBUG2(VAR, "%s:delete %s\n", scope->name, varname);
        v = HashEntry_Get(he);
-       if (v->flags & VAR_EXPORTED)
+       if (v->flags & VFL_EXPORTED)
                unsetenv(v->name.str);
        if (strcmp(v->name.str, MAKE_EXPORTED) == 0)
                var_exportedVars = VAR_EXPORTED_NONE;
@@ -611,16 +611,16 @@
        char *val = v->val.data;
        char *expr;
 
-       if ((v->flags & VAR_EXPORTED) && !(v->flags & VAR_REEXPORT))
+       if ((v->flags & VFL_EXPORTED) && !(v->flags & VFL_REEXPORT))
                return FALSE;   /* nothing to do */
 
        if (strchr(val, '$') == NULL) {
-               if (!(v->flags & VAR_EXPORTED))
+               if (!(v->flags & VFL_EXPORTED))
                        setenv(name, val, 1);
                return TRUE;
        }
 
-       if (v->flags & VAR_IN_USE) {
+       if (v->flags & VFL_IN_USE) {
                /*
                 * We recursed while exporting in a child.
                 * This isn't going to end well, just skip it.
@@ -643,8 +643,8 @@
 {
        if (strchr(v->val.data, '$') == NULL) {
                setenv(v->name.str, v->val.data, 1);
-               v->flags |= VAR_EXPORTED;
-               v->flags &= ~(unsigned)VAR_REEXPORT;
+               v->flags |= VFL_EXPORTED;
+               v->flags &= ~(unsigned)VFL_REEXPORT;
                return TRUE;
        }
 
@@ -653,17 +653,17 @@
         * No point actually exporting it now though,
         * the child process can do it at the last minute.
         */
-       v->flags |= VAR_EXPORTED | VAR_REEXPORT;
+       v->flags |= VFL_EXPORTED | VFL_REEXPORT;
        return TRUE;
 }
 
 static Boolean
 ExportVarLiteral(Var *v)
 {
-       if ((v->flags & VAR_EXPORTED) && !(v->flags & VAR_REEXPORT))
+       if ((v->flags & VFL_EXPORTED) && !(v->flags & VFL_REEXPORT))
                return FALSE;
 
-       if (!(v->flags & VAR_EXPORTED))
+       if (!(v->flags & VFL_EXPORTED))
                setenv(v->name.str, v->val.data, 1);
 
        return TRUE;
@@ -871,9 +871,9 @@
 
        DEBUG1(VAR, "Unexporting \"%s\"\n", varname);
        if (what != UNEXPORT_ENV &&
-           (v->flags & VAR_EXPORTED) && !(v->flags & VAR_REEXPORT))
+           (v->flags & VFL_EXPORTED) && !(v->flags & VFL_REEXPORT))
                unsetenv(v->name.str);
-       v->flags &= ~(unsigned)(VAR_EXPORTED | VAR_REEXPORT);
+       v->flags &= ~(unsigned)(VFL_EXPORTED | VFL_REEXPORT);
 
        if (what == UNEXPORT_NAMED) {
                /* Remove the variable names from .MAKE.EXPORTED. */
@@ -941,7 +941,7 @@
        if (scope == SCOPE_GLOBAL) {
                v = VarFind(name, SCOPE_CMDLINE, FALSE);
                if (v != NULL) {
-                       if (v->flags & VAR_FROM_CMD) {
+                       if (v->flags & VFL_FROM_CMD) {
                                DEBUG3(VAR, "%s:%s = %s ignored!\n",
                                    scope->name, name, val);
                                return;
@@ -968,7 +968,7 @@
                }
                VarAdd(name, val, scope, flags);
        } else {
-               if ((v->flags & VAR_READONLY) && !(flags & VAR_SET_READONLY)) {
+               if ((v->flags & VFL_READONLY) && !(flags & VAR_SET_READONLY)) {
                        DEBUG3(VAR, "%s:%s = %s ignored (read-only)\n",
                            scope->name, name, val);
                        return;
@@ -977,7 +977,7 @@
                Buf_AddStr(&v->val, val);
 
                DEBUG3(VAR, "%s:%s = %s\n", scope->name, name, val);
-               if (v->flags & VAR_EXPORTED)
+               if (v->flags & VFL_EXPORTED)
                        ExportVar(name, VEM_PLAIN);
        }
        /*
@@ -989,7 +989,7 @@
            name[0] != '.') {
                if (v == NULL)
                        v = VarFind(name, scope, FALSE); /* we just added it */
-               v->flags |= VAR_FROM_CMD;
+               v->flags |= VFL_FROM_CMD;
 
                /*
                 * If requested, don't export these in the environment
@@ -1092,23 +1092,23 @@
 
        if (v == NULL) {
                Var_SetWithFlags(scope, name, val, VAR_SET_NONE);
-       } else if (v->flags & VAR_READONLY) {
+       } else if (v->flags & VFL_READONLY) {
                DEBUG1(VAR, "Ignoring append to %s since it is read-only\n",
                    name);
-       } else if (scope == SCOPE_CMDLINE || !(v->flags & VAR_FROM_CMD)) {
+       } else if (scope == SCOPE_CMDLINE || !(v->flags & VFL_FROM_CMD)) {
                Buf_AddByte(&v->val, ' ');
                Buf_AddStr(&v->val, val);
 
                DEBUG3(VAR, "%s:%s = %s\n", scope->name, name, v->val.data);



Home | Main Index | Thread Index | Old Index