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: move dprint_node to the top of the...



details:   https://anonhg.NetBSD.org/src/rev/840209eaba9e
branches:  trunk
changeset: 958433:840209eaba9e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jan 04 21:17:31 2021 +0000

description:
lint: move dprint_node to the top of the file

It now resides right below dumpnode, which implements the same idea but
uses a fixed-size output buffer and prints everything in a single line,
which quickly gets hard to read.  Maybe that's the reason why it had
been commented out since it got added in 2014.

diffstat:

 usr.bin/xlint/lint1/tree.c |  88 +++++++++++++++++++++++-----------------------
 1 files changed, 44 insertions(+), 44 deletions(-)

diffs (116 lines):

diff -r 597c228f6eea -r 840209eaba9e usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Mon Jan 04 18:27:46 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Mon Jan 04 21:17:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.124 2021/01/04 17:06:20 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.125 2021/01/04 21:17:31 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.124 2021/01/04 17:06:20 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.125 2021/01/04 21:17:31 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -129,6 +129,48 @@
 }
 #endif
 
+#ifdef DEBUG
+static void
+dprint_node(const tnode_t *tn)
+{
+       static int indent = 0;
+
+       op_t op = tn->tn_op;
+
+       if (tn == NULL) {
+               printf("%*s" "null\n", indent, "");
+               return;
+       }
+
+       printf("%*s%s: %s%s%s",
+           indent, "",
+           op == CVT && !tn->tn_cast ? "convert" :
+               op == NAME ? "name" : getopname(op),
+           type_name(tn->tn_type), tn->tn_lvalue ? " lvalue" : "",
+           tn->tn_parenthesized ? " ()" : "");
+       indent += 2;
+       if (op == NAME)
+               printf(" %s\n", tn->tn_sym->s_name);
+       else if (op == CON)
+               printf(" value=?\n");
+       else if (op == STRING)
+               printf(" length=%zu\n", tn->tn_string->st_len);
+       else {
+               printf("\n");
+               dprint_node(tn->tn_left);
+               if (modtab[op].m_binary)
+                       dprint_node(tn->tn_right);
+       }
+       indent -= 2;
+}
+#else
+/*ARGSUSED*/
+static void
+dprint_node(const tnode_t *tn)
+{
+}
+#endif
+
 /*
  * Increase degree of reference.
  * This is most often used to change type "T" in type "pointer to T".
@@ -3972,48 +4014,6 @@
        return strg1;
 }
 
-#ifdef DEBUG
-static void
-dprint_node(const tnode_t *tn)
-{
-       static int indent = 0;
-
-       op_t op = tn->tn_op;
-
-       if (tn == NULL) {
-               printf("%*s" "null\n", indent, "");
-               return;
-       }
-
-       printf("%*s%s: %s%s%s",
-           indent, "",
-           op == CVT && !tn->tn_cast ? "convert" :
-           op == NAME ? "name" : getopname(op),
-           type_name(tn->tn_type), tn->tn_lvalue ? " lvalue" : "",
-           tn->tn_parenthesized ? " ()" : "");
-       indent += 2;
-       if (op == NAME)
-               printf(" %s\n", tn->tn_sym->s_name);
-       else if (op == CON)
-               printf(" value=?\n");
-       else if (op == STRING)
-               printf(" length=%zu\n", tn->tn_string->st_len);
-       else {
-               printf("\n");
-               dprint_node(tn->tn_left);
-               if (modtab[op].m_binary)
-                       dprint_node(tn->tn_right);
-       }
-       indent -= 2;
-}
-#else
-/*ARGSUSED*/
-static void
-dprint_node(const tnode_t *tn)
-{
-}
-#endif
-
 /*
  * Print a warning if the given node has operands which should be
  * parenthesized.



Home | Main Index | Thread Index | Old Index