Module Name: src
Committed By: rillig
Date: Thu Oct 7 22:56:49 UTC 2021
Modified Files:
src/usr.bin/indent: args.c indent.c indent_globs.h parse.c
Log Message:
indent: rename opt.btype_2 to brace_same_line
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/usr.bin/indent/args.c
cvs rdiff -u -r1.121 -r1.122 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.44 -r1.45 src/usr.bin/indent/indent_globs.h
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/indent/parse.c
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.50 src/usr.bin/indent/args.c:1.51
--- src/usr.bin/indent/args.c:1.50 Thu Oct 7 21:41:59 2021
+++ src/usr.bin/indent/args.c Thu Oct 7 22:56:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: args.c,v 1.50 2021/10/07 21:41:59 rillig Exp $ */
+/* $NetBSD: args.c,v 1.51 2021/10/07 22:56:49 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.50 2021/10/07 21:41:59 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.51 2021/10/07 22:56:49 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
#endif
@@ -94,8 +94,8 @@ static const struct pro {
bool_options("bap", blanklines_after_procs),
bool_options("bbb", blanklines_before_blockcomments),
bool_options("bc", break_after_comma),
- bool_option("bl", false, btype_2),
- bool_option("br", true, btype_2),
+ bool_option("bl", false, brace_same_line),
+ bool_option("br", true, brace_same_line),
bool_options("bs", blank_after_sizeof),
int_option("c", comment_column),
int_option("cd", decl_comment_column),
Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.121 src/usr.bin/indent/indent.c:1.122
--- src/usr.bin/indent/indent.c:1.121 Thu Oct 7 22:52:13 2021
+++ src/usr.bin/indent/indent.c Thu Oct 7 22:56:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.121 2021/10/07 22:52:13 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.122 2021/10/07 22:56:49 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.121 2021/10/07 22:52:13 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.122 2021/10/07 22:56:49 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,7 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
#include "indent.h"
struct options opt = {
- .btype_2 = true,
+ .brace_same_line = true,
.comment_delimiter_on_blankline = true,
.cuddle_else = true,
.comment_column = 33,
@@ -209,7 +209,7 @@ search_brace_lbrace(void)
* Put KNF-style lbraces before the buffered up tokens and jump out of
* this loop in order to avoid copying the token again.
*/
- if (sc_end != NULL && opt.btype_2) {
+ if (sc_end != NULL && opt.brace_same_line) {
save_com[0] = '{';
/*
* Originally the lbrace may have been alone on its own line, but it
@@ -576,7 +576,7 @@ process_comment_in_code(token_type ttype
{
if (*force_nl &&
ttype != semicolon &&
- (ttype != lbrace || !opt.btype_2)) {
+ (ttype != lbrace || !opt.brace_same_line)) {
/* we should force a broken line here */
if (opt.verbose)
@@ -712,10 +712,12 @@ process_rparen_or_rbracket(bool *sp_sw,
parse(hd_type); /* let parser worry about if, or whatever */
}
- ps.search_brace = opt.btype_2; /* this should ensure that constructs
- * such as main(){...} and int[]{...}
- * have their braces put in the right
- * place */
+
+ /*
+ * This should ensure that constructs such as main(){...} and int[]{...}
+ * have their braces put in the right place.
+ */
+ ps.search_brace = opt.brace_same_line;
}
static void
@@ -863,7 +865,7 @@ process_lbrace(bool *force_nl, bool *sp_
ps.block_init_level++;
if (code.s != code.e && !ps.block_init) {
- if (!opt.btype_2) {
+ if (!opt.brace_same_line) {
dump_line();
ps.want_blank = false;
} else if (ps.in_parameter_declaration && !ps.in_or_st) {
Index: src/usr.bin/indent/indent_globs.h
diff -u src/usr.bin/indent/indent_globs.h:1.44 src/usr.bin/indent/indent_globs.h:1.45
--- src/usr.bin/indent/indent_globs.h:1.44 Thu Oct 7 21:41:59 2021
+++ src/usr.bin/indent/indent_globs.h Thu Oct 7 22:56:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent_globs.h,v 1.44 2021/10/07 21:41:59 rillig Exp $ */
+/* $NetBSD: indent_globs.h,v 1.45 2021/10/07 22:56:49 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -90,7 +90,7 @@ extern struct options {
bool blanklines_before_blockcomments;
bool break_after_comma; /* whether to break declarations after
* commas */
- bool btype_2; /* whether brace should be on same line
+ bool brace_same_line;/* whether brace should be on same line
* as if, while, etc */
bool blank_after_sizeof; /* whether a blank should always be
* inserted after sizeof */
Index: src/usr.bin/indent/parse.c
diff -u src/usr.bin/indent/parse.c:1.32 src/usr.bin/indent/parse.c:1.33
--- src/usr.bin/indent/parse.c:1.32 Thu Oct 7 21:52:54 2021
+++ src/usr.bin/indent/parse.c Thu Oct 7 22:56:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.32 2021/10/07 21:52:54 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.33 2021/10/07 22:56:49 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -77,7 +77,7 @@ parse(token_type ttype)
switch (ttype) {
case decl: /* scanned a declaration word */
- ps.search_brace = opt.btype_2;
+ ps.search_brace = opt.brace_same_line;
/* indicate that following brace should be on same line */
if (ps.p_stack[ps.tos] != decl) { /* only put one declaration
@@ -112,7 +112,7 @@ parse(token_type ttype)
ps.p_stack[++ps.tos] = ttype;
ps.il[ps.tos] = ps.ind_level = ps.ind_level_follow;
++ps.ind_level_follow; /* subsequent statements should be indented 1 */
- ps.search_brace = opt.btype_2;
+ ps.search_brace = opt.brace_same_line;
break;
case lbrace:
@@ -152,7 +152,7 @@ parse(token_type ttype)
ps.p_stack[++ps.tos] = while_expr;
ps.il[ps.tos] = ps.ind_level_follow;
++ps.ind_level_follow;
- ps.search_brace = opt.btype_2;
+ ps.search_brace = opt.brace_same_line;
}
break;
@@ -166,7 +166,7 @@ parse(token_type ttype)
ps.ind_level_follow = ps.ind_level + 1;
ps.p_stack[ps.tos] = if_expr_stmt_else;
/* remember if with else */
- ps.search_brace = opt.btype_2 | opt.else_if;
+ ps.search_brace = opt.brace_same_line | opt.else_if;
}
break;
@@ -188,7 +188,7 @@ parse(token_type ttype)
case_ind = (float)ps.ind_level_follow + opt.case_indent;
/* statements should be two levels deeper */
ps.ind_level_follow += (int)opt.case_indent + 1;
- ps.search_brace = opt.btype_2;
+ ps.search_brace = opt.brace_same_line;
break;
case semicolon: /* this indicates a simple stmt */