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: in the Var_ functions, move the scope to ...



details:   https://anonhg.NetBSD.org/src/rev/8e612b1f5faf
branches:  trunk
changeset: 951522:8e612b1f5faf
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Feb 05 05:15:12 2021 +0000

description:
make: in the Var_ functions, move the scope to the front

This change provides for a more natural reading order in the code.
Placing the scope first makes it immediately clear in which context the
remaining parameters are interpreted.

No functional change.

diffstat:

 usr.bin/make/arch.c    |   8 ++--
 usr.bin/make/compat.c  |   8 ++--
 usr.bin/make/cond.c    |   6 ++--
 usr.bin/make/job.c     |  12 ++++----
 usr.bin/make/main.c    |  26 +++++++++---------
 usr.bin/make/make.c    |  30 +++++++++++-----------
 usr.bin/make/meta.c    |  34 ++++++++++++++----------
 usr.bin/make/nonints.h |  24 ++++++++--------
 usr.bin/make/parse.c   |  28 ++++++++++----------
 usr.bin/make/suff.c    |  36 +++++++++++++-------------
 usr.bin/make/trace.c   |   6 ++--
 usr.bin/make/var.c     |  68 +++++++++++++++++++++++++-------------------------
 12 files changed, 146 insertions(+), 140 deletions(-)

diffs (truncated from 1015 to 300 lines):

diff -r 5d48f2c93bb4 -r 8e612b1f5faf usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Fri Feb 05 04:41:17 2021 +0000
+++ b/usr.bin/make/arch.c       Fri Feb 05 05:15:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.196 2021/02/04 21:42:46 rillig Exp $        */
+/*     $NetBSD: arch.c,v 1.197 2021/02/05 05:15:12 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include "config.h"
 
 /*     "@(#)arch.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: arch.c,v 1.196 2021/02/04 21:42:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.197 2021/02/05 05:15:12 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -973,9 +973,9 @@
        free(libName);
 
 #ifdef LIBRARIES
-       Var_Set(TARGET, gn->name, gn);
+       Var_Set(gn, TARGET, gn->name);
 #else
-       Var_Set(TARGET, GNode_Path(gn), gn);
+       Var_Set(gn, TARGET, GNode_Path(gn));
 #endif
 }
 
diff -r 5d48f2c93bb4 -r 8e612b1f5faf usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Fri Feb 05 04:41:17 2021 +0000
+++ b/usr.bin/make/compat.c     Fri Feb 05 05:15:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.223 2021/02/04 21:42:46 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.224 2021/02/05 05:15:12 rillig Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*     "@(#)compat.c   8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.223 2021/02/04 21:42:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.224 2021/02/05 05:15:12 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -509,7 +509,7 @@
        }
 
        if (Lst_FindDatum(&gn->implicitParents, pgn) != NULL)
-               Var_Set(IMPSRC, GNode_VarTarget(gn), pgn);
+               Var_Set(pgn, IMPSRC, GNode_VarTarget(gn));
 
        /*
         * All the children were made ok. Now youngestChild->mtime contains the
@@ -602,7 +602,7 @@
 
        if (Lst_FindDatum(&gn->implicitParents, pgn) != NULL) {
                const char *target = GNode_VarTarget(gn);
-               Var_Set(IMPSRC, target != NULL ? target : "", pgn);
+               Var_Set(pgn, IMPSRC, target != NULL ? target : "");
        }
 
        switch (gn->made) {
diff -r 5d48f2c93bb4 -r 8e612b1f5faf usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Fri Feb 05 04:41:17 2021 +0000
+++ b/usr.bin/make/cond.c       Fri Feb 05 05:15:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.255 2021/02/04 21:33:13 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.256 2021/02/05 05:15:12 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.255 2021/02/04 21:33:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.256 2021/02/05 05:15:12 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -303,7 +303,7 @@
 static Boolean
 FuncDefined(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
 {
-       FStr value = Var_Value(arg, SCOPE_CMDLINE);
+       FStr value = Var_Value(SCOPE_CMDLINE, arg);
        Boolean result = value.str != NULL;
        FStr_Done(&value);
        return result;
diff -r 5d48f2c93bb4 -r 8e612b1f5faf usr.bin/make/job.c
--- a/usr.bin/make/job.c        Fri Feb 05 04:41:17 2021 +0000
+++ b/usr.bin/make/job.c        Fri Feb 05 05:15:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.416 2021/02/04 21:33:13 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.417 2021/02/05 05:15:12 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*     "@(#)job.c      8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.416 2021/02/04 21:33:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.417 2021/02/05 05:15:12 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -1316,7 +1316,7 @@
                 * .DEFAULT itself.
                 */
                Make_HandleUse(defaultNode, gn);
-               Var_Set(IMPSRC, GNode_VarTarget(gn), gn);
+               Var_Set(gn, IMPSRC, GNode_VarTarget(gn));
                return TRUE;
        }
 
@@ -2136,7 +2136,7 @@
        if (shellPath == NULL)
                InitShellNameAndPath();
 
-       Var_SetWithFlags(".SHELL", shellPath, SCOPE_CMDLINE, VAR_SET_READONLY);
+       Var_SetWithFlags(SCOPE_CMDLINE, ".SHELL", shellPath, VAR_SET_READONLY);
        if (shell->errFlag == NULL)
                shell->errFlag = "";
        if (shell->echoFlag == NULL)
@@ -2176,7 +2176,7 @@
 {
        if (targPrefix != NULL) {
                free(targPrefix);
-       } else if (!Var_Exists(MAKE_JOB_PREFIX, SCOPE_GLOBAL)) {
+       } else if (!Var_Exists(SCOPE_GLOBAL, MAKE_JOB_PREFIX)) {
                Global_Set(MAKE_JOB_PREFIX, "---");
        }
 
@@ -2891,7 +2891,7 @@
                return FALSE;
 
        if (fname != NULL)
-               Var_Set(ALLSRC, fname, gn);
+               Var_Set(gn, ALLSRC, fname);
 
        JobRun(gn);
        /* XXX: Replace with GNode_IsError(gn) */
diff -r 5d48f2c93bb4 -r 8e612b1f5faf usr.bin/make/main.c
--- a/usr.bin/make/main.c       Fri Feb 05 04:41:17 2021 +0000
+++ b/usr.bin/make/main.c       Fri Feb 05 05:15:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.531 2021/02/05 04:41:17 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.532 2021/02/05 05:15:12 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.531 2021/02/05 04:41:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.532 2021/02/05 05:15:12 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -693,7 +693,7 @@
                return;
 
        {
-               FStr argv0 = Var_Value(".MAKE", SCOPE_GLOBAL);
+               FStr argv0 = Var_Value(SCOPE_GLOBAL, ".MAKE");
                buf = str_concat3(argv0.str, " ", line);
                FStr_Done(&argv0);
        }
@@ -753,7 +753,7 @@
 static Boolean
 SetVarObjdir(Boolean writable, const char *var, const char *suffix)
 {
-       FStr path = Var_Value(var, SCOPE_CMDLINE);
+       FStr path = Var_Value(SCOPE_CMDLINE, var);
        FStr xpath;
 
        if (path.str == NULL || path.str[0] == '\0') {
@@ -855,7 +855,7 @@
                bmake_free(evalue);
 
        } else {
-               FStr value = Var_Value(varname, SCOPE_GLOBAL);
+               FStr value = Var_Value(SCOPE_GLOBAL, varname);
                printf("%s\n", value.str != NULL ? value.str : "");
                FStr_Done(&value);
        }
@@ -1051,13 +1051,13 @@
        if (ignorePWD || (pwd = getenv("PWD")) == NULL)
                return;
 
-       prefix = Var_Value("MAKEOBJDIRPREFIX", SCOPE_CMDLINE);
+       prefix = Var_Value(SCOPE_CMDLINE, "MAKEOBJDIRPREFIX");
        if (prefix.str != NULL) {
                FStr_Done(&prefix);
                return;
        }
 
-       makeobjdir = Var_Value("MAKEOBJDIR", SCOPE_CMDLINE);
+       makeobjdir = Var_Value(SCOPE_CMDLINE, "MAKEOBJDIR");
        if (makeobjdir.str != NULL && strchr(makeobjdir.str, '$') != NULL)
                goto ignore_pwd;
 
@@ -1238,7 +1238,7 @@
        int n;
 
        if (forceJobs || opts.compatMake ||
-           !Var_Exists(".MAKE.JOBS", SCOPE_GLOBAL))
+           !Var_Exists(SCOPE_GLOBAL, ".MAKE.JOBS"))
                return;
 
        (void)Var_Subst("${.MAKE.JOBS}", SCOPE_GLOBAL, VARE_WANTRES, &value);
@@ -1273,7 +1273,7 @@
 InitVpath(void)
 {
        char *vpath, savec, *path;
-       if (!Var_Exists("VPATH", SCOPE_CMDLINE))
+       if (!Var_Exists(SCOPE_CMDLINE, "VPATH"))
                return;
 
        (void)Var_Subst("${VPATH}", SCOPE_CMDLINE, VARE_WANTRES, &vpath);
@@ -1426,7 +1426,7 @@
        Global_Set("MFLAGS", "");
        Global_Set(".ALLTARGETS", "");
        /* some makefiles need to know this */
-       Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, SCOPE_CMDLINE);
+       Var_Set(SCOPE_CMDLINE, MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV);
 
        /* Set some other useful variables. */
        {
@@ -1560,7 +1560,7 @@
        MakeMode();
 
        {
-               FStr makeflags = Var_Value(MAKEFLAGS, SCOPE_GLOBAL);
+               FStr makeflags = Var_Value(SCOPE_GLOBAL, MAKEFLAGS);
                Global_Append("MFLAGS", makeflags.str);
                FStr_Done(&makeflags);
        }
@@ -1691,7 +1691,7 @@
 
        if (strcmp(fname, "-") == 0) {
                Parse_File(NULL /*stdin*/, -1);
-               Var_Set("MAKEFILE", "", SCOPE_INTERNAL);
+               Var_Set(SCOPE_INTERNAL, "MAKEFILE", "");
        } else {
                /* if we've chdir'd, rebuild the path name */
                if (strcmp(curdir, objdir) != 0 && *fname != '/') {
@@ -1735,7 +1735,7 @@
                 */
 found:
                if (!doing_depend)
-                       Var_Set("MAKEFILE", fname, SCOPE_INTERNAL);
+                       Var_Set(SCOPE_INTERNAL, "MAKEFILE", fname);
                Parse_File(fname, fd);
        }
        free(path);
diff -r 5d48f2c93bb4 -r 8e612b1f5faf usr.bin/make/make.c
--- a/usr.bin/make/make.c       Fri Feb 05 04:41:17 2021 +0000
+++ b/usr.bin/make/make.c       Fri Feb 05 05:15:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.c,v 1.241 2021/02/04 21:42:46 rillig Exp $        */
+/*     $NetBSD: make.c,v 1.242 2021/02/05 05:15:12 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -103,7 +103,7 @@
 #include "job.h"
 
 /*     "@(#)make.c     8.1 (Berkeley) 6/6/93"  */
-MAKE_RCSID("$NetBSD: make.c,v 1.241 2021/02/04 21:42:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.242 2021/02/05 05:15:12 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked_seqno = 1;
@@ -568,9 +568,9 @@
        for (ln = cgn->implicitParents.first; ln != NULL; ln = ln->next) {
                GNode *pgn = ln->datum;
                if (pgn->flags & REMAKE) {
-                       Var_Set(IMPSRC, cname, pgn);
+                       Var_Set(pgn, IMPSRC, cname);
                        if (cpref != NULL)
-                               Var_Set(PREFIX, cpref, pgn);
+                               Var_Set(pgn, PREFIX, cpref);
                }
        }
 }
@@ -823,11 +823,11 @@
                allsrc = child;
 
        if (allsrc != NULL)
-               Var_Append(ALLSRC, allsrc, pgn);
+               Var_Append(pgn, ALLSRC, allsrc);
 
        if (pgn->type & OP_JOIN) {



Home | Main Index | Thread Index | Old Index