Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make tests/make: demonstrate that the 'static' in Va...



details:   https://anonhg.NetBSD.org/src/rev/2aff4130912f
branches:  trunk
changeset: 359816:2aff4130912f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jan 24 22:59:49 2022 +0000

description:
tests/make: demonstrate that the 'static' in Var_Parse has an effect

diffstat:

 usr.bin/make/unit-tests/varparse-errors.exp |   6 ++++++
 usr.bin/make/unit-tests/varparse-errors.mk  |  22 +++++++++++++++++++++-
 usr.bin/make/var.c                          |   6 +++---
 3 files changed, 30 insertions(+), 4 deletions(-)

diffs (76 lines):

diff -r 0421c1bd6eea -r 2aff4130912f usr.bin/make/unit-tests/varparse-errors.exp
--- a/usr.bin/make/unit-tests/varparse-errors.exp       Mon Jan 24 20:54:54 2022 +0000
+++ b/usr.bin/make/unit-tests/varparse-errors.exp       Mon Jan 24 22:59:49 2022 +0000
@@ -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
diff -r 0421c1bd6eea -r 2aff4130912f usr.bin/make/unit-tests/varparse-errors.mk
--- a/usr.bin/make/unit-tests/varparse-errors.mk        Mon Jan 24 20:54:54 2022 +0000
+++ b/usr.bin/make/unit-tests/varparse-errors.mk        Mon Jan 24 22:59:49 2022 +0000
@@ -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 @@
 .  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:
diff -r 0421c1bd6eea -r 2aff4130912f usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Jan 24 20:54:54 2022 +0000
+++ b/usr.bin/make/var.c        Mon Jan 24 22:59:49 2022 +0000
@@ -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 @@
         * 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);



Home | Main Index | Thread Index | Old Index