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 negations in process_else, cle...



details:   https://anonhg.NetBSD.org/src/rev/639e2c0feaa7
branches:  trunk
changeset: 1024846:639e2c0feaa7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 07 14:00:35 2021 +0000

description:
indent: reduce negations in process_else, clean up comments

No functional change.

diffstat:

 usr.bin/indent/indent.c |  8 ++++----
 usr.bin/indent/indent.h |  5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diffs (55 lines):

diff -r dd860370e24b -r 639e2c0feaa7 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sun Nov 07 13:47:49 2021 +0000
+++ b/usr.bin/indent/indent.c   Sun Nov 07 14:00:35 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.213 2021/11/07 13:30:15 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.214 2021/11/07 14:00:35 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.213 2021/11/07 13:30:15 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.214 2021/11/07 14:00:35 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -484,7 +484,7 @@
            if (search_stmt_lbrace())
                goto switch_buffer;
            /* FALLTHROUGH */
-       default:                /* it is the start of a normal statement */
+       default:
            if (!search_stmt_other(*lsym, force_nl, comment_buffered,
                    *last_else))
                return;
@@ -1105,7 +1105,7 @@
 {
     ps.in_stmt = false;
 
-    if (code.e > code.s && (!opt.cuddle_else || code.e[-1] != '}')) {
+    if (code.e > code.s && !(opt.cuddle_else && code.e[-1] == '}')) {
        if (opt.verbose)
            diag(0, "Line broken");
        dump_line();            /* make sure this starts a line */
diff -r dd860370e24b -r 639e2c0feaa7 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Sun Nov 07 13:47:49 2021 +0000
+++ b/usr.bin/indent/indent.h   Sun Nov 07 14:00:35 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.83 2021/11/07 13:43:11 rillig Exp $       */
+/*     $NetBSD: indent.h,v 1.84 2021/11/07 14:00:35 rillig Exp $       */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -263,7 +263,8 @@
 #define        STACKSIZE 256
 
 extern struct parser_state {
-    lexer_symbol prev_token;
+    lexer_symbol prev_token;   /* the previous token, but never comment,
+                                * newline or preprocessing line */
     bool curr_col_1;           /* whether the current token started in column
                                 * 1 of the unformatted input */
     bool next_col_1;



Home | Main Index | Thread Index | Old Index