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: do not expand the variable name in the ':...
details: https://anonhg.NetBSD.org/src/rev/7924935393c3
branches: trunk
changeset: 960318:7924935393c3
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Mar 14 17:27:27 2021 +0000
description:
make: do not expand the variable name in the ':_' modifier
This edge case had been so obscure that even discovering this takes
quite some time and requires reading the source code of make.
The manual page doesn't document whether the variable name is expanded
or not, it doesn't even give an example. When this obscure modifier was
initially added in var.c 1.210 from 2017-01-30, Var_Set always expanded
the variable name once, and there was no way around it. Therefore this
expansion has probably been unintentional.
diffstat:
usr.bin/make/unit-tests/varmod-remember.mk | 7 +++++--
usr.bin/make/var.c | 12 +++---------
2 files changed, 8 insertions(+), 11 deletions(-)
diffs (57 lines):
diff -r 23fde9d43e76 -r 7924935393c3 usr.bin/make/unit-tests/varmod-remember.mk
--- a/usr.bin/make/unit-tests/varmod-remember.mk Sun Mar 14 17:14:15 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-remember.mk Sun Mar 14 17:27:27 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-remember.mk,v 1.5 2021/03/14 17:14:15 rillig Exp $
+# $NetBSD: varmod-remember.mk,v 1.6 2021/03/14 17:27:27 rillig Exp $
#
# Tests for the :_ modifier, which saves the current variable value
# in the _ variable or another, to be used later again.
@@ -22,10 +22,13 @@
# oversight than an intended feature. The variable name stops at the first
# '}' or ')' and thus cannot use the usual form ${VARNAME} of long variable
# names.
+#
+# Because of all these edge-casey conditions, this "feature" has been removed
+# in var.c 1.867 from 2021-03-14.
S= INDIRECT_VARNAME
.if ${value:L:@var@${var:_=$S}@} != "value"
. error
-.elif ${INDIRECT_VARNAME} != "value"
+.elif defined(INDIRECT_VARNAME)
. error
.endif
diff -r 23fde9d43e76 -r 7924935393c3 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Mar 14 17:14:15 2021 +0000
+++ b/usr.bin/make/var.c Sun Mar 14 17:27:27 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.866 2021/03/14 16:43:30 rillig Exp $ */
+/* $NetBSD: var.c,v 1.867 2021/03/14 17:27:27 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.866 2021/03/14 16:43:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.867 2021/03/14 17:27:27 rillig Exp $");
typedef enum VarFlags {
VFL_NONE = 0,
@@ -3433,13 +3433,7 @@
if (expr->eflags & VARE_WANTRES) {
char *name = bmake_strldup(mod + 2, n);
-
- /*
- * FIXME: do not expand the variable name here; it
- * would only work for single-character variable names
- * anyway.
- */
- Var_SetExpand(expr->scope, name, expr->value.str);
+ Var_Set(expr->scope, name, expr->value.str);
free(name);
}
} else {
Home |
Main Index |
Thread Index |
Old Index