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): remove dead code from ApplyModifiersIn...
details: https://anonhg.NetBSD.org/src/rev/4af57db98e6b
branches: trunk
changeset: 948346:4af57db98e6b
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Dec 27 16:31:58 2020 +0000
description:
make(1): remove dead code from ApplyModifiersIndirect
At that point, the expression can never be varUndefined. At the
beginning of ParseVarnameLong, the expression is initialized to a simple
empty string, and that string is only ever converted to varUndefined at
the very end of Var_Parse.
diffstat:
usr.bin/make/unit-tests/varmod-indirect.exp | 4 ++++
usr.bin/make/unit-tests/varmod-indirect.mk | 15 ++++++++++++++-
usr.bin/make/var.c | 7 +++----
3 files changed, 21 insertions(+), 5 deletions(-)
diffs (67 lines):
diff -r f9a08130c4cc -r 4af57db98e6b usr.bin/make/unit-tests/varmod-indirect.exp
--- a/usr.bin/make/unit-tests/varmod-indirect.exp Sun Dec 27 16:09:33 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-indirect.exp Sun Dec 27 16:31:58 2020 +0000
@@ -1,4 +1,8 @@
make: "varmod-indirect.mk" line 13: Unknown modifier '$'
+make: "varmod-indirect.mk" line 106: before
+make: "varmod-indirect.mk" line 106: after
+make: "varmod-indirect.mk" line 112: before
+make: "varmod-indirect.mk" line 112: after
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
diff -r f9a08130c4cc -r 4af57db98e6b usr.bin/make/unit-tests/varmod-indirect.mk
--- a/usr.bin/make/unit-tests/varmod-indirect.mk Sun Dec 27 16:09:33 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-indirect.mk Sun Dec 27 16:31:58 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.2 2020/12/20 19:29:06 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.3 2020/12/27 16:31:58 rillig Exp $
#
# Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
# These can be used for very basic purposes like converting a string to either
@@ -99,4 +99,17 @@
.endif
.MAKEFLAGS: -d0
+
+# In contrast to the .if conditions, the .for loop allows undefined variable
+# expressions. These expressions expand to empty strings.
+.for var in before ${UNDEF} ${UNDEF:${:US,a,a,}} after
+. info ${var}
+.endfor
+
+# Even in an indirect modifier based on an undefined variable, the value of
+# the expression in Var_Parse is a simple empty string.
+.for var in before ${UNDEF} ${UNDEF:${:U}} after
+. info ${var}
+.endfor
+
all:
diff -r f9a08130c4cc -r 4af57db98e6b usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Dec 27 16:09:33 2020 +0000
+++ b/usr.bin/make/var.c Sun Dec 27 16:31:58 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.772 2020/12/27 14:41:25 rillig Exp $ */
+/* $NetBSD: var.c,v 1.773 2020/12/27 16:31:58 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.772 2020/12/27 14:41:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.773 2020/12/27 16:31:58 rillig Exp $");
typedef enum VarFlags {
VAR_NONE = 0,
@@ -3473,8 +3473,7 @@
FStr newVal = ApplyModifiers(&modsp, *inout_value, '\0', '\0',
st->var, &st->exprFlags, st->ctxt, st->eflags);
*inout_value = newVal;
- if (newVal.str == var_Error || newVal.str == varUndefined ||
- *modsp != '\0') {
+ if (newVal.str == var_Error || *modsp != '\0') {
FStr_Done(&mods);
*pp = p;
return AMIR_OUT; /* error already reported */
Home |
Main Index |
Thread Index |
Old Index