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): when parsing an unknown directive, pri...



details:   https://anonhg.NetBSD.org/src/rev/faee6acf4d13
branches:  trunk
changeset: 936522:faee6acf4d13
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jul 28 18:15:11 2020 +0000

description:
make(1): when parsing an unknown directive, print the directive name

diffstat:

 usr.bin/make/parse.c                   |  17 +++++++++++++----
 usr.bin/make/unit-tests/directives.exp |  24 ++++++++++++------------
 2 files changed, 25 insertions(+), 16 deletions(-)

diffs (95 lines):

diff -r dc0d302e309e -r faee6acf4d13 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Tue Jul 28 17:47:57 2020 +0000
+++ b/usr.bin/make/parse.c      Tue Jul 28 18:15:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.239 2020/07/28 16:42:22 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.240 2020/07/28 18:15:11 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.239 2020/07/28 16:42:22 rillig Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.240 2020/07/28 18:15:11 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c    8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.239 2020/07/28 16:42:22 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.240 2020/07/28 18:15:11 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1289,7 +1289,16 @@
                (strncmp(line, ">>>>>>", 6) == 0))
                Parse_Error(PARSE_FATAL,
                    "Makefile appears to contain unresolved cvs/rcs/??? merge conflicts");
-           else
+           else if (lstart[0] == '.') {
+               const char *dirstart = lstart + 1;
+               while (isspace((unsigned char)*dirstart))
+                   dirstart++;
+               const char *dirend = dirstart;
+               while (isalnum((unsigned char)*dirend) || *dirend == '-')
+                   dirend++;
+               Parse_Error(PARSE_FATAL, "Unknown directive \"%.*s\"",
+                           (int)(dirend - dirstart), dirstart);
+           } else
                Parse_Error(PARSE_FATAL, lstart[0] == '.' ? "Unknown directive"
                                     : "Need an operator");
            goto out;
diff -r dc0d302e309e -r faee6acf4d13 usr.bin/make/unit-tests/directives.exp
--- a/usr.bin/make/unit-tests/directives.exp    Tue Jul 28 17:47:57 2020 +0000
+++ b/usr.bin/make/unit-tests/directives.exp    Tue Jul 28 18:15:11 2020 +0000
@@ -1,25 +1,25 @@
 make: "directives.mk" line 10: begin .export tests
-make: "directives.mk" line 11: Unknown directive
+make: "directives.mk" line 11: Unknown directive "expor"
 make: "directives.mk" line 20: begin .export-env tests
 make: "directives.mk" line 30: begin .export-literal tests
 make: "directives.mk" line 40: begin .info tests
-make: "directives.mk" line 41: Unknown directive
-make: "directives.mk" line 42: Unknown directive
+make: "directives.mk" line 41: Unknown directive "inf"
+make: "directives.mk" line 42: Unknown directive "info"
 make: "directives.mk" line 43: message
 make: "directives.mk" line 44: indented message
-make: "directives.mk" line 45: Unknown directive
+make: "directives.mk" line 45: Unknown directive "information"
 make: "directives.mk" line 46: message
 make: "directives.mk" line 50: begin .undef tests
-make: "directives.mk" line 51: Unknown directive
+make: "directives.mk" line 51: Unknown directive "unde"
 make: "directives.mk" line 60: begin .unexport tests
-make: "directives.mk" line 61: Unknown directive
+make: "directives.mk" line 61: Unknown directive "unexpor"
 make: "directives.mk" line 70: begin .unexport-env tests
 make: "directives.mk" line 80: begin .warning tests
-make: "directives.mk" line 81: Unknown directive
-make: "directives.mk" line 82: Unknown directive
-make: "directives.mk" line 83: Unknown directive
+make: "directives.mk" line 81: Unknown directive "warn"
+make: "directives.mk" line 82: Unknown directive "warnin"
+make: "directives.mk" line 83: Unknown directive "warning"
 make: "directives.mk" line 84: warning: message
-make: "directives.mk" line 85: Unknown directive
+make: "directives.mk" line 85: Unknown directive "warnings"
 make: "directives.mk" line 86: warning: messages
 make: "directives.mk" line 90: begin .elif misspellings tests, part 1
 make: "directives.mk" line 100: begin .elif misspellings tests, part 2
@@ -27,9 +27,9 @@
 make: "directives.mk" line 120: which branch is taken on misspelling after false?
 make: "directives.mk" line 127: else taken
 make: "directives.mk" line 130: which branch is taken on misspelling after true?
-make: "directives.mk" line 132: Unknown directive
+make: "directives.mk" line 132: Unknown directive "elsif"
 make: "directives.mk" line 133: 1 taken
-make: "directives.mk" line 134: Unknown directive
+make: "directives.mk" line 134: Unknown directive "elsif"
 make: "directives.mk" line 135: 2 taken
 make: "directives.mk" line 140: end of the tests
 make: Fatal errors encountered -- cannot continue



Home | Main Index | Thread Index | Old Index