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): rename oldVars to discardUndefined



details:   https://anonhg.NetBSD.org/src/rev/16f20d48b707
branches:  trunk
changeset: 956661:16f20d48b707
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Nov 04 03:37:51 2020 +0000

description:
make(1): rename oldVars to discardUndefined

While here, moved all the documentation about this variable into a
single place.

diffstat:

 usr.bin/make/main.c  |   8 ++++----
 usr.bin/make/make.h  |  18 +++++++++++++-----
 usr.bin/make/parse.c |  23 ++++++-----------------
 usr.bin/make/var.c   |  12 +++---------
 4 files changed, 26 insertions(+), 35 deletions(-)

diffs (153 lines):

diff -r 4d4fb8bcbc89 -r 16f20d48b707 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Wed Nov 04 03:13:46 2020 +0000
+++ b/usr.bin/make/main.c       Wed Nov 04 03:37:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.421 2020/11/01 00:24:57 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.422 2020/11/04 03:37:51 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.421 2020/11/01 00:24:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.422 2020/11/04 03:37:51 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -138,7 +138,7 @@
 static int             maxJobTokens;   /* -j argument */
 Boolean                        enterFlagObj;   /* -w and objdir != srcdir */
 
-Boolean                        oldVars;        /* variable substitution style */
+Boolean discardUndefined;
 static int jp_0 = -1, jp_1 = -1;       /* ends of parent job pipe */
 Boolean                        doing_depend;   /* Set while reading .depend */
 static Boolean         jobsRunning;    /* TRUE if the jobs might be running */
@@ -640,7 +640,7 @@
                argc -= arginc;
        }
 
-       oldVars = TRUE;
+       discardUndefined = TRUE;
 
        /*
         * See if the rest of the arguments are variable assignments and
diff -r 4d4fb8bcbc89 -r 16f20d48b707 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Wed Nov 04 03:13:46 2020 +0000
+++ b/usr.bin/make/make.h       Wed Nov 04 03:37:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.181 2020/11/04 03:13:46 rillig Exp $        */
+/*     $NetBSD: make.h,v 1.182 2020/11/04 03:37:51 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -444,11 +444,19 @@
 extern time_t  now;            /* The time at the start of this whole
                                 * process */
 
-/* Do old-style variable substitution.
+/*
+ * If TRUE (default behavior), undefined subexpressions in a variable
+ * expression are discarded.  If FALSE (only in variable assignments using the
+ * ':=' assignment operator), they are preserved and possibly expanded later
+ * when the variable from the subexpression has been defined.
  *
- * The word "old" comes from 1993-03-21 or earlier, so it must be really old.
- * TODO: But what does this "old-style" mean?  What effects does it have? */
-extern Boolean oldVars;
+ * Example for a ':=' assignment:
+ *     CFLAGS = $(.INCLUDES)
+ *     CFLAGS := -I.. $(CFLAGS)
+ *     # If .INCLUDES (an undocumented special variable, by the way) is
+ *     # still undefined, the updated CFLAGS becomes "-I.. $(.INCLUDES)".
+ */
+extern Boolean discardUndefined;
 
 extern SearchPath *sysIncPath; /* The system include path. */
 extern SearchPath *defSysIncPath; /* The default system include path. */
diff -r 4d4fb8bcbc89 -r 16f20d48b707 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Wed Nov 04 03:13:46 2020 +0000
+++ b/usr.bin/make/parse.c      Wed Nov 04 03:37:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.422 2020/11/02 22:50:55 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.423 2020/11/04 03:37:51 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.422 2020/11/02 22:50:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.423 2020/11/04 03:37:51 rillig Exp $");
 
 /* types and constants */
 
@@ -1919,20 +1919,9 @@
 {
     const char *avalue = uvalue;
     char *evalue;
-    /*
-     * Allow variables in the old value to be undefined, but leave their
-     * expressions alone -- this is done by forcing oldVars to be false.
-     * XXX: This can cause recursive variables, but that's not hard to do,
-     * and this allows someone to do something like
-     *
-     *  CFLAGS = $(.INCLUDES)
-     *  CFLAGS := -I.. $(CFLAGS)
-     *
-     * And not get an error.
-     */
-    Boolean oldOldVars = oldVars;
-
-    oldVars = FALSE;
+    Boolean savedDiscardUndefined = discardUndefined;
+
+    discardUndefined = FALSE;
 
     /*
      * make sure that we set the variable the first time to nothing
@@ -1943,7 +1932,7 @@
 
     (void)Var_Subst(uvalue, ctxt, VARE_WANTRES|VARE_ASSIGN, &evalue);
     /* TODO: handle errors */
-    oldVars = oldOldVars;
+    discardUndefined = savedDiscardUndefined;
     avalue = evalue;
     Var_Set(name, avalue, ctxt);
 
diff -r 4d4fb8bcbc89 -r 16f20d48b707 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Wed Nov 04 03:13:46 2020 +0000
+++ b/usr.bin/make/var.c        Wed Nov 04 03:37:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.654 2020/11/04 02:53:18 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.655 2020/11/04 03:37:51 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.654 2020/11/04 02:53:18 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.655 2020/11/04 03:37:51 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3989,13 +3989,7 @@
            /* TODO: handle errors */
 
            if (val == var_Error || val == varUndefined) {
-               /*
-                * If performing old-time variable substitution, skip over
-                * the variable and continue with the substitution. Otherwise,
-                * store the dollar sign and advance str so we continue with
-                * the string...
-                */
-               if (oldVars) {
+               if (discardUndefined) {
                    p = nested_p;
                } else if ((eflags & VARE_UNDEFERR) || val == var_Error) {
                    /*



Home | Main Index | Thread Index | Old Index