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: ApplyModifier_Remember always use SCOPE_G...
details: https://anonhg.NetBSD.org/src/rev/de2855a1589a
branches: trunk
changeset: 373430:de2855a1589a
user: sjg <sjg%NetBSD.org@localhost>
date: Thu Feb 09 07:34:15 2023 +0000
description:
make: ApplyModifier_Remember always use SCOPE_GLOBAL
Conditionals evaluate vars with SCOPE_CMDLINE, if :_
is used within a conditional expression and is thus
set in SCOPE_CMDLINE, it breaks any use of :_ in SCOPE_GLOBAL.
The simplest solution is for :_ to always use SCOPE_GLOBAL
Reviewed by: rillig
diffstat:
usr.bin/make/unit-tests/varmod-remember.mk | 14 +++++++++++++-
usr.bin/make/var.c | 6 +++---
2 files changed, 16 insertions(+), 4 deletions(-)
diffs (57 lines):
diff -r 02cf7dd772e4 -r de2855a1589a usr.bin/make/unit-tests/varmod-remember.mk
--- a/usr.bin/make/unit-tests/varmod-remember.mk Wed Feb 08 15:52:46 2023 +0000
+++ b/usr.bin/make/unit-tests/varmod-remember.mk Thu Feb 09 07:34:15 2023 +0000
@@ -1,8 +1,14 @@
-# $NetBSD: varmod-remember.mk,v 1.6 2021/03/14 17:27:27 rillig Exp $
+# $NetBSD: varmod-remember.mk,v 1.7 2023/02/09 07:34:15 sjg Exp $
#
# Tests for the :_ modifier, which saves the current variable value
# in the _ variable or another, to be used later again.
+# this should result in "1=A 2=B 3=C"
+ABC= ${A B C:L:_:range:@i@$i=${_:[$i]}@}
+
+# we compare this with a repeat later
+x:= ${ABC}
+
.if ${1 2 3:L:_:@var@${_}@} != "1 2 3 1 2 3 1 2 3"
. error
.endif
@@ -32,4 +38,10 @@
. error
.endif
+# we *should* get the same result as for $x above
+X:= ${ABC}
+.if $X != $x
+. error
+.endif
+
all:
diff -r 02cf7dd772e4 -r de2855a1589a usr.bin/make/var.c
--- a/usr.bin/make/var.c Wed Feb 08 15:52:46 2023 +0000
+++ b/usr.bin/make/var.c Thu Feb 09 07:34:15 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.1039 2023/01/26 20:48:17 sjg Exp $ */
+/* $NetBSD: var.c,v 1.1040 2023/02/09 07:34:15 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1039 2023/01/26 20:48:17 sjg Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1040 2023/02/09 07:34:15 sjg Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -3578,7 +3578,7 @@
*pp = mod + 1;
if (Expr_ShouldEval(expr))
- Var_Set(expr->scope, name.str, Expr_Str(expr));
+ Var_Set(SCOPE_GLOBAL, name.str, Expr_Str(expr));
FStr_Done(&name);
return AMR_OK;
Home |
Main Index |
Thread Index |
Old Index