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 misleading variable



details:   https://anonhg.NetBSD.org/src/rev/3c05ecaa6e5b
branches:  trunk
changeset: 376337:3c05ecaa6e5b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jun 10 21:36:38 2023 +0000

description:
indent: rename misleading variable

The name started with 'line_start', but the value is not always the
value from the beginning of the line.

No functional change.

diffstat:

 usr.bin/indent/debug.c  |   6 +++---
 usr.bin/indent/indent.c |  16 ++++++++--------
 usr.bin/indent/indent.h |   9 ++++-----
 usr.bin/indent/io.c     |  10 +++++-----
 4 files changed, 20 insertions(+), 21 deletions(-)

diffs (167 lines):

diff -r cced9a4ab10f -r 3c05ecaa6e5b usr.bin/indent/debug.c
--- a/usr.bin/indent/debug.c    Sat Jun 10 20:37:12 2023 +0000
+++ b/usr.bin/indent/debug.c    Sat Jun 10 21:36:38 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: debug.c,v 1.52 2023/06/10 20:37:12 rillig Exp $        */
+/*     $NetBSD: debug.c,v 1.53 2023/06/10 21:36:38 rillig Exp $        */
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: debug.c,v 1.52 2023/06/10 20:37:12 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.53 2023/06/10 21:36:38 rillig Exp $");
 
 #include <stdarg.h>
 #include <string.h>
@@ -360,7 +360,7 @@ debug_parser_state(void)
        state.heading = "spacing inside a statement or declaration";
        debug_ps_bool(next_unary);
        debug_ps_bool(want_blank);
-       debug_ps_int(line_start_nparen);
+       debug_ps_int(ind_paren_level);
        debug_ps_int(nparen);
        debug_ps_paren();
 
diff -r cced9a4ab10f -r 3c05ecaa6e5b usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sat Jun 10 20:37:12 2023 +0000
+++ b/usr.bin/indent/indent.c   Sat Jun 10 21:36:38 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.356 2023/06/10 20:37:12 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.357 2023/06/10 21:36:38 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.356 2023/06/10 20:37:12 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.357 2023/06/10 21:36:38 rillig Exp $");
 
 #include <sys/param.h>
 #include <err.h>
@@ -378,7 +378,7 @@ is_function_pointer_declaration(void)
            && !ps.in_init
            && !ps.decl_indent_done
            && !ps.line_has_func_def
-           && ps.line_start_nparen == 0;
+           && ps.ind_paren_level == 0;
 }
 
 static int
@@ -580,7 +580,7 @@ process_rparen(void)
                ps.want_blank = true;
 
        if (code.len == 0)
-               ps.line_start_nparen = ps.nparen;
+               ps.ind_paren_level = ps.nparen;
 
 unbalanced:
        buf_add_char(&code, token.s[0]);
@@ -631,7 +631,7 @@ process_rbracket(void)
 
        ps.want_blank = true;
        if (code.len == 0)
-               ps.line_start_nparen = ps.nparen;
+               ps.ind_paren_level = ps.nparen;
 
 unbalanced:
        buf_add_char(&code, token.s[0]);
@@ -788,7 +788,7 @@ process_comma(void)
                                         * does not start the line */
 
        if (ps.in_decl && !ps.line_has_func_def && !ps.in_init &&
-           !ps.decl_indent_done && ps.line_start_nparen == 0) {
+           !ps.decl_indent_done && ps.ind_paren_level == 0) {
                /* indent leading commas and not the actual identifiers */
                indent_declarator(ps.decl_ind - 1, ps.tabs_to_var);
        }
@@ -844,7 +844,7 @@ process_semicolon(void)
        ps.declaration = ps.declaration == decl_begin ? decl_end : decl_no;
 
        if (ps.in_decl && code.len == 0 && !ps.in_init &&
-           !ps.decl_indent_done && ps.line_start_nparen == 0) {
+           !ps.decl_indent_done && ps.ind_paren_level == 0) {
                /* indent stray semicolons in declarations */
                indent_declarator(ps.decl_ind - 1, ps.tabs_to_var);
        }
@@ -915,7 +915,7 @@ process_word(lexer_symbol lsym)
                        ps.want_blank = false;
 
                } else if (!ps.in_init && !ps.decl_indent_done &&
-                   ps.line_start_nparen == 0) {
+                   ps.ind_paren_level == 0) {
                        if (opt.decl_indent == 0
                            && code.len > 0 && code.s[code.len - 1] == '}')
                                ps.decl_ind = ind_add(0, code.s, code.len) + 1;
diff -r cced9a4ab10f -r 3c05ecaa6e5b usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Sat Jun 10 20:37:12 2023 +0000
+++ b/usr.bin/indent/indent.h   Sat Jun 10 21:36:38 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.187 2023/06/10 16:43:56 rillig Exp $      */
+/*     $NetBSD: indent.h,v 1.188 2023/06/10 21:36:38 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -368,10 +368,9 @@ extern struct parser_state {
        bool want_blank;        /* whether the following token should be
                                 * prefixed by a blank. (Said prefixing is
                                 * ignored in some cases.) */
-       int line_start_nparen;  /* the number of parentheses or brackets that
-                                * were open at the beginning of the current
-                                * line; used to indent within statements,
-                                * initializers and declarations */
+       int ind_paren_level;    /* the number of parentheses or brackets that
+                                * is used for indenting a continuation line of
+                                * a declaration, initializer or statement */
        int nparen;             /* the number of parentheses or brackets that
                                 * are currently open; used to indent the
                                 * remaining lines of the statement,
diff -r cced9a4ab10f -r 3c05ecaa6e5b usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Sat Jun 10 20:37:12 2023 +0000
+++ b/usr.bin/indent/io.c       Sat Jun 10 21:36:38 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.216 2023/06/10 16:43:56 rillig Exp $  */
+/*     $NetBSD: io.c,v 1.217 2023/06/10 21:36:38 rillig Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: io.c,v 1.216 2023/06/10 16:43:56 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.217 2023/06/10 21:36:38 rillig Exp $");
 
 #include <stdio.h>
 
@@ -249,7 +249,7 @@ compute_code_indent(void)
 {
        int base_ind = ps.ind_level * opt.indent_size;
 
-       if (ps.line_start_nparen == 0) {
+       if (ps.ind_paren_level == 0) {
                if (ps.psyms.top >= 1
                    && ps.psyms.sym[ps.psyms.top - 1] == psym_lbrace_enum)
                        return base_ind;
@@ -264,7 +264,7 @@ compute_code_indent(void)
                return compute_lined_up_code_indent(base_ind);
        }
 
-       int rel_ind = opt.continuation_indent * ps.line_start_nparen;
+       int rel_ind = opt.continuation_indent * ps.ind_paren_level;
        if (ps.extra_expr_indent != eei_no && rel_ind == opt.indent_size)
                rel_ind += opt.continuation_indent;
        return base_ind + rel_ind;
@@ -397,7 +397,7 @@ output_line(void)
        if (!(ps.psyms.sym[ps.psyms.top] == psym_if_expr_stmt_else
                && ps.nparen > 0))
                ps.ind_level = ps.ind_level_follow;
-       ps.line_start_nparen = ps.nparen;
+       ps.ind_paren_level = ps.nparen;
        ps.want_blank = false;
 
        if (ps.nparen > 0) {



Home | Main Index | Thread Index | Old Index