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): move lint option away from the debug f...



details:   https://anonhg.NetBSD.org/src/rev/5092d7b21ce3
branches:  trunk
changeset: 945902:5092d7b21ce3
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 08 23:38:02 2020 +0000

description:
make(1): move lint option away from the debug flags

The lint option affects much more than a typical debug flag.  Not only
does it produce additional diagnostics, it also changes the control flow
and fixes the traditional error handling in a few places.

No functional change.

diffstat:

 usr.bin/make/main.c  |  13 +++++++------
 usr.bin/make/make.h  |  16 +++++++++-------
 usr.bin/make/parse.c |   8 ++++----
 usr.bin/make/var.c   |  18 +++++++++---------
 4 files changed, 29 insertions(+), 26 deletions(-)

diffs (218 lines):

diff -r 545b1ef91ae9 -r 5092d7b21ce3 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sun Nov 08 23:30:59 2020 +0000
+++ b/usr.bin/make/main.c       Sun Nov 08 23:38:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.454 2020/11/08 15:07:37 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.455 2020/11/08 23:38:02 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.454 2020/11/08 15:07:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.455 2020/11/08 23:38:02 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -250,10 +250,10 @@
        for (modules = argvalue; *modules; ++modules) {
                switch (*modules) {
                case '0':       /* undocumented, only intended for tests */
-                       opts.debug &= DEBUG_LINT;
+                       opts.debug = DEBUG_NONE;
                        break;
                case 'A':
-                       opts.debug = ~(0 | DEBUG_LINT);
+                       opts.debug = DEBUG_ALL;
                        break;
                case 'a':
                        opts.debug |= DEBUG_ARCH;
@@ -292,7 +292,7 @@
                        opts.debug |= DEBUG_JOB;
                        break;
                case 'L':
-                       opts.debug |= DEBUG_LINT;
+                       opts.lint = TRUE;
                        break;
                case 'l':
                        opts.debug |= DEBUG_LOUD;
@@ -1124,6 +1124,7 @@
        opts.compatMake = FALSE;        /* No compat mode */
        opts.debug = 0;                 /* No debug verbosity, please. */
        /* opts.debug_file has been initialized earlier */
+       opts.lint = FALSE;
        opts.debugVflag = FALSE;
        opts.checkEnvFirst = FALSE;
        opts.makefiles = Lst_New();
@@ -1649,7 +1650,7 @@
 static int
 main_Exit(Boolean outOfDate)
 {
-       if (DEBUG(LINT) && (errors > 0 || Parse_GetFatals() > 0))
+       if (opts.lint && (errors > 0 || Parse_GetFatals() > 0))
                return 2;       /* Not 1 so -q can distinguish error */
        return outOfDate ? 1 : 0;
 }
diff -r 545b1ef91ae9 -r 5092d7b21ce3 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Sun Nov 08 23:30:59 2020 +0000
+++ b/usr.bin/make/make.h       Sun Nov 08 23:38:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.203 2020/11/08 23:30:59 rillig Exp $        */
+/*     $NetBSD: make.h,v 1.204 2020/11/08 23:38:02 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -496,6 +496,7 @@
 #endif
 
 typedef enum DebugFlags {
+    DEBUG_NONE         = 0,
     DEBUG_ARCH         = 1 << 0,
     DEBUG_COND         = 1 << 1,
     DEBUG_CWD          = 1 << 2,
@@ -516,12 +517,7 @@
     DEBUG_SUFF         = 1 << 17,
     DEBUG_TARG         = 1 << 18,
     DEBUG_VAR          = 1 << 19,
-
-    /* Runs make in strict mode, with additional checks and better error
-     * handling.  This is not the default mode to preserve compatibility.
-     *
-     * XXX: This is not really a debug flag, it doesn't belong here. */
-    DEBUG_LINT         = 1 << 20
+    DEBUG_ALL          = (1 << 20) - 1
 } DebugFlags;
 
 #define CONCAT(a,b)    a##b
@@ -572,6 +568,12 @@
     /* -df: debug output is written here - default stderr */
     FILE *debug_file;
 
+    /* -dL: lint mode
+     *
+     * Runs make in strict mode, with additional checks and better error
+     * handling. */
+    Boolean lint;
+
     /* -dV: for the -V option, print unexpanded variable values */
     Boolean debugVflag;
 
diff -r 545b1ef91ae9 -r 5092d7b21ce3 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sun Nov 08 23:30:59 2020 +0000
+++ b/usr.bin/make/parse.c      Sun Nov 08 23:38:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.436 2020/11/08 19:53:11 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.437 2020/11/08 23:38:02 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.436 2020/11/08 19:53:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.437 2020/11/08 23:38:02 rillig Exp $");
 
 /* types and constants */
 
@@ -1884,7 +1884,7 @@
 static void
 VarCheckSyntax(VarAssignOp type, const char *uvalue, GNode *ctxt)
 {
-    if (DEBUG(LINT)) {
+    if (opts.lint) {
        if (type != VAR_SUBST && strchr(uvalue, '$') != NULL) {
            /* Check for syntax errors such as unclosed expressions or
             * unknown modifiers. */
@@ -3032,7 +3032,7 @@
      * Var_Parse does not print any parse errors in such a case.
      * It simply returns the special empty string var_Error,
      * which cannot be detected in the result of Var_Subst. */
-    eflags = DEBUG(LINT) ? VARE_WANTRES : VARE_WANTRES | VARE_UNDEFERR;
+    eflags = opts.lint ? VARE_WANTRES : VARE_WANTRES | VARE_UNDEFERR;
     (void)Var_Subst(line, VAR_CMDLINE, eflags, &expanded_line);
     /* TODO: handle errors */
 
diff -r 545b1ef91ae9 -r 5092d7b21ce3 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Nov 08 23:30:59 2020 +0000
+++ b/usr.bin/make/var.c        Sun Nov 08 23:38:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.682 2020/11/08 19:53:11 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.683 2020/11/08 23:38:02 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.682 2020/11/08 19:53:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.683 2020/11/08 23:38:02 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -2077,7 +2077,7 @@
                            &args.tvar, NULL, NULL, NULL);
     if (res != VPR_OK)
        return AMR_CLEANUP;
-    if (DEBUG(LINT) && strchr(args.tvar, '$') != NULL) {
+    if (opts.lint && strchr(args.tvar, '$') != NULL) {
        Parse_Error(PARSE_FATAL,
                    "In the :@ modifier of \"%s\", the variable name \"%s\" "
                    "must not contain a dollar.",
@@ -3278,7 +3278,7 @@
      * is not accepted, but ${VAR:${M_1}:${M_2}} is.
      */
     if (mods[0] != '\0' && *p != '\0' && *p != ':' && *p != st->endc) {
-       if (DEBUG(LINT))
+       if (opts.lint)
            Parse_Error(PARSE_FATAL,
                        "Missing delimiter ':' after indirect modifier \"%.*s\"",
                        (int)(p - *inout_p), *inout_p);
@@ -3414,7 +3414,7 @@
                  st.endc, st.v->name, st.val, *mod);
        } else if (*p == ':') {
            p++;
-       } else if (DEBUG(LINT) && *p != '\0' && *p != endc) {
+       } else if (opts.lint && *p != '\0' && *p != endc) {
            Parse_Error(PARSE_FATAL,
                        "Missing delimiter ':' after modifier \"%.*s\"",
                        (int)(p - mod), mod);
@@ -3549,7 +3549,7 @@
        return VPR_OK;
     }
 
-    if (!DEBUG(LINT))
+    if (!opts.lint)
        return VPR_PARSE_SILENT;
 
     if (varname == '$')
@@ -3597,7 +3597,7 @@
        *pp += 2;
 
        *out_FALSE_val = UndefinedShortVarValue(startc, ctxt, eflags);
-       if (DEBUG(LINT) && *out_FALSE_val == var_Error) {
+       if (opts.lint && *out_FALSE_val == var_Error) {
            Parse_Error(PARSE_FATAL, "Variable \"%s\" is undefined", name);
            *out_FALSE_res = VPR_UNDEF_MSG;
            return FALSE;
@@ -3654,7 +3654,7 @@
        return VPR_OK;
     }
 
-    if ((eflags & VARE_UNDEFERR) && DEBUG(LINT)) {
+    if ((eflags & VARE_UNDEFERR) && opts.lint) {
        Parse_Error(PARSE_FATAL, "Variable \"%s\" is undefined", varname);
        free(varname);
        *out_val = var_Error;
@@ -3864,7 +3864,7 @@
      * variable value. */
     if (strchr(value, '$') != NULL && (eflags & VARE_WANTRES)) {
        VarEvalFlags nested_eflags = eflags;
-       if (DEBUG(LINT))
+       if (opts.lint)
            nested_eflags &= ~(unsigned)VARE_UNDEFERR;
        v->flags |= VAR_IN_USE;
        (void)Var_Subst(value, ctxt, nested_eflags, &value);



Home | Main Index | Thread Index | Old Index