Module Name: src Committed By: rillig Date: Sat Mar 26 14:34:07 UTC 2022
Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: directive.exp opt-debug-graph1.exp opt-debug-graph2.exp opt-debug-graph3.exp opt-debug-var.exp suff-main-several.exp suff-transform-debug.exp var-scope-local.exp vardebug.exp varmod-assign-shell.exp varmod-defined.exp varmod-indirect.exp varmod-shell.exp varmod-sun-shell.exp varname-dot-shell.exp varname-dot-suffixes.exp varname-empty.exp Log Message: make: avoid trailing whitespace in debug log for variables Since trailing whitespace is invisible, describe the variable value in words to make it visible. To generate a diff of this commit: cvs rdiff -u -r1.1017 -r1.1018 src/usr.bin/make/var.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/opt-debug-graph1.exp cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-debug-graph2.exp \ src/usr.bin/make/unit-tests/opt-debug-graph3.exp \ src/usr.bin/make/unit-tests/suff-transform-debug.exp \ src/usr.bin/make/unit-tests/varmod-shell.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-debug-var.exp \ src/usr.bin/make/unit-tests/varmod-sun-shell.exp \ src/usr.bin/make/unit-tests/varname-dot-suffixes.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/suff-main-several.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-scope-local.exp \ src/usr.bin/make/unit-tests/varmod-assign-shell.exp cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/unit-tests/vardebug.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-defined.exp cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-indirect.exp cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varname-dot-shell.exp cvs rdiff -u -r1.19 -r1.20 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.1017 src/usr.bin/make/var.c:1.1018 --- src/usr.bin/make/var.c:1.1017 Sat Mar 26 14:17:46 2022 +++ src/usr.bin/make/var.c Sat Mar 26 14:34:07 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1017 2022/03/26 14:17:46 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1018 2022/03/26 14:34:07 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.1017 2022/03/26 14:17:46 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1018 2022/03/26 14:34:07 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -471,6 +471,16 @@ VarFreeShortLived(Var *v) free(v); } +static const char * +ValueDescription(const char *value) +{ + if (value[0] == '\0') + return "# (empty)"; + if (ch_isspace(value[strlen(value)-1])) + return "# (ends with space)"; + return ""; +} + /* Add a new variable of the given name and value to the given scope. */ static Var * VarAdd(const char *name, const char *value, GNode *scope, VarSetFlags flags) @@ -479,7 +489,8 @@ VarAdd(const char *name, const char *val Var *v = VarNew(FStr_InitRefer(/* aliased to */ he->key), value, false, false, (flags & VAR_SET_READONLY) != 0); HashEntry_Set(he, v); - DEBUG3(VAR, "%s: %s = %s\n", scope->name, name, value); + DEBUG4(VAR, "%s: %s = %s%s\n", + scope->name, name, value, ValueDescription(value)); return v; } @@ -979,7 +990,8 @@ Var_SetWithFlags(GNode *scope, const cha Buf_Clear(&v->val); Buf_AddStr(&v->val, val); - DEBUG3(VAR, "%s: %s = %s\n", scope->name, name, val); + DEBUG4(VAR, "%s: %s = %s%s\n", + scope->name, name, val, ValueDescription(val)); if (v->exported) ExportVar(name, VEM_PLAIN); } @@ -4782,7 +4794,8 @@ Var_Dump(GNode *scope) for (i = 0; i < vec.len; i++) { const char *varname = varnames[i]; Var *var = HashTable_FindValue(&scope->vars, varname); - debug_printf("%-16s = %s\n", varname, var->val.data); + debug_printf("%-16s = %s%s\n", varname, + var->val.data, ValueDescription(var->val.data)); } Vector_Done(&vec); Index: src/usr.bin/make/unit-tests/directive.exp diff -u src/usr.bin/make/unit-tests/directive.exp:1.6 src/usr.bin/make/unit-tests/directive.exp:1.7 --- src/usr.bin/make/unit-tests/directive.exp:1.6 Sun Jan 23 16:09:38 2022 +++ src/usr.bin/make/unit-tests/directive.exp Sat Mar 26 14:34:07 2022 @@ -2,7 +2,7 @@ make: "directive.mk" line 10: Unknown di make: "directive.mk" line 12: Unknown directive "indented" make: "directive.mk" line 14: Unknown directive "indented" make: "directive.mk" line 21: Unknown directive "info" -Global: .info = +Global: .info = # (empty) Global: .info = value make: "directive.mk" line 33: := value Global: .MAKEFLAGS = -r -k -d v -d Index: src/usr.bin/make/unit-tests/opt-debug-graph1.exp diff -u src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.9 src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.10 --- src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.9 Tue Feb 2 17:56:31 2021 +++ src/usr.bin/make/unit-tests/opt-debug-graph1.exp Sat Mar 26 14:34:07 2022 @@ -16,8 +16,8 @@ #*** Global Variables: .ALLTARGETS = all made-target made-target-no-sources made-source unmade-target unmade-sources unmade-silent-source unmade-target-no-sources .CURDIR = <curdir> -.INCLUDES = -.LIBS = +.INCLUDES = # (empty) +.LIBS = # (empty) .MAKE = <details omitted> .MAKE.DEPENDFILE = <details omitted> .MAKE.GID = <details omitted> @@ -30,12 +30,12 @@ .MAKE.PPID = <details omitted> .MAKE.UID = <details omitted> .MAKEFLAGS = -r -k -d g1 -.MAKEOVERRIDES = +.MAKEOVERRIDES = # (empty) .OBJDIR = <curdir> .PATH = . <curdir> -.TARGETS = +.TARGETS = # (empty) .newline = - +# (ends with space) MACHINE = <details omitted> MACHINE_ARCH = <details omitted> MAKE = <details omitted> Index: src/usr.bin/make/unit-tests/opt-debug-graph2.exp diff -u src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.4 src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.5 --- src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.4 Tue Feb 2 17:56:31 2021 +++ src/usr.bin/make/unit-tests/opt-debug-graph2.exp Sat Mar 26 14:34:07 2022 @@ -50,8 +50,8 @@ all : made-target error-targ #*** Global Variables: .ALLTARGETS = made-target error-target aborted-target aborted-target-dependency all .END .CURDIR = <curdir> -.INCLUDES = -.LIBS = +.INCLUDES = # (empty) +.LIBS = # (empty) .MAKE = <details omitted> .MAKE.DEPENDFILE = <details omitted> .MAKE.GID = <details omitted> @@ -64,12 +64,12 @@ all : made-target error-targ .MAKE.PPID = <details omitted> .MAKE.UID = <details omitted> .MAKEFLAGS = -r -k -d g2 -.MAKEOVERRIDES = +.MAKEOVERRIDES = # (empty) .OBJDIR = <curdir> .PATH = . <curdir> .TARGETS = all .newline = - +# (ends with space) MACHINE = <details omitted> MACHINE_ARCH = <details omitted> MAKE = <details omitted> Index: src/usr.bin/make/unit-tests/opt-debug-graph3.exp diff -u src/usr.bin/make/unit-tests/opt-debug-graph3.exp:1.4 src/usr.bin/make/unit-tests/opt-debug-graph3.exp:1.5 --- src/usr.bin/make/unit-tests/opt-debug-graph3.exp:1.4 Tue Feb 2 17:56:31 2021 +++ src/usr.bin/make/unit-tests/opt-debug-graph3.exp Sat Mar 26 14:34:07 2022 @@ -50,8 +50,8 @@ all : made-target error-targ #*** Global Variables: .ALLTARGETS = made-target error-target aborted-target aborted-target-dependency all .END .CURDIR = <curdir> -.INCLUDES = -.LIBS = +.INCLUDES = # (empty) +.LIBS = # (empty) .MAKE = <details omitted> .MAKE.DEPENDFILE = <details omitted> .MAKE.GID = <details omitted> @@ -64,12 +64,12 @@ all : made-target error-targ .MAKE.PPID = <details omitted> .MAKE.UID = <details omitted> .MAKEFLAGS = -r -k -d g3 -.MAKEOVERRIDES = +.MAKEOVERRIDES = # (empty) .OBJDIR = <curdir> .PATH = . <curdir> .TARGETS = all .newline = - +# (ends with space) MACHINE = <details omitted> MACHINE_ARCH = <details omitted> MAKE = <details omitted> Index: src/usr.bin/make/unit-tests/suff-transform-debug.exp diff -u src/usr.bin/make/unit-tests/suff-transform-debug.exp:1.4 src/usr.bin/make/unit-tests/suff-transform-debug.exp:1.5 --- src/usr.bin/make/unit-tests/suff-transform-debug.exp:1.4 Tue Feb 2 17:56:31 2021 +++ src/usr.bin/make/unit-tests/suff-transform-debug.exp Sat Mar 26 14:34:07 2022 @@ -7,8 +7,8 @@ #*** Global Variables: .ALLTARGETS = all .CURDIR = <curdir> -.INCLUDES = -.LIBS = +.INCLUDES = # (empty) +.LIBS = # (empty) .MAKE = <details omitted> .MAKE.DEPENDFILE = <details omitted> .MAKE.GID = <details omitted> @@ -21,12 +21,12 @@ .MAKE.PPID = <details omitted> .MAKE.UID = <details omitted> .MAKEFLAGS = -r -k -d g1 -.MAKEOVERRIDES = +.MAKEOVERRIDES = # (empty) .OBJDIR = <curdir> .PATH = . <curdir> -.TARGETS = +.TARGETS = # (empty) .newline = - +# (ends with space) MACHINE = <details omitted> MACHINE_ARCH = <details omitted> MAKE = <details omitted> Index: src/usr.bin/make/unit-tests/varmod-shell.exp diff -u src/usr.bin/make/unit-tests/varmod-shell.exp:1.4 src/usr.bin/make/unit-tests/varmod-shell.exp:1.5 --- src/usr.bin/make/unit-tests/varmod-shell.exp:1.4 Mon Jan 10 20:32:29 2022 +++ src/usr.bin/make/unit-tests/varmod-shell.exp Sat Mar 26 14:34:07 2022 @@ -1,6 +1,6 @@ make: "echo word; false" returned non-zero status make: "echo word; false" returned non-zero status -Global: _ = +Global: _ = # (empty) Var_Parse: ${:!echo word; ${:Ufalse}!} (eval-keep-dollar-and-undefined) Evaluating modifier ${:!...} on value "" (eval-keep-dollar-and-undefined, undefined) Modifier part: "echo word; false" Index: src/usr.bin/make/unit-tests/opt-debug-var.exp diff -u src/usr.bin/make/unit-tests/opt-debug-var.exp:1.2 src/usr.bin/make/unit-tests/opt-debug-var.exp:1.3 --- src/usr.bin/make/unit-tests/opt-debug-var.exp:1.2 Sun Jan 23 16:09:38 2022 +++ src/usr.bin/make/unit-tests/opt-debug-var.exp Sat Mar 26 14:34:07 2022 @@ -1,5 +1,5 @@ Global: ASSIGNED = value -Global: SUBST = +Global: SUBST = # (empty) Global: SUBST = value Var_Parse: y(ASSIGNED) (eval) Global: .MAKEFLAGS = -r -k -d v -d Index: src/usr.bin/make/unit-tests/varmod-sun-shell.exp diff -u src/usr.bin/make/unit-tests/varmod-sun-shell.exp:1.2 src/usr.bin/make/unit-tests/varmod-sun-shell.exp:1.3 --- src/usr.bin/make/unit-tests/varmod-sun-shell.exp:1.2 Mon Jan 10 20:32:29 2022 +++ src/usr.bin/make/unit-tests/varmod-sun-shell.exp Sat Mar 26 14:34:07 2022 @@ -1,5 +1,5 @@ make: "echo word; false" returned non-zero status -Global: _ = +Global: _ = # (empty) Var_Parse: ${echo word; ${:Ufalse}:L:sh} (eval-keep-dollar-and-undefined) Evaluating modifier ${echo word; false:L} on value "" (eval-keep-dollar-and-undefined, undefined) Result of ${echo word; false:L} is "echo word; false" (eval-keep-dollar-and-undefined, defined) Index: src/usr.bin/make/unit-tests/varname-dot-suffixes.exp diff -u src/usr.bin/make/unit-tests/varname-dot-suffixes.exp:1.2 src/usr.bin/make/unit-tests/varname-dot-suffixes.exp:1.3 --- src/usr.bin/make/unit-tests/varname-dot-suffixes.exp:1.2 Sat Mar 26 14:17:46 2022 +++ src/usr.bin/make/unit-tests/varname-dot-suffixes.exp Sat Mar 26 14:34:07 2022 @@ -3,13 +3,13 @@ Global: .MAKEFLAGS = -r -k -d v -d Global: .MAKEFLAGS = -r -k -d v -d 0 Global: .SUFFIXES = set ignored (read-only) Global: .SUFFIXES = append ignored (read-only) -Global: _ = +Global: _ = # (empty) Var_Parse: ${.SUFFIXES::=assign} (eval-keep-dollar-and-undefined) Evaluating modifier ${.SUFFIXES::...} on value ".c .o .1 .err .tar.gz" (eval-keep-dollar-and-undefined, regular) Modifier part: "assign" Global: .SUFFIXES = assign ignored (read-only) Result of ${.SUFFIXES::=assign} is "" (eval-keep-dollar-and-undefined, regular) -Global: _ = +Global: _ = # (empty) Var_Parse: ${preserve:L:_=.SUFFIXES} (eval-keep-dollar-and-undefined) Evaluating modifier ${preserve:L} on value "" (eval-keep-dollar-and-undefined, undefined) Result of ${preserve:L} is "preserve" (eval-keep-dollar-and-undefined, defined) Index: src/usr.bin/make/unit-tests/suff-main-several.exp diff -u src/usr.bin/make/unit-tests/suff-main-several.exp:1.7 src/usr.bin/make/unit-tests/suff-main-several.exp:1.8 --- src/usr.bin/make/unit-tests/suff-main-several.exp:1.7 Tue Dec 28 15:49:00 2021 +++ src/usr.bin/make/unit-tests/suff-main-several.exp Sat Mar 26 14:34:07 2022 @@ -81,8 +81,8 @@ ParseDependency(.MAKEFLAGS: -d0 -dg1) #*** Global Variables: .ALLTARGETS = .1.2 .1.3 .1.4 next-main suff-main-several.1 suff-main-several.{2,3,4} .CURDIR = <curdir> -.INCLUDES = -.LIBS = +.INCLUDES = # (empty) +.LIBS = # (empty) .MAKE = <details omitted> .MAKE.DEPENDFILE = <details omitted> .MAKE.GID = <details omitted> @@ -95,12 +95,12 @@ ParseDependency(.MAKEFLAGS: -d0 -dg1) .MAKE.PPID = <details omitted> .MAKE.UID = <details omitted> .MAKEFLAGS = -r -k -d mps -d 0 -d g1 -.MAKEOVERRIDES = +.MAKEOVERRIDES = # (empty) .OBJDIR = <curdir> .PATH = . <curdir> -.TARGETS = +.TARGETS = # (empty) .newline = - +# (ends with space) MACHINE = <details omitted> MACHINE_ARCH = <details omitted> MAKE = <details omitted> Index: src/usr.bin/make/unit-tests/var-scope-local.exp diff -u src/usr.bin/make/unit-tests/var-scope-local.exp:1.3 src/usr.bin/make/unit-tests/var-scope-local.exp:1.4 --- src/usr.bin/make/unit-tests/var-scope-local.exp:1.3 Sat Jan 29 00:52:53 2022 +++ src/usr.bin/make/unit-tests/var-scope-local.exp Sat Mar 26 14:34:07 2022 @@ -3,7 +3,7 @@ Global: .ALLTARGETS = one two Var_Parse: ${.MAKE.TARGET_LOCAL_VARIABLES} (eval) Var_SetExpand: variable name "" expands to empty string, with value "three" - ignored Var_SetExpand: variable name "" expands to empty string, with value "three" - ignored -Global: one two = +Global: one two = # (empty) Global: one two = three Global: .MAKEFLAGS = -r -k -d v -d Global: .MAKEFLAGS = -r -k -d v -d 0 Index: src/usr.bin/make/unit-tests/varmod-assign-shell.exp diff -u src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.3 src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.4 --- src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.3 Mon Jan 10 20:32:29 2022 +++ src/usr.bin/make/unit-tests/varmod-assign-shell.exp Sat Mar 26 14:34:07 2022 @@ -1,12 +1,12 @@ make: "varmod-assign-shell.mk" line 27: warning: "echo output; false" returned non-zero status -Global: _ = +Global: _ = # (empty) Var_Parse: ${ASSIGNED::!=echo output; ${:Ufalse}} (eval-keep-dollar-and-undefined) Evaluating modifier ${ASSIGNED::...} on value "previous" (eval-keep-dollar-and-undefined, regular) Modifier part: "echo output; false" Capturing the output of command "echo output; false" make: "echo output; false" returned non-zero status Result of ${ASSIGNED::!=echo output; ${:Ufalse}} is "" (eval-keep-dollar-and-undefined, regular) -Global: _ = +Global: _ = # (empty) Global: .MAKEFLAGS = -r -k -d v -d Global: .MAKEFLAGS = -r -k -d v -d 0 DIRECT=output Index: src/usr.bin/make/unit-tests/vardebug.exp diff -u src/usr.bin/make/unit-tests/vardebug.exp:1.28 src/usr.bin/make/unit-tests/vardebug.exp:1.29 --- src/usr.bin/make/unit-tests/vardebug.exp:1.28 Sat Mar 26 14:17:46 2022 +++ src/usr.bin/make/unit-tests/vardebug.exp Sat Mar 26 14:34:07 2022 @@ -1,5 +1,5 @@ Global: delete FROM_CMDLINE (not found) -Command: FROM_CMDLINE = +Command: FROM_CMDLINE = # (empty) Global: .MAKEOVERRIDES = FROM_CMDLINE Global: VAR = added Global: VAR = overwritten Index: src/usr.bin/make/unit-tests/varmod-defined.exp diff -u src/usr.bin/make/unit-tests/varmod-defined.exp:1.10 src/usr.bin/make/unit-tests/varmod-defined.exp:1.11 --- src/usr.bin/make/unit-tests/varmod-defined.exp:1.10 Sat Mar 26 14:17:46 2022 +++ src/usr.bin/make/unit-tests/varmod-defined.exp Sat Mar 26 14:34:07 2022 @@ -1,5 +1,5 @@ Global: 8_DOLLARS = $$$$$$$$ -Global: VAR = +Global: VAR = # (empty) Var_Parse: ${8_DOLLARS} (eval-keep-dollar-and-undefined) Global: VAR = $$$$$$$$ Var_Parse: ${VAR:D${8_DOLLARS}} (eval-keep-dollar-and-undefined) Index: src/usr.bin/make/unit-tests/varmod-indirect.exp diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.21 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.22 --- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.21 Sat Jan 8 20:21:34 2022 +++ src/usr.bin/make/unit-tests/varmod-indirect.exp Sat Mar 26 14:34:07 2022 @@ -11,7 +11,7 @@ make: "varmod-indirect.mk" line 156: Unk make: "varmod-indirect.mk" line 157: before make: "varmod-indirect.mk" line 157: after Parsing line 166: _:= before ${UNDEF} after -Global: _ = +Global: _ = # (empty) Var_Parse: ${UNDEF} after (eval-keep-dollar-and-undefined) Global: _ = before ${UNDEF} after Parsing line 169: _:= before ${UNDEF:${:US,a,a,}} after Index: src/usr.bin/make/unit-tests/varname-dot-shell.exp diff -u src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.15 src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.16 --- src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.15 Sat Mar 26 14:17:46 2022 +++ src/usr.bin/make/unit-tests/varname-dot-shell.exp Sat Mar 26 14:34:07 2022 @@ -1,5 +1,5 @@ Parsing line 10: ORIG_SHELL:= ${.SHELL} -Global: ORIG_SHELL = +Global: ORIG_SHELL = # (empty) Var_Parse: ${.SHELL} (eval-keep-dollar-and-undefined) Global: delete .SHELL (not found) Command: .SHELL = (details omitted) Index: src/usr.bin/make/unit-tests/varname-empty.exp diff -u src/usr.bin/make/unit-tests/varname-empty.exp:1.19 src/usr.bin/make/unit-tests/varname-empty.exp:1.20 --- src/usr.bin/make/unit-tests/varname-empty.exp:1.19 Sat Mar 26 14:17:46 2022 +++ src/usr.bin/make/unit-tests/varname-empty.exp Sat Mar 26 14:34:07 2022 @@ -2,7 +2,7 @@ Var_SetExpand: variable name "${:U}" exp Var_SetExpand: variable name "" expands to empty string, with value "cmdline-plain" - ignored Global: .CURDIR = <curdir> Var_Parse: ${MAKE_OBJDIR_CHECK_WRITABLE} (eval) -Global: .TARGETS = +Global: .TARGETS = # (empty) Internal: MAKEFILE = varname-empty.mk Global: .MAKE.MAKEFILES = varname-empty.mk Global: .PARSEFILE = varname-empty.mk