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: reduce indentation in dump_line



details:   https://anonhg.NetBSD.org/src/rev/99fb2efeb239
branches:  trunk
changeset: 1024035:99fb2efeb239
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 08 17:00:21 2021 +0000

description:
indent: reduce indentation in dump_line

diffstat:

 usr.bin/indent/io.c |  33 +++++++++++++++------------------
 1 files changed, 15 insertions(+), 18 deletions(-)

diffs (68 lines):

diff -r 637e208a37d5 -r 99fb2efeb239 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Fri Oct 08 16:47:42 2021 +0000
+++ b/usr.bin/indent/io.c       Fri Oct 08 17:00:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.80 2021/10/07 23:18:47 rillig Exp $   */
+/*     $NetBSD: io.c,v 1.81 2021/10/08 17:00:21 rillig Exp $   */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.80 2021/10/07 23:18:47 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.81 2021/10/08 17:00:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -197,21 +197,17 @@
            }
 
            int target_col = 1 + compute_code_indent();
-           {
-               int i;
-
-               for (i = 0; i < ps.p_l_follow; i++) {
-                   if (ps.paren_indents[i] >= 0) {
-                       int ind = ps.paren_indents[i];
-                       /*
-                        * XXX: this mix of 'indent' and 'column' smells like
-                        * an off-by-one error.
-                        */
-                       ps.paren_indents[i] = (short)-(ind + target_col);
-                       debug_println(
-                           "setting pi[%d] from %d to %d for column %d",
-                           i, ind, ps.paren_indents[i], target_col);
-                   }
+           for (int i = 0; i < ps.p_l_follow; i++) {
+               if (ps.paren_indents[i] >= 0) {
+                   int ind = ps.paren_indents[i];
+                   /*
+                    * XXX: this mix of 'indent' and 'column' smells like
+                    * an off-by-one error.
+                    */
+                   ps.paren_indents[i] = (short)-(ind + target_col);
+                   debug_println(
+                       "setting pi[%d] from %d to %d for column %d",
+                       i, ind, ps.paren_indents[i], target_col);
                }
            }
 
@@ -228,7 +224,7 @@
            while (*com_st == '\t')     /* consider original indentation in
                                         * case this is a box comment */
                com_st++, target_col += opt.tabsize;
-           while (target_col <= 0)
+           while (target_col <= 0) {
                if (*com_st == ' ')
                    target_col++, com_st++;
                else if (*com_st == '\t') {
@@ -236,6 +232,7 @@
                    com_st++;
                } else
                    target_col = 1;
+           }
            if (cur_col > target_col) { /* if comment can't fit on this line,
                                         * put it on next line */
                output_char('\n');



Home | Main Index | Thread Index | Old Index