From ebbfad8f2df68fb0fe9df441b4ddb25053440cf5 Mon Sep 17 00:00:00 2001 From: rillig Date: Thu, 2 Jul 2020 16:52:34 +0000 Subject: [PATCH] make(1): fix unnecessary evaluation of variables in :@var@ modifier --- usr.bin/make/unit-tests/cond-short.exp | 3 --- usr.bin/make/var.c | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/usr.bin/make/unit-tests/cond-short.exp b/usr.bin/make/unit-tests/cond-short.exp index 33be03079bb3..0c8c47a449fe 100644 --- a/usr.bin/make/unit-tests/cond-short.exp +++ b/usr.bin/make/unit-tests/cond-short.exp @@ -4,9 +4,6 @@ expected and empty expected U23 condition expected VAR23 expected M pattern -unexpected @ modifier -unexpected @ modifier -unexpected @ modifier expected or expected or exists expected or empty diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 297f4be261bb..306e91ac4b42 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.232 2020/07/02 16:46:57 rillig Exp $ */ +/* $NetBSD: var.c,v 1.233 2020/07/02 16:52:34 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.232 2020/07/02 16:46:57 rillig Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.233 2020/07/02 16:52:34 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.232 2020/07/02 16:46:57 rillig Exp $"); +__RCSID("$NetBSD: var.c,v 1.233 2020/07/02 16:52:34 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -279,7 +279,7 @@ typedef struct { int tvarLen; char *str; /* string to expand */ int strLen; - int errnum; /* errnum for not defined */ + Varf_Flags flags; } VarLoop_t; #ifndef NO_REGEX @@ -1843,7 +1843,7 @@ VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSED, if (word && *word) { Var_Set_Flags(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT); - s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum | VARF_WANTRES); + s = Var_Subst(NULL, loop->str, loop->ctxt, loop->flags); if (s != NULL && *s != '\0') { if (addSpace && *s != '\n') Buf_AddByte(buf, ' '); @@ -2759,7 +2759,7 @@ ApplyModifiers(char *nstr, const char *tstr, termc = *cp; delim = '\0'; - loop.errnum = flags & VARF_UNDEFERR; + loop.flags = flags & (VARF_UNDEFERR | VARF_WANTRES); loop.ctxt = ctxt; newStr = VarModify(ctxt, &parsestate, nstr, VarLoopExpand, &loop);