Module Name:    src
Committed By:   rillig
Date:           Sat Dec 12 18:11:42 UTC 2020

Modified Files:
        src/usr.bin/make: var.c
        src/usr.bin/make/unit-tests: directive-unexport-env.exp
            directive-unexport-env.mk directive-unexport.exp
            directive-unexport.mk

Log Message:
make(1): error out on misspelled .export directives


To generate a diff of this commit:
cvs rdiff -u -r1.723 -r1.724 src/usr.bin/make/var.c
cvs rdiff -u -r1.3 -r1.4 \
    src/usr.bin/make/unit-tests/directive-unexport-env.exp
cvs rdiff -u -r1.6 -r1.7 \
    src/usr.bin/make/unit-tests/directive-unexport-env.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/directive-unexport.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/directive-unexport.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/var.c
diff -u src/usr.bin/make/var.c:1.723 src/usr.bin/make/var.c:1.724
--- src/usr.bin/make/var.c:1.723	Sat Dec 12 18:00:18 2020
+++ src/usr.bin/make/var.c	Sat Dec 12 18:11:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.723 2020/12/12 18:00:18 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.724 2020/12/12 18:11:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.723 2020/12/12 18:00:18 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.724 2020/12/12 18:11:42 rillig Exp $");
 
 /* A string that may need to be freed after use. */
 typedef struct FStr {
@@ -770,11 +770,15 @@ GetVarnamesToUnexport(const char *direct
 		}
 		what = UNEXPORT_ENV;
 
-	} else {
+	} else if (*p == '\0' || ch_isspace(*p)) {
 		cpp_skip_whitespace(&p);
 		what = p[0] != '\0' ? UNEXPORT_NAMED : UNEXPORT_ALL;
 		if (what == UNEXPORT_NAMED)
 			FStr_Assign(&varnames, p, NULL);
+	} else {
+		Parse_Error(PARSE_FATAL, "Unknown directive \"%s\"", directive);
+		what = UNEXPORT_NAMED;
+		FStr_Assign(&varnames, "", NULL);
 	}
 
 	if (what != UNEXPORT_NAMED) {

Index: src/usr.bin/make/unit-tests/directive-unexport-env.exp
diff -u src/usr.bin/make/unit-tests/directive-unexport-env.exp:1.3 src/usr.bin/make/unit-tests/directive-unexport-env.exp:1.4
--- src/usr.bin/make/unit-tests/directive-unexport-env.exp:1.3	Sat Dec 12 18:00:18 2020
+++ src/usr.bin/make/unit-tests/directive-unexport-env.exp	Sat Dec 12 18:11:42 2020
@@ -1,3 +1,4 @@
+make: "directive-unexport-env.mk" line 13: Unknown directive "unexport-en"
 make: "directive-unexport-env.mk" line 15: Unknown directive "unexport-environment"
 Global:UT_EXPORTED = value
 Global:UT_UNEXPORTED = value

Index: src/usr.bin/make/unit-tests/directive-unexport-env.mk
diff -u src/usr.bin/make/unit-tests/directive-unexport-env.mk:1.6 src/usr.bin/make/unit-tests/directive-unexport-env.mk:1.7
--- src/usr.bin/make/unit-tests/directive-unexport-env.mk:1.6	Sat Dec 12 18:00:18 2020
+++ src/usr.bin/make/unit-tests/directive-unexport-env.mk	Sat Dec 12 18:11:42 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-unexport-env.mk,v 1.6 2020/12/12 18:00:18 rillig Exp $
+# $NetBSD: directive-unexport-env.mk,v 1.7 2020/12/12 18:11:42 rillig Exp $
 #
 # Tests for the .unexport-env directive.
 #
@@ -10,7 +10,7 @@
 
 # TODO: Implementation
 
-.unexport-en			# oops: misspelled
+.unexport-en			# misspelled
 .unexport-env			# ok
 .unexport-environment		# misspelled
 

Index: src/usr.bin/make/unit-tests/directive-unexport.exp
diff -u src/usr.bin/make/unit-tests/directive-unexport.exp:1.4 src/usr.bin/make/unit-tests/directive-unexport.exp:1.5
--- src/usr.bin/make/unit-tests/directive-unexport.exp:1.4	Tue Nov  3 17:17:31 2020
+++ src/usr.bin/make/unit-tests/directive-unexport.exp	Sat Dec 12 18:11:42 2020
@@ -1,8 +1,9 @@
-make: "directive-unexport.mk" line 14: UT_A=a UT_B=b UT_C=c
-make: "directive-unexport.mk" line 15: UT_A UT_B UT_C
-make: "directive-unexport.mk" line 23: UT_A=a UT_B=b UT_C=c
-make: "directive-unexport.mk" line 24: 
-make: "directive-unexport.mk" line 26: Unknown directive "unexpor"
+make: "directive-unexport.mk" line 15: UT_A=a UT_B=b UT_C=c
+make: "directive-unexport.mk" line 16: UT_A UT_B UT_C
+make: "directive-unexport.mk" line 24: UT_A=a UT_B=b UT_C=c
+make: "directive-unexport.mk" line 25: 
+make: "directive-unexport.mk" line 27: Unknown directive "unexpor"
+make: "directive-unexport.mk" line 29: Unknown directive "unexporting works"
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/directive-unexport.mk
diff -u src/usr.bin/make/unit-tests/directive-unexport.mk:1.5 src/usr.bin/make/unit-tests/directive-unexport.mk:1.6
--- src/usr.bin/make/unit-tests/directive-unexport.mk:1.5	Tue Nov  3 17:17:31 2020
+++ src/usr.bin/make/unit-tests/directive-unexport.mk	Sat Dec 12 18:11:42 2020
@@ -1,8 +1,9 @@
-# $NetBSD: directive-unexport.mk,v 1.5 2020/11/03 17:17:31 rillig Exp $
+# $NetBSD: directive-unexport.mk,v 1.6 2020/12/12 18:11:42 rillig Exp $
 #
 # Tests for the .unexport directive.
-
-# TODO: Implementation
+#
+# Before 2020-12-13, misspelled directives like ".unexporting" or
+# ".unexport-en" had not been detected properly.
 
 # First, export 3 variables.
 UT_A=	a
@@ -25,7 +26,7 @@ UT_C=	c
 
 .unexpor			# misspelled
 .unexport			# oops: missing argument
-.unexporting works		# oops: misspelled
+.unexporting works		# misspelled
 
 all:
 	@:;

Reply via email to