Module Name:    src
Committed By:   rillig
Date:           Wed Dec 20 08:50:10 UTC 2023

Modified Files:
        src/usr.bin/make: var.c
        src/usr.bin/make/unit-tests: deptgt-makeflags.exp var-readonly.exp
            vardebug.exp varname-dot-shell.exp varname-dot-suffixes.exp
            varname-dot-suffixes.mk varname-empty.exp

Log Message:
make: fix confusing debug logging when deleting a variable

Be clear when deleting a variable is ignored and state the reason,
instead of only providing a keyword as a hint for insiders.


To generate a diff of this commit:
cvs rdiff -u -r1.1084 -r1.1085 src/usr.bin/make/var.c
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/deptgt-makeflags.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-readonly.exp
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/unit-tests/vardebug.exp
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varname-dot-shell.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varname-dot-suffixes.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varname-dot-suffixes.mk
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/varname-empty.exp

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.1084 src/usr.bin/make/var.c:1.1085
--- src/usr.bin/make/var.c:1.1084	Tue Dec 19 19:33:39 2023
+++ src/usr.bin/make/var.c	Wed Dec 20 08:50:10 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1084 2023/12/19 19:33:39 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1085 2023/12/20 08:50:10 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.1084 2023/12/19 19:33:39 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1085 2023/12/20 08:50:10 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -503,15 +503,14 @@ Var_Delete(GNode *scope, const char *var
 	Var *v;
 
 	if (he == NULL) {
-		DEBUG2(VAR, "%s: delete %s (not found)\n",
+		DEBUG2(VAR, "%s: ignoring delete '%s' as it is not found\n",
 		    scope->name, varname);
 		return;
 	}
 
-	DEBUG2(VAR, "%s: delete %s\n", scope->name, varname);
 	v = he->value;
 	if (v->readOnly) {
-		DEBUG2(VAR, "%s: delete %s (readOnly)\n",
+		DEBUG2(VAR, "%s: ignoring delete '%s' as it is read-only\n",
 		    scope->name, varname);
 		return;
 	}
@@ -522,6 +521,7 @@ Var_Delete(GNode *scope, const char *var
 		return;
 	}
 
+	DEBUG2(VAR, "%s: delete %s\n", scope->name, varname);
 	if (v->exported)
 		unsetenv(v->name.str);
 	if (strcmp(v->name.str, ".MAKE.EXPORTED") == 0)

Index: src/usr.bin/make/unit-tests/deptgt-makeflags.exp
diff -u src/usr.bin/make/unit-tests/deptgt-makeflags.exp:1.7 src/usr.bin/make/unit-tests/deptgt-makeflags.exp:1.8
--- src/usr.bin/make/unit-tests/deptgt-makeflags.exp:1.7	Sat Mar 26 14:17:46 2022
+++ src/usr.bin/make/unit-tests/deptgt-makeflags.exp	Wed Dec 20 08:50:10 2023
@@ -1,4 +1,4 @@
-Global: delete DOLLAR (not found)
+Global: ignoring delete 'DOLLAR' as it is not found
 Command: DOLLAR = $$$$
 Global: .MAKEOVERRIDES =  VAR DOLLAR
 CondParser_Eval: ${DOLLAR} != "\$\$"

Index: src/usr.bin/make/unit-tests/var-readonly.exp
diff -u src/usr.bin/make/unit-tests/var-readonly.exp:1.2 src/usr.bin/make/unit-tests/var-readonly.exp:1.3
--- src/usr.bin/make/unit-tests/var-readonly.exp:1.2	Wed Dec 20 08:42:10 2023
+++ src/usr.bin/make/unit-tests/var-readonly.exp	Wed Dec 20 08:50:10 2023
@@ -1,5 +1,4 @@
-Global: delete N
-Global: delete N (readOnly)
+Global: ignoring delete 'N' as it is read-only
 Global: .MAKEFLAGS =  -r -k -d v -d
 Global: .MAKEFLAGS =  -r -k -d v -d 0
 exit status 0

Index: src/usr.bin/make/unit-tests/vardebug.exp
diff -u src/usr.bin/make/unit-tests/vardebug.exp:1.31 src/usr.bin/make/unit-tests/vardebug.exp:1.32
--- src/usr.bin/make/unit-tests/vardebug.exp:1.31	Sun Dec 10 20:17:23 2023
+++ src/usr.bin/make/unit-tests/vardebug.exp	Wed Dec 20 08:50:10 2023
@@ -1,10 +1,10 @@
-Global: delete FROM_CMDLINE (not found)
+Global: ignoring delete 'FROM_CMDLINE' as it is not found
 Command: FROM_CMDLINE = # (empty)
 Global: .MAKEOVERRIDES =  FROM_CMDLINE
 Global: VAR = added
 Global: VAR = overwritten
 Global: delete VAR
-Global: delete VAR (not found)
+Global: ignoring delete 'VAR' as it is not found
 Var_SetExpand: variable name "${:U}" expands to empty string, with value "empty name" - ignored
 Var_AppendExpand: variable name "${:U}" expands to empty string, with value "empty name" - ignored
 Global: ignoring 'FROM_CMDLINE' = 'overwritten' due to a command line variable of the same name
@@ -59,7 +59,7 @@ Result of ${:unknown} is error (eval-def
 make: "vardebug.mk" line 46: Malformed conditional (${:Uvariable:unknown})
 Var_Parse: ${UNDEFINED} (eval-defined)
 make: "vardebug.mk" line 56: Malformed conditional (${UNDEFINED})
-Global: delete .SHELL (not found)
+Global: ignoring delete '.SHELL' as it is not found
 Command: .SHELL = </path/to/shell>
 Command: .SHELL = overwritten ignored (read-only)
 Global: .MAKEFLAGS =  -r -k -d v -d

Index: src/usr.bin/make/unit-tests/varname-dot-shell.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.18 src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.19
--- src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.18	Sun Dec 10 20:17:23 2023
+++ src/usr.bin/make/unit-tests/varname-dot-shell.exp	Wed Dec 20 08:50:10 2023
@@ -1,7 +1,7 @@
 Parsing line 10: ORIG_SHELL:=	${.SHELL}
 Global: ORIG_SHELL = # (empty)
 Var_Parse: ${.SHELL} (eval-keep-dollar-and-undefined)
-Global: delete .SHELL (not found)
+Global: ignoring delete '.SHELL' as it is not found
 Command: .SHELL = (details omitted)
 Global: ORIG_SHELL = (details omitted)
 Parsing line 12: .SHELL=		overwritten
@@ -18,7 +18,7 @@ Var_Parse: ${.SHELL} != ${ORIG_SHELL} (e
 Var_Parse: ${ORIG_SHELL} (eval-defined)
 Comparing "(details omitted)" != "(details omitted)"
 Parsing line 27: .undef .SHELL
-Global: delete .SHELL (not found)
+Global: ignoring delete '.SHELL' as it is not found
 Parsing line 28: .SHELL=		newly overwritten
 Global: ignoring '.SHELL' = 'newly overwritten' due to a command line variable of the same name
 CondParser_Eval: ${.SHELL} != ${ORIG_SHELL}

Index: src/usr.bin/make/unit-tests/varname-dot-suffixes.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-suffixes.exp:1.5 src/usr.bin/make/unit-tests/varname-dot-suffixes.exp:1.6
--- src/usr.bin/make/unit-tests/varname-dot-suffixes.exp:1.5	Tue Aug 23 19:22:01 2022
+++ src/usr.bin/make/unit-tests/varname-dot-suffixes.exp	Wed Dec 20 08:50:10 2023
@@ -1,4 +1,4 @@
-Global: delete .SUFFIXES (not found)
+Global: ignoring delete '.SUFFIXES' as it is not found
 Global: .MAKEFLAGS =  -r -k -d v -d
 Global: .MAKEFLAGS =  -r -k -d v -d 0
 Global: .SUFFIXES = set ignored (read-only)
@@ -32,7 +32,7 @@ ModifyWord_Loop: in "1", replace ".SUFFI
 Command: .SUFFIXES = 2 ignored (read-only)
 Var_Parse: ${.SUFFIXES} (eval-defined)
 ModifyWord_Loop: in "2", replace ".SUFFIXES" with "${.SUFFIXES}" to ".c .o .1 .err .tar.gz"
-Command: delete .SUFFIXES (not found)
+Command: ignoring delete '.SUFFIXES' as it is not found
 Result of ${1 2:@.SUFFIXES@${.SUFFIXES}@} is ".c .o .1 .err .tar.gz .c .o .1 .err .tar.gz" (eval-defined, defined)
 Global: .MAKEFLAGS =  -r -k -d v -d 0 -d v -d 0 -d v -d
 Global: .MAKEFLAGS =  -r -k -d v -d 0 -d v -d 0 -d v -d 0

Index: src/usr.bin/make/unit-tests/varname-dot-suffixes.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-suffixes.mk:1.3 src/usr.bin/make/unit-tests/varname-dot-suffixes.mk:1.4
--- src/usr.bin/make/unit-tests/varname-dot-suffixes.mk:1.3	Fri Apr 15 09:33:20 2022
+++ src/usr.bin/make/unit-tests/varname-dot-suffixes.mk	Wed Dec 20 08:50:10 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varname-dot-suffixes.mk,v 1.3 2022/04/15 09:33:20 rillig Exp $
+# $NetBSD: varname-dot-suffixes.mk,v 1.4 2023/12/20 08:50:10 rillig Exp $
 #
 # Tests for the special "variable" .SUFFIXES, which lists the suffixes that
 # have been registered for use in suffix transformation rules.  Suffixes are
@@ -51,7 +51,7 @@
 # Deleting .SUFFIXES has no effect since there is no actual variable of that
 # name.
 .MAKEFLAGS: -dv
-# expect: Global: delete .SUFFIXES (not found)
+# expect: Global: ignoring delete '.SUFFIXES' as it is not found
 .undef .SUFFIXES
 .MAKEFLAGS: -d0
 .if ${.SUFFIXES} != ".c .o .1 .err .tar.gz"
@@ -96,8 +96,7 @@ _:=		${preserve:L:_=.SUFFIXES}
 .MAKEFLAGS: -dv
 # expect: Command: .SUFFIXES = 1 ignored (read-only)
 # expect: Command: .SUFFIXES = 2 ignored (read-only)
-# XXX: Missing space after ':'
-# expect: Command: delete .SUFFIXES (not found)
+# expect: Command: ignoring delete '.SUFFIXES' as it is not found
 .if ${1 2:L:@.SUFFIXES@${.SUFFIXES}@} != ".c .o .1 .err .tar.gz .c .o .1 .err .tar.gz"
 .  error
 .endif

Index: src/usr.bin/make/unit-tests/varname-empty.exp
diff -u src/usr.bin/make/unit-tests/varname-empty.exp:1.20 src/usr.bin/make/unit-tests/varname-empty.exp:1.21
--- src/usr.bin/make/unit-tests/varname-empty.exp:1.20	Sat Mar 26 14:34:07 2022
+++ src/usr.bin/make/unit-tests/varname-empty.exp	Wed Dec 20 08:50:10 2023
@@ -6,8 +6,8 @@ Global: .TARGETS = # (empty)
 Internal: MAKEFILE = varname-empty.mk
 Global: .MAKE.MAKEFILES = varname-empty.mk
 Global: .PARSEFILE = varname-empty.mk
-Global: delete .INCLUDEDFROMDIR (not found)
-Global: delete .INCLUDEDFROMFILE (not found)
+Global: ignoring delete '.INCLUDEDFROMDIR' as it is not found
+Global: ignoring delete '.INCLUDEDFROMFILE' as it is not found
 Var_SetExpand: variable name "" expands to empty string, with value "default" - ignored
 Var_SetExpand: variable name "" expands to empty string, with value "assigned" - ignored
 SetVar: variable name is empty - ignored

Reply via email to