Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 lint: indent node details in debug mode



details:   https://anonhg.NetBSD.org/src/rev/011097ff15fc
branches:  trunk
changeset: 959644:011097ff15fc
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 21 07:21:57 2021 +0000

description:
lint: indent node details in debug mode

diffstat:

 usr.bin/xlint/lint1/externs1.h |   4 ++--
 usr.bin/xlint/lint1/init.c     |   6 +++---
 usr.bin/xlint/lint1/tree.c     |  18 +++++++-----------
 3 files changed, 12 insertions(+), 16 deletions(-)

diffs (107 lines):

diff -r 869cdd5d7f65 -r 011097ff15fc usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Sun Feb 21 02:29:56 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Sun Feb 21 07:21:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.68 2021/02/20 16:34:57 rillig Exp $     */
+/*     $NetBSD: externs1.h,v 1.69 2021/02/21 07:21:57 rillig Exp $     */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -223,7 +223,7 @@
 extern strg_t  *cat_strings(strg_t *, strg_t *);
 extern  int64_t tsize(type_t *);
 #ifdef DEBUG
-extern void    debug_node(const tnode_t *);
+extern void    debug_node(const tnode_t *, int);
 #else
 #define debug_node(tn) (void)0
 #endif
diff -r 869cdd5d7f65 -r 011097ff15fc usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Sun Feb 21 02:29:56 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Sun Feb 21 07:21:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.75 2021/02/20 19:56:44 rillig Exp $ */
+/*     $NetBSD: init.c,v 1.76 2021/02/21 07:21:57 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.75 2021/02/20 19:56:44 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.76 2021/02/21 07:21:57 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -699,7 +699,7 @@
 
        debug_enter();
        debug_named_member();
-       debug_node(tn);
+       debug_node(tn, debug_ind);
        debug_initstack();
 
        if (initerr || tn == NULL) {
diff -r 869cdd5d7f65 -r 011097ff15fc usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sun Feb 21 02:29:56 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sun Feb 21 07:21:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.212 2021/02/20 19:10:38 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.213 2021/02/21 07:21:57 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.212 2021/02/20 19:10:38 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.213 2021/02/21 07:21:57 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -99,10 +99,8 @@
 
 #ifdef DEBUG
 void
-debug_node(const tnode_t *tn)
+debug_node(const tnode_t *tn, int indent)
 {
-       static int indent = 0;
-
        op_t op;
 
        if (tn == NULL) {
@@ -112,7 +110,7 @@
 
        op = tn->tn_op;
        printf("%*s%s: %s%s%s",
-           indent, "",
+           2 * indent, "",
            op == CVT && !tn->tn_cast ? "convert" :
                op == NAME ? "name" : getopname(op),
            type_name(tn->tn_type), tn->tn_lvalue ? " lvalue" : "",
@@ -133,11 +131,9 @@
        else {
                printf("\n");
 
-               indent += 2;
-               debug_node(tn->tn_left);
+               debug_node(tn->tn_left, indent + 1);
                if (modtab[op].m_binary || tn->tn_right != NULL)
-                       debug_node(tn->tn_right);
-               indent -= 2;
+                       debug_node(tn->tn_right, indent + 1);
        }
 }
 #endif
@@ -4347,7 +4343,7 @@
        if (!hflag)
                return;
 
-       debug_node(tn);
+       debug_node(tn, 0);
 
        lint_assert(modtab[tn->tn_op].m_binary);
        for (ln = tn->tn_left; ln->tn_op == CVT; ln = ln->tn_left)



Home | Main Index | Thread Index | Old Index