Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Add -dL for LINT



details:   https://anonhg.NetBSD.org/src/rev/b37d8ecdc513
branches:  trunk
changeset: 936611:b37d8ecdc513
user:      sjg <sjg%NetBSD.org@localhost>
date:      Fri Jul 31 20:22:10 2020 +0000

description:
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

diffstat:

 usr.bin/make/main.c  |  11 +++++++----
 usr.bin/make/make.1  |   9 +++++++--
 usr.bin/make/make.h  |   4 +++-
 usr.bin/make/parse.c |  16 +++++++++++++---
 4 files changed, 30 insertions(+), 10 deletions(-)

diffs (137 lines):

diff -r dc59ef5d7f86 -r b37d8ecdc513 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Fri Jul 31 20:16:21 2020 +0000
+++ b/usr.bin/make/main.c       Fri Jul 31 20:22:10 2020 +0000
@@ -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 @@
 #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 @@
        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 @@
                case 'j':
                        debug |= DEBUG_JOB;
                        break;
+               case 'L':
+                       debug |= DEBUG_LINT;
+                       break;
                case 'l':
                        debug |= DEBUG_LOUD;
                        break;
diff -r dc59ef5d7f86 -r b37d8ecdc513 usr.bin/make/make.1
--- a/usr.bin/make/make.1       Fri Jul 31 20:16:21 2020 +0000
+++ b/usr.bin/make/make.1       Fri Jul 31 20:22:10 2020 +0000
@@ -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 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 @
diff -r dc59ef5d7f86 -r b37d8ecdc513 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Fri Jul 31 20:16:21 2020 +0000
+++ b/usr.bin/make/make.h       Fri Jul 31 20:22:10 2020 +0000
@@ -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 @@
 #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))
diff -r dc59ef5d7f86 -r b37d8ecdc513 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Fri Jul 31 20:16:21 2020 +0000
+++ b/usr.bin/make/parse.c      Fri Jul 31 20:22:10 2020 +0000
@@ -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 @@
     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) {



Home | Main Index | Thread Index | Old Index