Module Name: src
Committed By: rillig
Date: Sat Oct 31 11:34:30 UTC 2020
Modified Files:
src/usr.bin/make: main.c var.c
Log Message:
make(1): reduce the scope where recursive expressions are detected
Only the call to Var_Subst needs to be protected since the other
functions have nothing to do with expanding variables.
To generate a diff of this commit:
cvs rdiff -u -r1.417 -r1.418 src/usr.bin/make/main.c
cvs rdiff -u -r1.614 -r1.615 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.417 src/usr.bin/make/main.c:1.418
--- src/usr.bin/make/main.c:1.417 Sat Oct 31 09:35:58 2020
+++ src/usr.bin/make/main.c Sat Oct 31 11:34:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.417 2020/10/31 09:35:58 rillig Exp $ */
+/* $NetBSD: main.c,v 1.418 2020/10/31 11:34:30 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.417 2020/10/31 09:35:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.418 2020/10/31 11:34:30 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -1827,7 +1827,7 @@ Error(const char *fmt, ...)
/* Produce a Fatal error message, then exit immediately.
*
- * If jobs are running, waits for them to finish. */
+ * If jobs are running, wait for them to finish. */
void
Fatal(const char *fmt, ...)
{
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.614 src/usr.bin/make/var.c:1.615
--- src/usr.bin/make/var.c:1.614 Sat Oct 31 09:57:47 2020
+++ src/usr.bin/make/var.c Sat Oct 31 11:34:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.614 2020/10/31 09:57:47 rillig Exp $ */
+/* $NetBSD: var.c,v 1.615 2020/10/31 11:34:30 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.614 2020/10/31 09:57:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.615 2020/10/31 11:34:30 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3662,12 +3662,8 @@ Var_Parse(const char **pp, GNode *ctxt,
free(varname);
}
- if (v->flags & VAR_IN_USE) {
+ if (v->flags & VAR_IN_USE)
Fatal("Variable %s is recursive.", v->name);
- /*NOTREACHED*/
- } else {
- v->flags |= VAR_IN_USE;
- }
/*
* Before doing any modification, we have to make sure the value
@@ -3683,13 +3679,13 @@ Var_Parse(const char **pp, GNode *ctxt,
VarEvalFlags nested_eflags = eflags;
if (DEBUG(LINT))
nested_eflags &= ~(unsigned)VARE_UNDEFERR;
+ v->flags |= VAR_IN_USE;
(void)Var_Subst(nstr, ctxt, nested_eflags, &nstr);
+ v->flags &= ~(unsigned)VAR_IN_USE;
/* TODO: handle errors */
*freePtr = nstr;
}
- v->flags &= ~(unsigned)VAR_IN_USE;
-
if (haveModifier || extramodifiers != NULL) {
void *extraFree;