Module Name:    src
Committed By:   sjg
Date:           Fri Jul 31 20:22:10 UTC 2020

Modified Files:
        src/usr.bin/make: main.c make.1 make.h parse.c

Log Message:
Add -dL for LINT

When parsing variable assignments other than := and if
value contains '$' attempt Var_Subst the same as for :=,
if the value does not parse correctly, we get a fatal error
including file an line number.

This can greatly help with finding the cause of problems.

Reviewed by: christos


To generate a diff of this commit:
cvs rdiff -u -r1.284 -r1.285 src/usr.bin/make/main.c
cvs rdiff -u -r1.283 -r1.284 src/usr.bin/make/make.1
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/make/make.h
cvs rdiff -u -r1.242 -r1.243 src/usr.bin/make/parse.c

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/main.c
diff -u src/usr.bin/make/main.c:1.284 src/usr.bin/make/main.c:1.285
--- src/usr.bin/make/main.c:1.284	Tue Jul 28 16:42:22 2020
+++ src/usr.bin/make/main.c	Fri Jul 31 20:22:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.284 2020/07/28 16:42:22 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.285 2020/07/31 20:22:10 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.284 2020/07/28 16:42:22 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.285 2020/07/31 20:22:10 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.284 2020/07/28 16:42:22 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.285 2020/07/31 20:22:10 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -244,7 +244,7 @@ parse_debug_options(const char *argvalue
 	for (modules = argvalue; *modules; ++modules) {
 		switch (*modules) {
 		case 'A':
-			debug = ~0;
+			debug = ~(0|DEBUG_LINT);
 			break;
 		case 'a':
 			debug |= DEBUG_ARCH;
@@ -284,6 +284,9 @@ parse_debug_options(const char *argvalue
 		case 'j':
 			debug |= DEBUG_JOB;
 			break;
+		case 'L':
+			debug |= DEBUG_LINT;
+			break;
 		case 'l':
 			debug |= DEBUG_LOUD;
 			break;

Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.283 src/usr.bin/make/make.1:1.284
--- src/usr.bin/make/make.1:1.283	Sat Jul 18 21:37:38 2020
+++ src/usr.bin/make/make.1	Fri Jul 31 20:22:10 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.283 2020/07/18 21:37:38 sjg Exp $
+.\"	$NetBSD: make.1,v 1.284 2020/07/31 20:22:10 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd July 18, 2020
+.Dd July 31, 2020
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -170,6 +170,11 @@ Print the input graph before exiting on 
 Print debugging information about hash table operations.
 .It Ar j
 Print debugging information about running multiple shells.
+.It Ar L
+Turn on lint checks.
+This will throw errors for variable assignments that do not parse
+correctly, at the time of assignment so the file and line number
+are available.
 .It Ar l
 Print commands in Makefiles regardless of whether or not they are prefixed by
 .Ql @

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.111 src/usr.bin/make/make.h:1.112
--- src/usr.bin/make/make.h:1.111	Tue Jul 21 21:13:24 2020
+++ src/usr.bin/make/make.h	Fri Jul 31 20:22:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.111 2020/07/21 21:13:24 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.112 2020/07/31 20:22:10 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -474,6 +474,8 @@ extern int debug;
 #define DEBUG_PARSE	0x40000
 #define DEBUG_CWD	0x80000
 
+#define DEBUG_LINT	0x100000
+
 #define CONCAT(a,b)	a##b
 
 #define	DEBUG(module)	(debug & CONCAT(DEBUG_,module))

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.242 src/usr.bin/make/parse.c:1.243
--- src/usr.bin/make/parse.c:1.242	Tue Jul 28 19:13:49 2020
+++ src/usr.bin/make/parse.c	Fri Jul 31 20:22:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.242 2020/07/28 19:13:49 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.243 2020/07/31 20:22:10 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.242 2020/07/28 19:13:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.243 2020/07/31 20:22:10 sjg 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.242 2020/07/28 19:13:49 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.243 2020/07/31 20:22:10 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1948,6 +1948,16 @@ Parse_DoVar(char *line, GNode *ctxt)
     while (isspace((unsigned char)*cp))
 	cp++;
 
+    if (DEBUG(LINT)) {
+	if (type != VAR_SUBST && strchr(cp, '$') != NULL) {
+	    /* sanity check now */
+	    char *cp2;
+
+	    cp2 = Var_Subst(cp, ctxt, VARE_WANTRES|VARE_ASSIGN);
+	    free(cp2);
+	}
+    }
+
     if (type == VAR_APPEND) {
 	Var_Append(line, cp, ctxt);
     } else if (type == VAR_SUBST) {

Reply via email to