Module Name: src Committed By: rillig Date: Wed Nov 4 03:37:51 UTC 2020
Modified Files: src/usr.bin/make: main.c make.h parse.c var.c Log Message: make(1): rename oldVars to discardUndefined While here, moved all the documentation about this variable into a single place. To generate a diff of this commit: cvs rdiff -u -r1.421 -r1.422 src/usr.bin/make/main.c cvs rdiff -u -r1.181 -r1.182 src/usr.bin/make/make.h cvs rdiff -u -r1.422 -r1.423 src/usr.bin/make/parse.c cvs rdiff -u -r1.654 -r1.655 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.421 src/usr.bin/make/main.c:1.422 --- src/usr.bin/make/main.c:1.421 Sun Nov 1 00:24:57 2020 +++ src/usr.bin/make/main.c Wed Nov 4 03:37:51 2020 @@ -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 @@ Boolean deleteOnError; /* .DELETE_ON_E 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 @@ rearg: argc -= arginc; } - oldVars = TRUE; + discardUndefined = TRUE; /* * See if the rest of the arguments are variable assignments and Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.181 src/usr.bin/make/make.h:1.182 --- src/usr.bin/make/make.h:1.181 Wed Nov 4 03:13:46 2020 +++ src/usr.bin/make/make.h Wed Nov 4 03:37:51 2020 @@ -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 char var_Error[]; /* Value return 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. */ Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.422 src/usr.bin/make/parse.c:1.423 --- src/usr.bin/make/parse.c:1.422 Mon Nov 2 22:50:55 2020 +++ src/usr.bin/make/parse.c Wed Nov 4 03:37:51 2020 @@ -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 @@ VarAssign_EvalSubst(const char *name, co { 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; + Boolean savedDiscardUndefined = discardUndefined; - oldVars = FALSE; + discardUndefined = FALSE; /* * make sure that we set the variable the first time to nothing @@ -1943,7 +1932,7 @@ VarAssign_EvalSubst(const char *name, co (void)Var_Subst(uvalue, ctxt, VARE_WANTRES|VARE_ASSIGN, &evalue); /* TODO: handle errors */ - oldVars = oldOldVars; + discardUndefined = savedDiscardUndefined; avalue = evalue; Var_Set(name, avalue, ctxt); Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.654 src/usr.bin/make/var.c:1.655 --- src/usr.bin/make/var.c:1.654 Wed Nov 4 02:53:18 2020 +++ src/usr.bin/make/var.c Wed Nov 4 03:37:51 2020 @@ -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 @@ Var_Subst(const char *str, GNode *ctxt, /* 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) { /*