Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make: improve error message for unclosed modifier
details: https://anonhg.NetBSD.org/src/rev/fee9c813456c
branches: trunk
changeset: 953017:fee9c813456c
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Feb 23 15:56:29 2021 +0000
description:
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.
diffstat:
usr.bin/make/suff.c | 6 +++---
usr.bin/make/unit-tests/directive-for-escape.exp | 4 ++--
usr.bin/make/unit-tests/moderrs.exp | 20 ++++++++++----------
usr.bin/make/unit-tests/moderrs.mk | 6 +++---
usr.bin/make/unit-tests/varmisc.exp | 2 +-
usr.bin/make/unit-tests/varmod-edge.exp | 2 +-
usr.bin/make/unit-tests/varmod-edge.mk | 4 ++--
usr.bin/make/var.c | 15 ++++++++-------
8 files changed, 30 insertions(+), 29 deletions(-)
diffs (219 lines):
diff -r 4893a03dcc17 -r fee9c813456c usr.bin/make/suff.c
--- a/usr.bin/make/suff.c Tue Feb 23 15:19:41 2021 +0000
+++ b/usr.bin/make/suff.c Tue Feb 23 15:56:29 2021 +0000
@@ -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 @@
* 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)
diff -r 4893a03dcc17 -r fee9c813456c usr.bin/make/unit-tests/directive-for-escape.exp
--- a/usr.bin/make/unit-tests/directive-for-escape.exp Tue Feb 23 15:19:41 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-for-escape.exp Tue Feb 23 15:56:29 2021 +0000
@@ -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:
diff -r 4893a03dcc17 -r fee9c813456c usr.bin/make/unit-tests/moderrs.exp
--- a/usr.bin/make/unit-tests/moderrs.exp Tue Feb 23 15:19:41 2021 +0000
+++ b/usr.bin/make/unit-tests/moderrs.exp Tue Feb 23 15:56:29 2021 +0000
@@ -9,13 +9,13 @@
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 @@
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 @@
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 @@
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 @@
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
diff -r 4893a03dcc17 -r fee9c813456c usr.bin/make/unit-tests/moderrs.mk
--- a/usr.bin/make/unit-tests/moderrs.mk Tue Feb 23 15:19:41 2021 +0000
+++ b/usr.bin/make/unit-tests/moderrs.mk Tue Feb 23 15:56:29 2021 +0000
@@ -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 @@
@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
diff -r 4893a03dcc17 -r fee9c813456c usr.bin/make/unit-tests/varmisc.exp
--- a/usr.bin/make/unit-tests/varmisc.exp Tue Feb 23 15:19:41 2021 +0000
+++ b/usr.bin/make/unit-tests/varmisc.exp Tue Feb 23 15:56:29 2021 +0000
@@ -54,7 +54,7 @@
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."
diff -r 4893a03dcc17 -r fee9c813456c usr.bin/make/unit-tests/varmod-edge.exp
--- a/usr.bin/make/unit-tests/varmod-edge.exp Tue Feb 23 15:19:41 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-edge.exp Tue Feb 23 15:56:29 2021 +0000
@@ -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
diff -r 4893a03dcc17 -r fee9c813456c usr.bin/make/unit-tests/varmod-edge.mk
--- a/usr.bin/make/unit-tests/varmod-edge.mk Tue Feb 23 15:19:41 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-edge.mk Tue Feb 23 15:56:29 2021 +0000
@@ -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 @@
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
diff -r 4893a03dcc17 -r fee9c813456c usr.bin/make/var.c
--- a/usr.bin/make/var.c Tue Feb 23 15:19:41 2021 +0000
+++ b/usr.bin/make/var.c Tue Feb 23 15:56:29 2021 +0000
@@ -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 @@
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 @@
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) {
Home |
Main Index |
Thread Index |
Old Index