Module Name: src Committed By: rillig Date: Sat Mar 29 11:24:35 UTC 2025
Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: moderrs.exp varmod-indirect.exp varmod.exp Log Message: make: add details about indirect modifiers to the stack traces Previously, the error message "Unfinished modifier (',' missing)" from moderrs.mk didn't provide enough context to understand where and why the comma was missing. To generate a diff of this commit: cvs rdiff -u -r1.1146 -r1.1147 src/usr.bin/make/var.c cvs rdiff -u -r1.46 -r1.47 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/unit-tests/varmod-indirect.exp cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod.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.1146 src/usr.bin/make/var.c:1.1147 --- src/usr.bin/make/var.c:1.1146 Sat Mar 29 10:39:48 2025 +++ src/usr.bin/make/var.c Sat Mar 29 11:24:34 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1146 2025/03/29 10:39:48 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1147 2025/03/29 11:24:34 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -128,7 +128,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1146 2025/03/29 10:39:48 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1147 2025/03/29 11:24:34 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -259,6 +259,7 @@ typedef enum { VSK_TARGET, VSK_COMMAND, VSK_VARNAME, + VSK_INDIRECT_MODIFIERS, VSK_COND, VSK_COND_THEN, VSK_COND_ELSE, @@ -379,6 +380,7 @@ EvalStack_PrintDetails(void) "in target", "in command", "while evaluating variable", + "while evaluating indirect modifiers", "while evaluating condition", "while evaluating then-branch of condition", "while evaluating else-branch of condition", @@ -3960,7 +3962,9 @@ ApplyModifiersIndirect(ModChain *ch, con if (ModChain_ShouldEval(ch) && mods.str[0] != '\0') { const char *modsp = mods.str; + EvalStack_Push(VSK_INDIRECT_MODIFIERS, mods.str, NULL); ApplyModifiers(expr, &modsp, '\0', '\0'); + EvalStack_Pop(); if (Expr_Str(expr) == var_Error || *modsp != '\0') { FStr_Done(&mods); *pp = p; Index: src/usr.bin/make/unit-tests/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.46 src/usr.bin/make/unit-tests/moderrs.exp:1.47 --- src/usr.bin/make/unit-tests/moderrs.exp:1.46 Sat Mar 29 10:39:48 2025 +++ src/usr.bin/make/unit-tests/moderrs.exp Sat Mar 29 11:24:34 2025 @@ -3,6 +3,7 @@ make: Unknown modifier "Z" in command "@echo 'VAR:Z=before-${VAR:Z}-after'" in target "mod-unknown-direct" make: Unknown modifier "Z" + while evaluating indirect modifiers "Z" while evaluating variable "VAR" with value "TheVariable" in command "@echo 'VAR:${MOD_UNKN}=before-${VAR:${MOD_UNKN}:inner}-after'" in target "mod-unknown-indirect" @@ -15,6 +16,7 @@ make: Unclosed expression after indirect in command "@echo VAR:${MOD_TERM},=${VAR:${MOD_S}" in target "unclosed-indirect" make: Unfinished modifier (',' missing) + while evaluating indirect modifiers "S,V,v" while evaluating variable "VAR" with value "TheVariable" in command "-@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}"" in target "unfinished-indirect" Index: src/usr.bin/make/unit-tests/varmod-indirect.exp diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.31 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.32 --- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.31 Thu Oct 31 09:12:13 2024 +++ src/usr.bin/make/unit-tests/varmod-indirect.exp Sat Mar 29 11:24:34 2025 @@ -10,6 +10,7 @@ make: "varmod-indirect.mk" line 151: aft make: "varmod-indirect.mk" line 159: before make: "varmod-indirect.mk" line 159: after make: "varmod-indirect.mk" line 164: Unknown modifier "Z" + while evaluating indirect modifiers "Z" while evaluating variable "UNDEF" with value "" make: "varmod-indirect.mk" line 167: before make: "varmod-indirect.mk" line 167: after @@ -35,6 +36,7 @@ Var_Parse: ${UNDEF:${:UZ}} after (eval-k Indirect modifier "Z" from "${:UZ}" Evaluating modifier ${UNDEF:Z} on value "" (eval-keep-dollar-and-undefined, undefined) make: "varmod-indirect.mk" line 195: Unknown modifier "Z" + while evaluating indirect modifiers "Z" while evaluating variable "UNDEF" with value "" Result of ${UNDEF:Z} is error (eval-keep-dollar-and-undefined, undefined) Global: _ = before ${UNDEF:Z} after Index: src/usr.bin/make/unit-tests/varmod.exp diff -u src/usr.bin/make/unit-tests/varmod.exp:1.18 src/usr.bin/make/unit-tests/varmod.exp:1.19 --- src/usr.bin/make/unit-tests/varmod.exp:1.18 Sat Jan 11 20:54:46 2025 +++ src/usr.bin/make/unit-tests/varmod.exp Sat Mar 29 11:24:34 2025 @@ -12,6 +12,7 @@ make: "varmod.mk" line 128: Bad modifier make: "varmod.mk" line 134: Invalid number "99333000222000111000}" for ':range' modifier while evaluating variable "word" with value "word" make: "varmod.mk" line 141: Invalid time value "\" + while evaluating indirect modifiers "gmtime=\" while evaluating "${:${:Ugmtime=\\}}" with value "" make: "varmod.mk" line 156: Dollar followed by nothing while evaluating variable "VAR" with value "value$"