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(1): improve error message in case of unfin...



details:   https://anonhg.NetBSD.org/src/rev/5e4fe3151980
branches:  trunk
changeset: 936892:5e4fe3151980
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 08 13:27:42 2020 +0000

description:
make(1): improve error message in case of unfinished modifiers

The previous error message "Unclosed substitution" was wrong for several
reasons.

It is not about "unclosed", but about "unfinished" since in the
:@var@...@ modifier the missing '@' does not really close anything.

The word "substitution" may have originated in a time where :S and
:from=to were the only modifiers, and these were indeed substitutions,
but several other modifiers aren't.

The :S and :C modifiers allow an arbitrary delimiter, therefore it is
helpful to enclose the delimiter in quotes, just in case someone chooses
')' or '{' or even ' ' as delimiter.

diffstat:

 usr.bin/make/unit-tests/moderrs.exp     |  58 ++++++++++++++++----------------
 usr.bin/make/unit-tests/moderrs.mk      |   4 +-
 usr.bin/make/unit-tests/varmod-edge.exp |   2 +-
 usr.bin/make/var.c                      |  10 ++--
 4 files changed, 37 insertions(+), 37 deletions(-)

diffs (210 lines):

diff -r 5735d0c9ee6d -r 5e4fe3151980 usr.bin/make/unit-tests/moderrs.exp
--- a/usr.bin/make/unit-tests/moderrs.exp       Sat Aug 08 13:17:39 2020 +0000
+++ b/usr.bin/make/unit-tests/moderrs.exp       Sat Aug 08 13:27:42 2020 +0000
@@ -10,13 +10,13 @@
 Expect: Unclosed variable specification for VAR
 make: Unclosed variable specification after complex modifier (expecting '}') for VAR
 VAR:S,V,v,=Thevariable
-Expect: Unclosed substitution for VAR (, missing)
-make: Unclosed substitution for VAR (, missing)
+Expect: Unfinished modifier for VAR (',' missing)
+make: Unfinished modifier for VAR (',' missing)
 VAR:S,V,v=
 Expect: 2 errors about missing @ delimiter
-make: Unclosed substitution for UNDEF (@ missing)
+make: Unfinished modifier for UNDEF ('@' missing)
 
-make: Unclosed substitution for UNDEF (@ missing)
+make: Unfinished modifier for UNDEF ('@' missing)
 
 1 2 3
 modloop-close:
@@ -24,40 +24,40 @@
 1}... 2}... 3}...
 1}... 2}... 3}...
 Expect: 2 errors about missing ] delimiter
-make: Unclosed substitution for UNDEF (] missing)
+make: Unfinished modifier for UNDEF (']' missing)
 
-make: Unclosed substitution for UNDEF (] missing)
+make: Unfinished modifier for UNDEF (']' missing)
 
 13=
 12345=ok
 Expect: 2 errors about missing ! delimiter
-make: Unclosed substitution for VARNAME (! missing)
+make: Unfinished modifier for VARNAME ('!' missing)
 
-make: Unclosed substitution for ! (! missing)
+make: Unfinished modifier for ! ('!' missing)
 
 mod-subst-delimiter:
 make: Missing delimiter for :S modifier
 
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 
 make: Unclosed variable specification (expecting '}') for "VAR" (value "TheVariable") modifier S
 TheVariable
 TheVariable
 make: Missing delimiter for :S modifier
 1:
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 2:
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 3:
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 
 make: Unclosed variable specification (expecting '}') for "VAR" (value "TheVariable") modifier S
 TheVariable
@@ -65,26 +65,26 @@
 mod-regex-delimiter:
 make: Missing delimiter for :C modifier
 
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 
 make: Unclosed variable specification (expecting '}') for "VAR" (value "TheVariable") modifier C
 TheVariable
 TheVariable
 make: Missing delimiter for :C modifier
 1:
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 2:
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 3:
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 
-make: Unclosed substitution for VAR (, missing)
+make: Unfinished modifier for VAR (',' missing)
 
 make: Unclosed variable specification (expecting '}') for "VAR" (value "TheVariable") modifier C
 TheVariable
@@ -106,13 +106,13 @@
 make: Bad modifier `:t' for FIB
 M*}
 mod-ifelse-parse:
-make: Unclosed substitution for FIB (: missing)
+make: Unfinished modifier for FIB (':' missing)
 
-make: Unclosed substitution for FIB (: missing)
+make: Unfinished modifier for FIB (':' missing)
 
-make: Unclosed substitution for FIB (} missing)
+make: Unfinished modifier for FIB ('}' missing)
 
-make: Unclosed substitution for FIB (} missing)
+make: Unfinished modifier for FIB ('}' missing)
 
 then
 mod-assign-parse:
@@ -120,7 +120,7 @@
 
 make: Bad modifier `:' for 
 value}
-make: Unclosed substitution for ASSIGN (} missing)
+make: Unfinished modifier for ASSIGN ('}' missing)
 
 mod-remember-parse:
 1 1 2 3 5 8 13 21 34
diff -r 5735d0c9ee6d -r 5e4fe3151980 usr.bin/make/unit-tests/moderrs.mk
--- a/usr.bin/make/unit-tests/moderrs.mk        Sat Aug 08 13:17:39 2020 +0000
+++ b/usr.bin/make/unit-tests/moderrs.mk        Sat Aug 08 13:27:42 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: moderrs.mk,v 1.11 2020/07/31 15:16:05 rillig Exp $
+# $Id: moderrs.mk,v 1.12 2020/08/08 13:27:42 rillig Exp $
 #
 # various modifier error tests
 
@@ -40,7 +40,7 @@
        @echo VAR:${MOD_TERM},=${VAR:${MOD_S}
 
 modtermV:
-       @echo "Expect: Unclosed substitution for VAR (, missing)"
+       @echo "Expect: Unfinished modifier for VAR (',' missing)"
        -@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}"
 
 modloop:
diff -r 5735d0c9ee6d -r 5e4fe3151980 usr.bin/make/unit-tests/varmod-edge.exp
--- a/usr.bin/make/unit-tests/varmod-edge.exp   Sat Aug 08 13:17:39 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-edge.exp   Sat Aug 08 13:27:42 2020 +0000
@@ -12,7 +12,7 @@
 make: "varmod-edge.mk" line omitted: ok eq-ext
 make: "varmod-edge.mk" line omitted: ok eq-q
 make: "varmod-edge.mk" line omitted: ok eq-bs
-make: Unclosed substitution for INP.eq-esc (= missing)
+make: Unfinished modifier for INP.eq-esc ('=' missing)
 make: "varmod-edge.mk" line omitted: ok eq-esc
 make: "varmod-edge.mk" line omitted: ok colon
 make: Unknown modifier ':'
diff -r 5735d0c9ee6d -r 5e4fe3151980 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Aug 08 13:17:39 2020 +0000
+++ b/usr.bin/make/var.c        Sat Aug 08 13:27:42 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.427 2020/08/08 13:17:39 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.428 2020/08/08 13:27:42 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.427 2020/08/08 13:17:39 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.428 2020/08/08 13:27:42 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.427 2020/08/08 13:17:39 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.428 2020/08/08 13:27:42 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1918,7 +1918,7 @@
     AMR_OK,                    /* Continue parsing */
     AMR_UNKNOWN,               /* Not a match, try other modifiers as well */
     AMR_BAD,                   /* Error out with "Bad modifier" message */
-    AMR_CLEANUP                        /* Error out, with "Unclosed substitution"
+    AMR_CLEANUP                        /* Error out, with "Unfinished modifier"
                                 * if st->missing_delim is set. */
 } ApplyModifierResult;
 
@@ -3209,7 +3209,7 @@
 cleanup:
     *pp = p;
     if (st.missing_delim != '\0')
-       Error("Unclosed substitution for %s (%c missing)",
+       Error("Unfinished modifier for %s ('%c' missing)",
              st.v->name, st.missing_delim);
     free(*freePtr);
     *freePtr = NULL;



Home | Main Index | Thread Index | Old Index