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: add debug logging for switching the i...



details:   https://anonhg.NetBSD.org/src/rev/a9ffacf12214
branches:  trunk
changeset: 981500:a9ffacf12214
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Mar 13 18:46:39 2021 +0000

description:
indent: add debug logging for switching the input buffer

No functional change outside debug mode.

diffstat:

 usr.bin/indent/indent.c |  19 +++++++++++++------
 usr.bin/indent/io.c     |   5 +++--
 2 files changed, 16 insertions(+), 8 deletions(-)

diffs (87 lines):

diff -r 09bfcba88521 -r a9ffacf12214 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sat Mar 13 18:24:56 2021 +0000
+++ b/usr.bin/indent/indent.c   Sat Mar 13 18:46:39 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.57 2021/03/13 13:51:08 rillig Exp $       */
+/*     $NetBSD: indent.c,v 1.58 2021/03/13 18:46:39 rillig Exp $       */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
 #include <sys/cdefs.h>
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.57 2021/03/13 13:51:08 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.58 2021/03/13 18:46:39 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -314,6 +314,7 @@
            *sc_end++ = ' ';    /* add trailing blank, just in case */
            buf_end = sc_end;
            sc_end = NULL;
+           debug_println("switched buf_ptr to save_com");
            break;
        }
        }                       /* end of switch */
@@ -640,11 +641,17 @@
        *e_code++ = ' ';
     ps.want_blank = false;
     *e_code++ = token[0];
+
     ps.paren_indents[ps.p_l_follow - 1] =
        indentation_after_range(0, s_code, e_code);
+    debug_println("paren_indent[%d] is now %d",
+       ps.p_l_follow - 1, ps.paren_indents[ps.p_l_follow - 1]);
+
     if (sp_sw && ps.p_l_follow == 1 && opt.extra_expression_indent
-           && ps.paren_indents[0] < 2 * opt.indent_size)
+           && ps.paren_indents[0] < 2 * opt.indent_size) {
        ps.paren_indents[0] = 2 * opt.indent_size;
+       debug_println("paren_indent[0] is now %d", ps.paren_indents[0]);
+    }
     if (ps.in_or_st && *token == '(' && ps.tos <= 2) {
        /*
         * this is a kluge to make sure that declarations will be
@@ -1196,12 +1203,12 @@
                e_lab--;
            bp_save = buf_ptr;  /* save current input buffer */
            be_save = buf_end;
-           buf_ptr = save_com; /* fix so that subsequent calls to
-                                        * lexi will take tokens out of
-                                        * save_com */
+           buf_ptr = save_com; /* fix so that subsequent calls to lexi will
+                                * take tokens out of save_com */
            *sc_end++ = ' ';    /* add trailing blank, just in case */
            buf_end = sc_end;
            sc_end = NULL;
+           debug_println("switched buf_ptr to save_com");
        }
        check_size_label(1);
        *e_lab = '\0';  /* null terminate line */
diff -r 09bfcba88521 -r a9ffacf12214 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Sat Mar 13 18:24:56 2021 +0000
+++ b/usr.bin/indent/io.c       Sat Mar 13 18:46:39 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.46 2021/03/13 18:24:56 rillig Exp $   */
+/*     $NetBSD: io.c,v 1.47 2021/03/13 18:46:39 rillig Exp $   */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
 #include <sys/cdefs.h>
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.46 2021/03/13 18:24:56 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.47 2021/03/13 18:46:39 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -346,6 +346,7 @@
        buf_ptr = bp_save;      /* do not read anything, just switch buffers */
        buf_end = be_save;
        bp_save = be_save = NULL;
+       debug_println("switched buf_ptr back to bp_save");
        if (buf_ptr < buf_end)
            return;             /* only return if there is really something in
                                 * this buffer */



Home | Main Index | Thread Index | Old Index