Module Name: src Committed By: rillig Date: Sun Mar 14 17:27:28 UTC 2021
Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-remember.mk Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.866 -r1.867 src/usr.bin/make/var.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-remember.mk 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/var.c diff -u src/usr.bin/make/var.c:1.866 src/usr.bin/make/var.c:1.867 --- src/usr.bin/make/var.c:1.866 Sun Mar 14 16:43:30 2021 +++ src/usr.bin/make/var.c Sun Mar 14 17:27:27 2021 @@ -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 @@ ApplyModifier_Remember(const char **pp, 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 { Index: src/usr.bin/make/unit-tests/varmod-remember.mk diff -u src/usr.bin/make/unit-tests/varmod-remember.mk:1.5 src/usr.bin/make/unit-tests/varmod-remember.mk:1.6 --- src/usr.bin/make/unit-tests/varmod-remember.mk:1.5 Sun Mar 14 17:14:15 2021 +++ src/usr.bin/make/unit-tests/varmod-remember.mk Sun Mar 14 17:27:27 2021 @@ -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