Module Name: src Committed By: rillig Date: Mon Jan 24 22:59:50 UTC 2022
Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varparse-errors.exp varparse-errors.mk Log Message: tests/make: demonstrate that the 'static' in Var_Parse has an effect To generate a diff of this commit: cvs rdiff -u -r1.1004 -r1.1005 src/usr.bin/make/var.c cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varparse-errors.exp \ src/usr.bin/make/unit-tests/varparse-errors.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.1004 src/usr.bin/make/var.c:1.1005 --- src/usr.bin/make/var.c:1.1004 Mon Jan 24 20:54:54 2022 +++ src/usr.bin/make/var.c Mon Jan 24 22:59:49 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1004 2022/01/24 20:54:54 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1005 2022/01/24 22:59:49 rillig 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.1004 2022/01/24 20:54:54 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1005 2022/01/24 22:59:49 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -4704,7 +4704,7 @@ Var_Subst(const char *str, GNode *scope, * Set true if an error has already been reported, to prevent a * plethora of messages when recursing */ - /* XXX: Why is the 'static' necessary here? */ + /* See varparse-errors.mk for why the 'static' is necessary here. */ static bool errorReported; Buf_Init(&res); Index: src/usr.bin/make/unit-tests/varparse-errors.exp diff -u src/usr.bin/make/unit-tests/varparse-errors.exp:1.4 src/usr.bin/make/unit-tests/varparse-errors.exp:1.5 --- src/usr.bin/make/unit-tests/varparse-errors.exp:1.4 Tue Feb 23 15:19:41 2021 +++ src/usr.bin/make/unit-tests/varparse-errors.exp Mon Jan 24 22:59:49 2022 @@ -1,5 +1,11 @@ make: "varparse-errors.mk" line 38: Unknown modifier "Z" make: "varparse-errors.mk" line 46: Unknown modifier "Z" +make: Bad modifier ":OX" for variable "" +make: "varparse-errors.mk" line 68: Undefined variable "${:U:OX" +make: Bad modifier ":OX" for variable "" +make: Bad modifier ":OX" for variable "" +make: "varparse-errors.mk" line 68: Undefined variable "${:U:OX" +make: Bad modifier ":OX" for variable "" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varparse-errors.mk diff -u src/usr.bin/make/unit-tests/varparse-errors.mk:1.4 src/usr.bin/make/unit-tests/varparse-errors.mk:1.5 --- src/usr.bin/make/unit-tests/varparse-errors.mk:1.4 Mon Mar 15 12:15:03 2021 +++ src/usr.bin/make/unit-tests/varparse-errors.mk Mon Jan 24 22:59:49 2022 @@ -1,4 +1,4 @@ -# $NetBSD: varparse-errors.mk,v 1.4 2021/03/15 12:15:03 rillig Exp $ +# $NetBSD: varparse-errors.mk,v 1.5 2022/01/24 22:59:49 rillig Exp $ # Tests for parsing and evaluating all kinds of variable expressions. # @@ -48,4 +48,24 @@ VAR.${:U:Z}post= unknown modifier with t . error .endif +# Demonstrate an edge case in which the 'static' for 'errorReported' in +# Var_Subst actually makes a difference, preventing "a plethora of messages". +# Given that this is an edge case and the error message is wrong and thus +# misleading anyway, that piece of code is probably not necessary. The wrong +# condition was added in var.c 1.185 from 2014-05-19. +# +# To trigger this difference, the variable assignment must use the assignment +# operator ':=' to make VarEvalMode_ShouldKeepUndef return true. There must +# be 2 expressions that create a parse error, which in this case is ':OX'. +# These expressions must be nested in some way. The below expressions are +# minimal, that is, removing any part of it destroys the effect. +# +# Without the 'static', there would be one more message like this: +# Undefined variable "${:U:OX" +# +#.MAKEFLAGS: -dv +IND= ${:OX} +_:= ${:U:OX:U${IND}} ${:U:OX:U${IND}} +#.MAKEFLAGS: -d0 + all: