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: negate and rename option.leave_comma



details:   https://anonhg.NetBSD.org/src/rev/314e25684bd9
branches:  trunk
changeset: 1023812:314e25684bd9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Sep 26 19:57:23 2021 +0000

description:
indent: negate and rename option.leave_comma

The old name did not mirror the description in the manual page, and it
was the only option that is negated. Inverting it allows the options
table to be compressed.

diffstat:

 usr.bin/indent/args.c         |   8 ++++----
 usr.bin/indent/indent.c       |  11 +++++------
 usr.bin/indent/indent_globs.h |   4 ++--
 3 files changed, 11 insertions(+), 12 deletions(-)

diffs (100 lines):

diff -r ef1023517163 -r 314e25684bd9 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c     Sun Sep 26 19:37:11 2021 +0000
+++ b/usr.bin/indent/args.c     Sun Sep 26 19:57:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: args.c,v 1.33 2021/09/26 19:37:11 rillig Exp $ */
+/*     $NetBSD: args.c,v 1.34 2021/09/26 19:57:23 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.33 2021/09/26 19:37:11 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.34 2021/09/26 19:57:23 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
@@ -97,7 +97,7 @@
     bool_option("bad", true, opt.blanklines_after_declarations),
     bool_option("bap", true, opt.blanklines_after_procs),
     bool_option("bbb", true, opt.blanklines_before_blockcomments),
-    bool_option("bc", false, opt.leave_comma),
+    bool_option("bc", true, opt.break_after_comma),
     bool_option("bl", false, opt.btype_2),
     bool_option("br", true, opt.btype_2),
     bool_option("bs", true, opt.blank_after_sizeof),
@@ -127,7 +127,7 @@
     bool_option("nbad", false, opt.blanklines_after_declarations),
     bool_option("nbap", false, opt.blanklines_after_procs),
     bool_option("nbbb", false, opt.blanklines_before_blockcomments),
-    bool_option("nbc", true, opt.leave_comma),
+    bool_option("nbc", false, opt.break_after_comma),
     bool_option("nbs", false, opt.blank_after_sizeof),
     bool_option("ncdb", false, opt.comment_delimiter_on_blankline),
     bool_option("nce", false, opt.cuddle_else),
diff -r ef1023517163 -r 314e25684bd9 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sun Sep 26 19:37:11 2021 +0000
+++ b/usr.bin/indent/indent.c   Sun Sep 26 19:57:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.86 2021/09/26 19:37:11 rillig Exp $       */
+/*     $NetBSD: indent.c,v 1.87 2021/09/26 19:57:23 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.86 2021/09/26 19:37:11 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.87 2021/09/26 19:57:23 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -65,7 +65,6 @@
 #include "indent.h"
 
 struct options opt = {
-    .leave_comma = true,
     .btype_2 = true,
     .comment_delimiter_on_blankline = true,
     .cuddle_else = true,
@@ -556,8 +555,8 @@
 static void
 process_newline(void)
 {
-    if (ps.last_token != comma || ps.p_l_follow > 0
-       || !opt.leave_comma || ps.block_init || !break_comma || com.s != com.e) {
+    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;
     }
@@ -1047,7 +1046,7 @@
     if (ps.p_l_follow == 0) {
        if (ps.block_init_level <= 0)
            ps.block_init = false;
-       if (break_comma && (!opt.leave_comma ||
+       if (break_comma && (opt.break_after_comma ||
                            indentation_after_range(
                                    compute_code_indent(), code.s, code.e)
                            >= opt.max_line_length - opt.tabsize))
diff -r ef1023517163 -r 314e25684bd9 usr.bin/indent/indent_globs.h
--- a/usr.bin/indent/indent_globs.h     Sun Sep 26 19:37:11 2021 +0000
+++ b/usr.bin/indent/indent_globs.h     Sun Sep 26 19:57:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent_globs.h,v 1.37 2021/09/25 22:57:04 rillig Exp $ */
+/*     $NetBSD: indent_globs.h,v 1.38 2021/09/26 19:57:23 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -89,7 +89,7 @@
     bool       blanklines_after_declarations;
     bool       blanklines_after_procs;
     bool       blanklines_before_blockcomments;
-    bool       leave_comma;    /* if true, never break declarations after
+    bool       break_after_comma; /* whether to break declarations after
                                 * commas */
     bool       btype_2;        /* whether brace should be on same line
                                 * as if, while, etc */



Home | Main Index | Thread Index | Old Index