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.
This commit is contained in:
parent
2cb05daf5c
commit
b1ac54abf1
|
@ -10,13 +10,13 @@ VAR:S,V,v,=Thevariable
|
|||
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 @@ make: Unclosed variable specification (expecting '}') for "UNDEF" (value "1}...
|
|||
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 @@ TheVariable
|
|||
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
|
|||
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: Unknown modifier ':'
|
|||
|
||||
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
|
||||
|
|
|
@ -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 @@ vartermV:
|
|||
@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:
|
||||
|
|
|
@ -12,7 +12,7 @@ make: "varmod-edge.mk" line omitted: ok M-128
|
|||
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 ':'
|
||||
|
|
|
@ -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 @@ typedef enum {
|
|||
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 @@ bad_modifier:
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue