Module Name:    src
Committed By:   rillig
Date:           Tue Feb 23 16:07:14 UTC 2021

Modified Files:
        src/usr.bin/make: var.c
        src/usr.bin/make/unit-tests: moderrs.exp modts.exp modword.exp
            varmod-assign.exp varmod-order.exp varmod-to-separator.exp

Log Message:
make: improve error message for bad modifier in variable expression

The improvement is especially noteable for variable expressions based on
the empty variable, see moderrs.exp:103.


To generate a diff of this commit:
cvs rdiff -u -r1.852 -r1.853 src/usr.bin/make/var.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/unit-tests/moderrs.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/modts.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/modword.exp \
    src/usr.bin/make/unit-tests/varmod-order.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-assign.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-to-separator.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.852 src/usr.bin/make/var.c:1.853
--- src/usr.bin/make/var.c:1.852	Tue Feb 23 15:56:29 2021
+++ src/usr.bin/make/var.c	Tue Feb 23 16:07:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.852 2021/02/23 15:56:29 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.853 2021/02/23 16:07:14 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.852 2021/02/23 15:56:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.853 2021/02/23 16:07:14 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3826,7 +3826,7 @@ ApplyModifiers(
 
 bad_modifier:
 	/* XXX: The modifier end is only guessed. */
-	Error("Bad modifier `:%.*s' for %s",
+	Error("Bad modifier \":%.*s\" for variable \"%s\"",
 	    (int)strcspn(mod, ":)}"), mod, expr->var->name.str);
 
 cleanup:

Index: src/usr.bin/make/unit-tests/moderrs.exp
diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.28 src/usr.bin/make/unit-tests/moderrs.exp:1.29
--- src/usr.bin/make/unit-tests/moderrs.exp:1.28	Tue Feb 23 16:04:16 2021
+++ src/usr.bin/make/unit-tests/moderrs.exp	Tue Feb 23 16:07:14 2021
@@ -45,7 +45,7 @@ want: Unfinished modifier for UNDEF (']'
 make: Unfinished modifier for "UNDEF" (']' missing)
 
 13=
-make: Bad modifier `:[123451234512345123451234512345]' for UNDEF
+make: Bad modifier ":[123451234512345123451234512345]" for variable "UNDEF"
 12345=S,^ok,:S,^3ok,}
 
 exclam:
@@ -98,21 +98,21 @@ make: No match for subexpression \1
 mod-ts-parse:
 112358132134
 15152535558513521534
-make: Bad modifier `:ts\65oct' for FIB
+make: Bad modifier ":ts\65oct" for variable "FIB"
 65oct}
-make: Bad modifier `:ts\65oct' for 
+make: Bad modifier ":ts\65oct" for variable ""
 65oct}
-make: Bad modifier `:tsxy' for FIB
+make: Bad modifier ":tsxy" for variable "FIB"
 xy}
 
 mod-t-parse:
-make: Bad modifier `:t' for FIB
+make: Bad modifier ":t" for variable "FIB"
 
-make: Bad modifier `:txy' for FIB
+make: Bad modifier ":txy" for variable "FIB"
 y}
-make: Bad modifier `:t' for FIB
+make: Bad modifier ":t" for variable "FIB"
 
-make: Bad modifier `:t' for FIB
+make: Bad modifier ":t" for variable "FIB"
 M*}
 
 mod-ifelse-parse:

Index: src/usr.bin/make/unit-tests/modts.exp
diff -u src/usr.bin/make/unit-tests/modts.exp:1.5 src/usr.bin/make/unit-tests/modts.exp:1.6
--- src/usr.bin/make/unit-tests/modts.exp:1.5	Mon Aug 31 19:58:21 2020
+++ src/usr.bin/make/unit-tests/modts.exp	Tue Feb 23 16:07:14 2021
@@ -1,6 +1,6 @@
-make: Bad modifier `:tx' for LIST
+make: Bad modifier ":tx" for variable "LIST"
 LIST:tx="}"
-make: Bad modifier `:ts\X' for LIST
+make: Bad modifier ":ts\X" for variable "LIST"
 LIST:ts/x:tu="\X:tu}"
 FU_mod-ts="a/b/cool"
 FU_mod-ts:ts:T="cool" == cool?

Index: src/usr.bin/make/unit-tests/modword.exp
diff -u src/usr.bin/make/unit-tests/modword.exp:1.2 src/usr.bin/make/unit-tests/modword.exp:1.3
--- src/usr.bin/make/unit-tests/modword.exp:1.2	Sun Nov  1 13:55:31 2020
+++ src/usr.bin/make/unit-tests/modword.exp	Tue Feb 23 16:07:14 2021
@@ -1,4 +1,4 @@
-make: Bad modifier `:[]' for LIST
+make: Bad modifier ":[]" for variable "LIST"
 LIST:[]="" is an error
 LIST:[0]="one two three four five six"
 LIST:[0x0]="one two three four five six"
@@ -37,17 +37,17 @@ REALLYSPACE=" "
 REALLYSPACE:[1]="" == "" ?
 REALLYSPACE:[*]:[1]=" " == " " ?
 LIST:[1]="one"
-make: Bad modifier `:[1.]' for LIST
+make: Bad modifier ":[1.]" for variable "LIST"
 LIST:[1.]="" is an error
-make: Bad modifier `:[1].' for LIST
+make: Bad modifier ":[1]." for variable "LIST"
 LIST:[1].="}" is an error
 LIST:[2]="two"
 LIST:[6]="six"
 LIST:[7]=""
 LIST:[999]=""
-make: Bad modifier `:[-]' for LIST
+make: Bad modifier ":[-]" for variable "LIST"
 LIST:[-]="" is an error
-make: Bad modifier `:[--]' for LIST
+make: Bad modifier ":[--]" for variable "LIST"
 LIST:[--]="" is an error
 LIST:[-1]="six"
 LIST:[-2]="five"
@@ -67,20 +67,20 @@ LIST:[*]:C/ /,/:[2]=""
 LIST:[*]:C/ /,/:[*]:[2]=""
 LIST:[*]:C/ /,/:[@]:[2]="three"
 LONGLIST:[012..0x12]="10 11 12 13 14 15 16 17 18"
-make: Bad modifier `:[1.]' for LIST
+make: Bad modifier ":[1.]" for variable "LIST"
 LIST:[1.]="" is an error
-make: Bad modifier `:[1..]' for LIST
+make: Bad modifier ":[1..]" for variable "LIST"
 LIST:[1..]="" is an error
 LIST:[1..1]="one"
-make: Bad modifier `:[1..1.]' for LIST
+make: Bad modifier ":[1..1.]" for variable "LIST"
 LIST:[1..1.]="" is an error
 LIST:[1..2]="one two"
 LIST:[2..1]="two one"
 LIST:[3..-2]="three four five"
 LIST:[-4..4]="three four"
-make: Bad modifier `:[0..1]' for LIST
+make: Bad modifier ":[0..1]" for variable "LIST"
 LIST:[0..1]="" is an error
-make: Bad modifier `:[-1..0]' for LIST
+make: Bad modifier ":[-1..0]" for variable "LIST"
 LIST:[-1..0]="" is an error
 LIST:[-1..1]="six five four three two one"
 LIST:[0..0]="one two three four five six"
@@ -95,7 +95,7 @@ LIST:[${ONE}]="one"
 LIST:[${MINUSONE}]="six"
 LIST:[${STAR}]="one two three four five six"
 LIST:[${AT}]="one two three four five six"
-make: Bad modifier `:[${EMPTY' for LIST
+make: Bad modifier ":[${EMPTY" for variable "LIST"
 LIST:[${EMPTY}]="" is an error
 LIST:[${LONGLIST:[21]:S/2//}]="one"
 LIST:[${LIST:[#]}]="six"
Index: src/usr.bin/make/unit-tests/varmod-order.exp
diff -u src/usr.bin/make/unit-tests/varmod-order.exp:1.2 src/usr.bin/make/unit-tests/varmod-order.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-order.exp:1.2	Sun Aug 16 20:43:01 2020
+++ src/usr.bin/make/unit-tests/varmod-order.exp	Tue Feb 23 16:07:14 2021
@@ -1,6 +1,6 @@
-make: Bad modifier `:OX' for NUMBERS
+make: Bad modifier ":OX" for variable "NUMBERS"
 make: "varmod-order.mk" line 13: Undefined variable "${NUMBERS:OX"
-make: Bad modifier `:OxXX' for NUMBERS
+make: Bad modifier ":OxXX" for variable "NUMBERS"
 make: "varmod-order.mk" line 16: Undefined variable "${NUMBERS:Ox"
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests

Index: src/usr.bin/make/unit-tests/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.8 src/usr.bin/make/unit-tests/varmod-assign.exp:1.9
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.8	Tue Feb 23 15:19:41 2021
+++ src/usr.bin/make/unit-tests/varmod-assign.exp	Tue Feb 23 16:07:14 2021
@@ -10,9 +10,9 @@ mod-assign-nested: then1t1
 mod-assign-nested: else2e2
 mod-assign-nested: then3t3
 mod-assign-nested: else4e4
-make: Bad modifier `:' for 
+make: Bad modifier ":" for variable ""
 mod-assign-empty: value}
-make: Bad modifier `:' for 
+make: Bad modifier ":" for variable ""
 mod-assign-empty: overwritten}
 mod-assign-empty: VAR=overwritten
 make: Unknown modifier ":x"

Index: src/usr.bin/make/unit-tests/varmod-to-separator.exp
diff -u src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.6 src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.7
--- src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.6	Mon Dec 21 21:04:18 2020
+++ src/usr.bin/make/unit-tests/varmod-to-separator.exp	Tue Feb 23 16:07:14 2021
@@ -2,17 +2,17 @@ make: "varmod-to-separator.mk" line 107:
 make: "varmod-to-separator.mk" line 107: Malformed conditional (${WORDS:[1..3]:ts\400:tu})
 make: "varmod-to-separator.mk" line 121: Invalid character number: 100:tu}
 make: "varmod-to-separator.mk" line 121: Malformed conditional (${WORDS:[1..3]:ts\x100:tu})
-make: Bad modifier `:ts\-300' for WORDS
+make: Bad modifier ":ts\-300" for variable "WORDS"
 make: "varmod-to-separator.mk" line 128: Malformed conditional (${WORDS:[1..3]:ts\-300:tu})
-make: Bad modifier `:ts\8' for 1 2 3
+make: Bad modifier ":ts\8" for variable "1 2 3"
 make: "varmod-to-separator.mk" line 136: Malformed conditional (${1 2 3:L:ts\8:tu})
-make: Bad modifier `:ts\100L' for 1 2 3
+make: Bad modifier ":ts\100L" for variable "1 2 3"
 make: "varmod-to-separator.mk" line 143: Malformed conditional (${1 2 3:L:ts\100L})
-make: Bad modifier `:ts\x40g' for 1 2 3
+make: Bad modifier ":ts\x40g" for variable "1 2 3"
 make: "varmod-to-separator.mk" line 150: Malformed conditional (${1 2 3:L:ts\x40g})
-make: Bad modifier `:tx' for WORDS
+make: Bad modifier ":tx" for variable "WORDS"
 make: "varmod-to-separator.mk" line 158: Malformed conditional (${WORDS:tx} != "anything")
-make: Bad modifier `:t\X' for WORDS
+make: Bad modifier ":t\X" for variable "WORDS"
 make: "varmod-to-separator.mk" line 165: Malformed conditional (${WORDS:t\X} != "anything")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests

Reply via email to