Module Name: src Committed By: rillig Date: Tue Feb 23 15:56:30 UTC 2021
Modified Files: src/usr.bin/make: suff.c var.c src/usr.bin/make/unit-tests: directive-for-escape.exp moderrs.exp moderrs.mk varmisc.exp varmod-edge.exp varmod-edge.mk Log Message: make: improve error message for unclosed modifier Replace "variable specification" with the more modern "variable expression", reduce the number of parentheses, output more than a single character for modifiers, make it obvious that in expressions such as ${:Serror}, the "" means a variable name. To generate a diff of this commit: cvs rdiff -u -r1.345 -r1.346 src/usr.bin/make/suff.c cvs rdiff -u -r1.851 -r1.852 src/usr.bin/make/var.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmisc.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-edge.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/suff.c diff -u src/usr.bin/make/suff.c:1.345 src/usr.bin/make/suff.c:1.346 --- src/usr.bin/make/suff.c:1.345 Fri Feb 5 05:15:12 2021 +++ src/usr.bin/make/suff.c Tue Feb 23 15:56:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.345 2021/02/05 05:15:12 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.346 2021/02/23 15:56:29 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -114,7 +114,7 @@ #include "dir.h" /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ -MAKE_RCSID("$NetBSD: suff.c,v 1.345 2021/02/05 05:15:12 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.346 2021/02/23 15:56:29 rillig Exp $"); typedef List SuffixList; typedef ListNode SuffixListNode; @@ -1282,7 +1282,7 @@ ExpandWildcards(GNodeListNode *cln, GNod * add those nodes to the members list. * * Unfortunately, we can't use Str_Words because it doesn't understand about - * variable specifications with spaces in them. + * variable expressions with spaces in them. */ static void ExpandChildrenRegular(char *cp, GNode *pgn, GNodeList *members) Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.851 src/usr.bin/make/var.c:1.852 --- src/usr.bin/make/var.c:1.851 Tue Feb 23 15:19:41 2021 +++ src/usr.bin/make/var.c Tue Feb 23 15:56:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.851 2021/02/23 15:19:41 rillig Exp $ */ +/* $NetBSD: var.c,v 1.852 2021/02/23 15:56:29 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.851 2021/02/23 15:19:41 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.852 2021/02/23 15:56:29 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -3689,8 +3689,8 @@ ApplyModifiersIndirect(ApplyModifiersSta if (*p == ':') p++; else if (*p == '\0' && st->endc != '\0') { - Error("Unclosed variable specification after complex " - "modifier (expecting '%c') for %s", + Error("Unclosed variable expression after indirect " + "modifier, expecting '%c' for variable \"%s\"", st->endc, expr->var->name.str); *pp = p; return AMIR_OUT; @@ -3742,10 +3742,11 @@ ApplySingleModifier(const char **pp, cha if (*p == '\0' && st->endc != '\0') { Error( - "Unclosed variable specification (expecting '%c') " - "for \"%s\" (value \"%s\") modifier %c", + "Unclosed variable expression, expecting '%c' for " + "modifier \"%.*s\" of variable \"%s\" with value \"%s\"", st->endc, - st->expr->var->name.str, st->expr->value.str, *mod); + (int)(p - mod), mod, + st->expr->var->name.str, st->expr->value.str); } else if (*p == ':') { p++; } else if (opts.strict && *p != '\0' && *p != endc) { Index: src/usr.bin/make/unit-tests/directive-for-escape.exp diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.7 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.8 --- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.7 Mon Feb 15 07:58:19 2021 +++ src/usr.bin/make/unit-tests/directive-for-escape.exp Tue Feb 23 15:56:30 2021 @@ -1,12 +1,12 @@ For: end for 1 For: loop body: . info ${:U!"#$%&'()*+,-./0-9\:;<=>?@A-Z[\\]_^a-z{|\}~} -make: Unclosed variable specification (expecting '}') for "" (value "!"") modifier U +make: Unclosed variable expression, expecting '}' for modifier "U!"" of variable "" with value "!"" make: "directive-for-escape.mk" line 19: !" For: end for 1 For: loop body: . info ${:U!"\\\\#$%&'()*+,-./0-9\:;<=>?@A-Z[\\]_^a-z{|\}~} -make: Unclosed variable specification (expecting '}') for "" (value "!"\\") modifier U +make: Unclosed variable expression, expecting '}' for modifier "U!"\\\\" of variable "" with value "!"\\" make: "directive-for-escape.mk" line 29: !"\\ For: end for 1 For: loop body: Index: src/usr.bin/make/unit-tests/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.26 src/usr.bin/make/unit-tests/moderrs.exp:1.27 --- src/usr.bin/make/unit-tests/moderrs.exp:1.26 Tue Feb 23 15:19:41 2021 +++ src/usr.bin/make/unit-tests/moderrs.exp Tue Feb 23 15:56:30 2021 @@ -9,13 +9,13 @@ make: Unknown modifier "Z" VAR:Z=before-inner}-after unclosed-direct: -want: Unclosed variable specification (expecting '}') for "VAR" (value "Thevariable") modifier S -make: Unclosed variable specification (expecting '}') for "VAR" (value "Thevariable") modifier S +want: Unclosed variable expression, expecting '}' for modifier "S,V,v," of variable "VAR" with value "Thevariable" +make: Unclosed variable expression, expecting '}' for modifier "S,V,v," of variable "VAR" with value "Thevariable" VAR:S,V,v,=Thevariable unclosed-indirect: -want: Unclosed variable specification after complex modifier (expecting '}') for VAR -make: Unclosed variable specification after complex modifier (expecting '}') for VAR +want: Unclosed variable expression after indirect modifier, expecting '}' for variable "VAR" +make: Unclosed variable expression after indirect modifier, expecting '}' for variable "VAR" VAR:S,V,v,=Thevariable unfinished-indirect: @@ -33,7 +33,7 @@ make: Unfinished modifier for "UNDEF" (' 1 2 3 loop-close: -make: Unclosed variable specification (expecting '}') for "UNDEF" (value "1}... 2}... 3}...") modifier @ +make: Unclosed variable expression, expecting '}' for modifier "@var@${var}}...@" of variable "UNDEF" with value "1}... 2}... 3}..." 1}... 2}... 3}... 1}... 2}... 3}... @@ -67,7 +67,7 @@ make: Unfinished modifier for "VAR" (',' 4: make: Unfinished modifier for "VAR" (',' missing) 5: -make: Unclosed variable specification (expecting '}') for "VAR" (value "TheVariable") modifier S +make: Unclosed variable expression, expecting '}' for modifier "S,from,to," of variable "VAR" with value "TheVariable" 6: TheVariable 7: TheVariable @@ -82,7 +82,7 @@ make: Unfinished modifier for "VAR" (',' 4: make: Unfinished modifier for "VAR" (',' missing) 5: -make: Unclosed variable specification (expecting '}') for "VAR" (value "TheVariable") modifier C +make: Unclosed variable expression, expecting '}' for modifier "C,from,to," of variable "VAR" with value "TheVariable" 6: TheVariable 7: TheVariable @@ -131,13 +131,13 @@ make: Unknown modifier "__" mod-sysv-parse: make: Unknown modifier "3" -make: Unclosed variable specification (expecting '}') for "FIB" (value "") modifier 3 +make: Unclosed variable expression, expecting '}' for modifier "3" of variable "FIB" with value "" make: Unknown modifier "3=" -make: Unclosed variable specification (expecting '}') for "FIB" (value "") modifier 3 +make: Unclosed variable expression, expecting '}' for modifier "3=" of variable "FIB" with value "" make: Unknown modifier "3=x3" -make: Unclosed variable specification (expecting '}') for "FIB" (value "") modifier 3 +make: Unclosed variable expression, expecting '}' for modifier "3=x3" of variable "FIB" with value "" 1 1 2 x3 5 8 1x3 21 34 Index: src/usr.bin/make/unit-tests/moderrs.mk diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.25 src/usr.bin/make/unit-tests/moderrs.mk:1.26 --- src/usr.bin/make/unit-tests/moderrs.mk:1.25 Sun Nov 15 20:20:58 2020 +++ src/usr.bin/make/unit-tests/moderrs.mk Tue Feb 23 15:56:30 2021 @@ -1,4 +1,4 @@ -# $NetBSD: moderrs.mk,v 1.25 2020/11/15 20:20:58 rillig Exp $ +# $NetBSD: moderrs.mk,v 1.26 2021/02/23 15:56:30 rillig Exp $ # # various modifier error tests @@ -35,11 +35,11 @@ mod-unknown-indirect: print-header print @echo 'VAR:${MOD_UNKN}=before-${VAR:${MOD_UNKN}:inner}-after' unclosed-direct: print-header print-footer - @echo 'want: Unclosed variable specification (expecting $'}$') for "VAR" (value "Thevariable") modifier S' + @echo 'want: Unclosed variable expression, expecting $'}$' for modifier "S,V,v," of variable "VAR" with value "Thevariable"' @echo VAR:S,V,v,=${VAR:S,V,v, unclosed-indirect: print-header print-footer - @echo 'want: Unclosed variable specification after complex modifier (expecting $'}$') for VAR' + @echo 'want: Unclosed variable expression after indirect modifier, expecting $'}$' for variable "VAR"' @echo VAR:${MOD_TERM},=${VAR:${MOD_S} unfinished-indirect: print-header print-footer Index: src/usr.bin/make/unit-tests/varmisc.exp diff -u src/usr.bin/make/unit-tests/varmisc.exp:1.16 src/usr.bin/make/unit-tests/varmisc.exp:1.17 --- src/usr.bin/make/unit-tests/varmisc.exp:1.16 Mon Aug 31 16:20:00 2020 +++ src/usr.bin/make/unit-tests/varmisc.exp Tue Feb 23 15:56:30 2021 @@ -54,7 +54,7 @@ make: Unclosed variable "UNCLOSED" make: Unclosed variable "UNCLOSED" make: Unclosed variable "PATTERN" -make: Unclosed variable specification (expecting '}') for "UNCLOSED" (value "") modifier M +make: Unclosed variable expression, expecting '}' for modifier "M${PATTERN" of variable "UNCLOSED" with value "" make: Unclosed variable "param" make: Unclosed variable "UNCLOSED." Index: src/usr.bin/make/unit-tests/varmod-edge.exp diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.13 src/usr.bin/make/unit-tests/varmod-edge.exp:1.14 --- src/usr.bin/make/unit-tests/varmod-edge.exp:1.13 Tue Feb 23 15:19:41 2021 +++ src/usr.bin/make/unit-tests/varmod-edge.exp Tue Feb 23 15:56:30 2021 @@ -1,7 +1,7 @@ make: "varmod-edge.mk" line 166: ok M-paren make: "varmod-edge.mk" line 166: ok M-mixed make: "varmod-edge.mk" line 166: ok M-unescape -make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U +make: Unclosed variable expression, expecting '}' for modifier "U*)" of variable "" with value "*)" make: "varmod-edge.mk" line 166: ok M-nest-mix make: "varmod-edge.mk" line 166: ok M-nest-brk make: "varmod-edge.mk" line 166: ok M-pat-err Index: src/usr.bin/make/unit-tests/varmod-edge.mk diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.15 src/usr.bin/make/unit-tests/varmod-edge.mk:1.16 --- src/usr.bin/make/unit-tests/varmod-edge.mk:1.15 Tue Feb 23 00:04:48 2021 +++ src/usr.bin/make/unit-tests/varmod-edge.mk Tue Feb 23 15:56:30 2021 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-edge.mk,v 1.15 2021/02/23 00:04:48 rillig Exp $ +# $NetBSD: varmod-edge.mk,v 1.16 2021/02/23 15:56:30 rillig Exp $ # # Tests for edge cases in variable modifiers. # @@ -51,7 +51,7 @@ TESTS+= M-nest-mix INP.M-nest-mix= (parentheses) MOD.M-nest-mix= ${INP.M-nest-mix:M${:U*)}} EXP.M-nest-mix= (parentheses)} -# make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U +# make: Unclosed variable expression, expecting '}' for modifier "U*)" of variable "" with value "*)" # In contrast to parentheses and braces, the brackets are not counted # when the :M modifier is parsed since Makefile variables only take the