Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/indent indent: in debug mode, log only differences f...



details:   https://anonhg.NetBSD.org/src/rev/05c985784340
branches:  trunk
changeset: 990528:05c985784340
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 29 21:31:29 2021 +0000

description:
indent: in debug mode, log only differences for most ps members

diffstat:

 usr.bin/indent/lexi.c |  21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diffs (56 lines):

diff -r 6d16e8f75ea5 -r 05c985784340 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Fri Oct 29 21:22:05 2021 +0000
+++ b/usr.bin/indent/lexi.c     Fri Oct 29 21:31:29 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.112 2021/10/29 21:22:05 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.113 2021/10/29 21:31:29 rillig Exp $        */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.112 2021/10/29 21:22:05 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.113 2021/10/29 21:31:29 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -295,17 +295,24 @@
 }
 
 #define debug_ps_bool(name) \
-       debug_println("[%c] " #name, ps.name ? 'x' : ' ')
+        if (ps.name != prev_ps.name) \
+           debug_println("[%c] ps." #name, ps.name ? 'x' : ' ')
 #define debug_ps_int(name) \
-       if (ps.name != 0) \
-           debug_println("%3d " #name, ps.name)
+       if (ps.name != prev_ps.name) \
+           debug_println("%3d ps." #name, ps.name)
 #define debug_ps_keyword(name) \
        if (ps.name != kw_0) \
-           debug_println("    " #name " = %s", kw_name(ps.name))
+           debug_println("    ps." #name " = %s", kw_name(ps.name))
 
 static void
 debug_lexi(lexer_symbol lsym)
 {
+    /*
+     * Watch out for 'rolled back parser state' in the debug output; the
+     * differences around these are unreliable.
+     */
+    static struct parser_state prev_ps;
+
     debug_println("");
     debug_printf("line %d\n", line_no);
     debug_print_buf("label", &lab);
@@ -351,6 +358,8 @@
     debug_ps_bool(is_case_label);
 
     debug_ps_bool(search_stmt);
+
+    prev_ps = ps;
 }
 #endif
 



Home | Main Index | Thread Index | Old Index