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): error out on misspelled .export direct...



details:   https://anonhg.NetBSD.org/src/rev/4b98a4acc2da
branches:  trunk
changeset: 957837:4b98a4acc2da
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Dec 12 18:11:42 2020 +0000

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

diffstat:

 usr.bin/make/unit-tests/directive-unexport-env.exp |   1 +
 usr.bin/make/unit-tests/directive-unexport-env.mk  |   4 ++--
 usr.bin/make/unit-tests/directive-unexport.exp     |  11 ++++++-----
 usr.bin/make/unit-tests/directive-unexport.mk      |   9 +++++----
 usr.bin/make/var.c                                 |  10 +++++++---
 5 files changed, 21 insertions(+), 14 deletions(-)

diffs (104 lines):

diff -r 9fa6b78bf3a4 -r 4b98a4acc2da usr.bin/make/unit-tests/directive-unexport-env.exp
--- a/usr.bin/make/unit-tests/directive-unexport-env.exp        Sat Dec 12 18:00:18 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-unexport-env.exp        Sat Dec 12 18:11:42 2020 +0000
@@ -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
diff -r 9fa6b78bf3a4 -r 4b98a4acc2da usr.bin/make/unit-tests/directive-unexport-env.mk
--- a/usr.bin/make/unit-tests/directive-unexport-env.mk Sat Dec 12 18:00:18 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-unexport-env.mk Sat Dec 12 18:11:42 2020 +0000
@@ -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
 
diff -r 9fa6b78bf3a4 -r 4b98a4acc2da usr.bin/make/unit-tests/directive-unexport.exp
--- a/usr.bin/make/unit-tests/directive-unexport.exp    Sat Dec 12 18:00:18 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-unexport.exp    Sat Dec 12 18:11:42 2020 +0000
@@ -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
diff -r 9fa6b78bf3a4 -r 4b98a4acc2da usr.bin/make/unit-tests/directive-unexport.mk
--- a/usr.bin/make/unit-tests/directive-unexport.mk     Sat Dec 12 18:00:18 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-unexport.mk     Sat Dec 12 18:11:42 2020 +0000
@@ -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 @@
 
 .unexpor                       # misspelled
 .unexport                      # oops: missing argument
-.unexporting works             # oops: misspelled
+.unexporting works             # misspelled
 
 all:
        @:;
diff -r 9fa6b78bf3a4 -r 4b98a4acc2da usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Dec 12 18:00:18 2020 +0000
+++ b/usr.bin/make/var.c        Sat Dec 12 18:11:42 2020 +0000
@@ -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 @@
                }
                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) {



Home | Main Index | Thread Index | Old Index