Tue Jul 28 18:15:11 2020 UTC ()
make(1): when parsing an unknown directive, print the directive name


(rillig)
diff -r1.239 -r1.240 src/usr.bin/make/parse.c
diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/directives.exp

cvs diff -r1.239 -r1.240 src/usr.bin/make/parse.c (expand / switch to unified diff)

--- src/usr.bin/make/parse.c 2020/07/28 16:42:22 1.239
+++ src/usr.bin/make/parse.c 2020/07/28 18:15:11 1.240
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: parse.c,v 1.239 2020/07/28 16:42:22 rillig Exp $ */ 1/* $NetBSD: parse.c,v 1.240 2020/07/28 18:15:11 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990, 1993 4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -59,34 +59,34 @@ @@ -59,34 +59,34 @@
59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE. 68 * SUCH DAMAGE.
69 */ 69 */
70 70
71#ifndef MAKE_NATIVE 71#ifndef MAKE_NATIVE
72static char rcsid[] = "$NetBSD: parse.c,v 1.239 2020/07/28 16:42:22 rillig Exp $"; 72static char rcsid[] = "$NetBSD: parse.c,v 1.240 2020/07/28 18:15:11 rillig Exp $";
73#else 73#else
74#include <sys/cdefs.h> 74#include <sys/cdefs.h>
75#ifndef lint 75#ifndef lint
76#if 0 76#if 0
77static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; 77static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
78#else 78#else
79__RCSID("$NetBSD: parse.c,v 1.239 2020/07/28 16:42:22 rillig Exp $"); 79__RCSID("$NetBSD: parse.c,v 1.240 2020/07/28 18:15:11 rillig Exp $");
80#endif 80#endif
81#endif /* not lint */ 81#endif /* not lint */
82#endif 82#endif
83 83
84/*- 84/*-
85 * parse.c -- 85 * parse.c --
86 * Functions to parse a makefile. 86 * Functions to parse a makefile.
87 * 87 *
88 * One function, Parse_Init, must be called before any functions 88 * One function, Parse_Init, must be called before any functions
89 * in this module are used. After that, the function Parse_File is the 89 * in this module are used. After that, the function Parse_File is the
90 * main entry point and controls most of the other functions in this 90 * main entry point and controls most of the other functions in this
91 * module. 91 * module.
92 * 92 *
@@ -1279,27 +1279,36 @@ ParseDoDependency(char *line) @@ -1279,27 +1279,36 @@ ParseDoDependency(char *line)
1279 /* 1279 /*
1280 * We got to the end of the line while we were still 1280 * We got to the end of the line while we were still
1281 * looking at targets. 1281 * looking at targets.
1282 * 1282 *
1283 * Ending a dependency line without an operator is a Bozo 1283 * Ending a dependency line without an operator is a Bozo
1284 * no-no. As a heuristic, this is also often triggered by 1284 * no-no. As a heuristic, this is also often triggered by
1285 * undetected conflicts from cvs/rcs merges. 1285 * undetected conflicts from cvs/rcs merges.
1286 */ 1286 */
1287 if ((strncmp(line, "<<<<<<", 6) == 0) || 1287 if ((strncmp(line, "<<<<<<", 6) == 0) ||
1288 (strncmp(line, "======", 6) == 0) || 1288 (strncmp(line, "======", 6) == 0) ||
1289 (strncmp(line, ">>>>>>", 6) == 0)) 1289 (strncmp(line, ">>>>>>", 6) == 0))
1290 Parse_Error(PARSE_FATAL, 1290 Parse_Error(PARSE_FATAL,
1291 "Makefile appears to contain unresolved cvs/rcs/??? merge conflicts"); 1291 "Makefile appears to contain unresolved cvs/rcs/??? merge conflicts");
1292 else 1292 else if (lstart[0] == '.') {
 1293 const char *dirstart = lstart + 1;
 1294 while (isspace((unsigned char)*dirstart))
 1295 dirstart++;
 1296 const char *dirend = dirstart;
 1297 while (isalnum((unsigned char)*dirend) || *dirend == '-')
 1298 dirend++;
 1299 Parse_Error(PARSE_FATAL, "Unknown directive \"%.*s\"",
 1300 (int)(dirend - dirstart), dirstart);
 1301 } else
1293 Parse_Error(PARSE_FATAL, lstart[0] == '.' ? "Unknown directive" 1302 Parse_Error(PARSE_FATAL, lstart[0] == '.' ? "Unknown directive"
1294 : "Need an operator"); 1303 : "Need an operator");
1295 goto out; 1304 goto out;
1296 } 1305 }
1297 1306
1298 /* Insert a null terminator. */ 1307 /* Insert a null terminator. */
1299 savec = *cp; 1308 savec = *cp;
1300 *cp = '\0'; 1309 *cp = '\0';
1301 1310
1302 /* 1311 /*
1303 * Got the word. See if it's a special target and if so set 1312 * Got the word. See if it's a special target and if so set
1304 * specType to match it. 1313 * specType to match it.
1305 */ 1314 */

cvs diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/Attic/directives.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/Attic/directives.exp 2020/07/28 17:47:57 1.2
+++ src/usr.bin/make/unit-tests/Attic/directives.exp 2020/07/28 18:15:11 1.3
@@ -1,37 +1,37 @@ @@ -1,37 +1,37 @@
1make: "directives.mk" line 10: begin .export tests 1make: "directives.mk" line 10: begin .export tests
2make: "directives.mk" line 11: Unknown directive 2make: "directives.mk" line 11: Unknown directive "expor"
3make: "directives.mk" line 20: begin .export-env tests 3make: "directives.mk" line 20: begin .export-env tests
4make: "directives.mk" line 30: begin .export-literal tests 4make: "directives.mk" line 30: begin .export-literal tests
5make: "directives.mk" line 40: begin .info tests 5make: "directives.mk" line 40: begin .info tests
6make: "directives.mk" line 41: Unknown directive 6make: "directives.mk" line 41: Unknown directive "inf"
7make: "directives.mk" line 42: Unknown directive 7make: "directives.mk" line 42: Unknown directive "info"
8make: "directives.mk" line 43: message 8make: "directives.mk" line 43: message
9make: "directives.mk" line 44: indented message 9make: "directives.mk" line 44: indented message
10make: "directives.mk" line 45: Unknown directive 10make: "directives.mk" line 45: Unknown directive "information"
11make: "directives.mk" line 46: message 11make: "directives.mk" line 46: message
12make: "directives.mk" line 50: begin .undef tests 12make: "directives.mk" line 50: begin .undef tests
13make: "directives.mk" line 51: Unknown directive 13make: "directives.mk" line 51: Unknown directive "unde"
14make: "directives.mk" line 60: begin .unexport tests 14make: "directives.mk" line 60: begin .unexport tests
15make: "directives.mk" line 61: Unknown directive 15make: "directives.mk" line 61: Unknown directive "unexpor"
16make: "directives.mk" line 70: begin .unexport-env tests 16make: "directives.mk" line 70: begin .unexport-env tests
17make: "directives.mk" line 80: begin .warning tests 17make: "directives.mk" line 80: begin .warning tests
18make: "directives.mk" line 81: Unknown directive 18make: "directives.mk" line 81: Unknown directive "warn"
19make: "directives.mk" line 82: Unknown directive 19make: "directives.mk" line 82: Unknown directive "warnin"
20make: "directives.mk" line 83: Unknown directive 20make: "directives.mk" line 83: Unknown directive "warning"
21make: "directives.mk" line 84: warning: message 21make: "directives.mk" line 84: warning: message
22make: "directives.mk" line 85: Unknown directive 22make: "directives.mk" line 85: Unknown directive "warnings"
23make: "directives.mk" line 86: warning: messages 23make: "directives.mk" line 86: warning: messages
24make: "directives.mk" line 90: begin .elif misspellings tests, part 1 24make: "directives.mk" line 90: begin .elif misspellings tests, part 1
25make: "directives.mk" line 100: begin .elif misspellings tests, part 2 25make: "directives.mk" line 100: begin .elif misspellings tests, part 2
26make: "directives.mk" line 110: begin .elif misspellings tests, part 3 26make: "directives.mk" line 110: begin .elif misspellings tests, part 3
27make: "directives.mk" line 120: which branch is taken on misspelling after false? 27make: "directives.mk" line 120: which branch is taken on misspelling after false?
28make: "directives.mk" line 127: else taken 28make: "directives.mk" line 127: else taken
29make: "directives.mk" line 130: which branch is taken on misspelling after true? 29make: "directives.mk" line 130: which branch is taken on misspelling after true?
30make: "directives.mk" line 132: Unknown directive 30make: "directives.mk" line 132: Unknown directive "elsif"
31make: "directives.mk" line 133: 1 taken 31make: "directives.mk" line 133: 1 taken
32make: "directives.mk" line 134: Unknown directive 32make: "directives.mk" line 134: Unknown directive "elsif"
33make: "directives.mk" line 135: 2 taken 33make: "directives.mk" line 135: 2 taken
34make: "directives.mk" line 140: end of the tests 34make: "directives.mk" line 140: end of the tests
35make: Fatal errors encountered -- cannot continue 35make: Fatal errors encountered -- cannot continue
36make: stopped in unit-tests 36make: stopped in unit-tests
37exit status 1 37exit status 1