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: invert condition in process_newline



details:   https://anonhg.NetBSD.org/src/rev/f86570026ac5
branches:  trunk
changeset: 1024350:f86570026ac5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Oct 20 05:07:08 2021 +0000

description:
indent: invert condition in process_newline

It's hard to follow a condition that combines many negated terms with
'||'. Group the conditions by their origin.

The condition '!opt.break_after_comma && break_comma' still sounds like
a contradition, more investigations to follow.

No functional change.

diffstat:

 usr.bin/indent/indent.c |  18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diffs (39 lines):

diff -r d365d9a51c58 -r f86570026ac5 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Wed Oct 20 05:00:37 2021 +0000
+++ b/usr.bin/indent/indent.c   Wed Oct 20 05:07:08 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.140 2021/10/20 05:00:37 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.141 2021/10/20 05:07:08 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.140 2021/10/20 05:00:37 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.141 2021/10/20 05:07:08 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -670,11 +670,15 @@
 static void
 process_newline(void)
 {
-    if (ps.last_token != comma || ps.p_l_follow > 0 || opt.break_after_comma
-       || ps.block_init || !break_comma || com.s != com.e) {
-       dump_line();
-       ps.want_blank = false;
-    }
+    if (ps.last_token == comma && ps.p_l_follow == 0 && !ps.block_init &&
+       !opt.break_after_comma && break_comma &&
+       com.s == com.e)
+       goto stay_in_line;
+
+    dump_line();
+    ps.want_blank = false;
+
+stay_in_line:
     ++line_no;
 }
 



Home | Main Index | Thread Index | Old Index