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
This commit is contained in:
parent
3244fba725
commit
3c0f6ebb0e
|
@ -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
|
# Tests for the :_ modifier, which saves the current variable value
|
||||||
# in the _ variable or another, to be used later again.
|
# 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"
|
.if ${1 2 3:L:_:@var@${_}@} != "1 2 3 1 2 3 1 2 3"
|
||||||
. error
|
. error
|
||||||
.endif
|
.endif
|
||||||
|
@ -32,4 +38,10 @@ S= INDIRECT_VARNAME
|
||||||
. error
|
. error
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
|
# we *should* get the same result as for $x above
|
||||||
|
X:= ${ABC}
|
||||||
|
.if $X != $x
|
||||||
|
. error
|
||||||
|
.endif
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
|
@ -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
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
#include "metachar.h"
|
#include "metachar.h"
|
||||||
|
|
||||||
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
|
/* "@(#)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
|
* Variables are defined using one of the VAR=value assignments. Their
|
||||||
|
@ -3578,7 +3578,7 @@ ApplyModifier_Remember(const char **pp, ModChain *ch)
|
||||||
*pp = mod + 1;
|
*pp = mod + 1;
|
||||||
|
|
||||||
if (Expr_ShouldEval(expr))
|
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);
|
FStr_Done(&name);
|
||||||
|
|
||||||
return AMR_OK;
|
return AMR_OK;
|
||||||
|
|
Loading…
Reference in New Issue