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: rename opt.btype_2 to brace_same_line



details:   https://anonhg.NetBSD.org/src/rev/fcab5902c9e1
branches:  trunk
changeset: 988624:fcab5902c9e1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Oct 07 22:56:49 2021 +0000

description:
indent: rename opt.btype_2 to brace_same_line

No functional change.

diffstat:

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

diffs (172 lines):

diff -r 17c19d16337c -r fcab5902c9e1 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c     Thu Oct 07 22:52:13 2021 +0000
+++ b/usr.bin/indent/args.c     Thu Oct 07 22:56:49 2021 +0000
@@ -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 @@
 
 #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 @@
     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),
diff -r 17c19d16337c -r fcab5902c9e1 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Thu Oct 07 22:52:13 2021 +0000
+++ b/usr.bin/indent/indent.c   Thu Oct 07 22:56:49 2021 +0000
@@ -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 @@
 
 #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 @@
 #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 @@
      * 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 @@
 {
     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 @@
 
        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 @@
        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) {
diff -r 17c19d16337c -r fcab5902c9e1 usr.bin/indent/indent_globs.h
--- a/usr.bin/indent/indent_globs.h     Thu Oct 07 22:52:13 2021 +0000
+++ b/usr.bin/indent/indent_globs.h     Thu Oct 07 22:56:49 2021 +0000
@@ -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 @@
     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 */
diff -r 17c19d16337c -r fcab5902c9e1 usr.bin/indent/parse.c
--- a/usr.bin/indent/parse.c    Thu Oct 07 22:52:13 2021 +0000
+++ b/usr.bin/indent/parse.c    Thu Oct 07 22:56:49 2021 +0000
@@ -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 @@
     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 @@
        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 @@
            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 @@
            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 @@
        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 */



Home | Main Index | Thread Index | Old Index