Module Name:    src
Committed By:   rillig
Date:           Sun Sep 26 19:57:23 UTC 2021

Modified Files:
        src/usr.bin/indent: args.c indent.c indent_globs.h

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/indent/args.c
cvs rdiff -u -r1.86 -r1.87 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/indent/indent_globs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.33 src/usr.bin/indent/args.c:1.34
--- src/usr.bin/indent/args.c:1.33	Sun Sep 26 19:37:11 2021
+++ src/usr.bin/indent/args.c	Sun Sep 26 19:57:23 2021
@@ -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 @@ static char sccsid[] = "@(#)args.c	8.1 (
 
 #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 @@ static const struct pro {
     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 @@ static const struct pro {
     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),

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.86 src/usr.bin/indent/indent.c:1.87
--- src/usr.bin/indent/indent.c:1.86	Sun Sep 26 19:37:11 2021
+++ src/usr.bin/indent/indent.c	Sun Sep 26 19:57:23 2021
@@ -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 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #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 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 #include "indent.h"
 
 struct options opt = {
-    .leave_comma = true,
     .btype_2 = true,
     .comment_delimiter_on_blankline = true,
     .cuddle_else = true,
@@ -556,8 +555,8 @@ process_form_feed(void)
 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 @@ process_comma(int dec_ind, bool tabs_to_
     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))

Index: src/usr.bin/indent/indent_globs.h
diff -u src/usr.bin/indent/indent_globs.h:1.37 src/usr.bin/indent/indent_globs.h:1.38
--- src/usr.bin/indent/indent_globs.h:1.37	Sat Sep 25 22:57:04 2021
+++ src/usr.bin/indent/indent_globs.h	Sun Sep 26 19:57:23 2021
@@ -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 @@ extern struct options {
     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 */

Reply via email to