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 state variable to be more accu...



details:   https://anonhg.NetBSD.org/src/rev/712922d8110c
branches:  trunk
changeset: 376392:712922d8110c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jun 15 10:59:06 2023 +0000

description:
indent: rename state variable to be more accurate

No binary change.

diffstat:

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

diffs (145 lines):

diff -r 10a52a5ba77f -r 712922d8110c usr.bin/indent/debug.c
--- a/usr.bin/indent/debug.c    Thu Jun 15 10:34:12 2023 +0000
+++ b/usr.bin/indent/debug.c    Thu Jun 15 10:59:06 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: debug.c,v 1.61 2023/06/14 20:46:08 rillig Exp $        */
+/*     $NetBSD: debug.c,v 1.62 2023/06/15 10:59:06 rillig Exp $        */
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: debug.c,v 1.61 2023/06/14 20:46:08 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.62 2023/06/15 10:59:06 rillig Exp $");
 
 #include <stdarg.h>
 #include <string.h>
@@ -344,7 +344,7 @@ debug_parser_state(void)
        state.heading = "indentation of statements and declarations";
        debug_ps_int(ind_level);
        debug_ps_int(ind_level_follow);
-       debug_ps_bool(in_stmt_cont);
+       debug_ps_bool(line_is_stmt_cont);
        debug_ps_int(decl_level);
        debug_ps_di_stack();
        debug_ps_bool(decl_indent_done);
diff -r 10a52a5ba77f -r 712922d8110c usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Thu Jun 15 10:34:12 2023 +0000
+++ b/usr.bin/indent/indent.c   Thu Jun 15 10:59:06 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.370 2023/06/15 10:34:12 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.371 2023/06/15 10:59:06 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.370 2023/06/15 10:34:12 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.371 2023/06/15 10:59:06 rillig Exp $");
 
 #include <sys/param.h>
 #include <err.h>
@@ -566,7 +566,7 @@ process_newline(void)
            && ps.psyms.sym[ps.psyms.len - 2] == psym_lbrace_enum
            && ps.paren.len == 0
            && ps.prev_lsym == lsym_comma)
-               ps.in_stmt_cont = false;
+               ps.line_is_stmt_cont = false;
 
 stay_in_line:
        ++line_no;
@@ -724,8 +724,7 @@ process_lbrace(void)
        }
 
        if (code.len == 0)
-               ps.in_stmt_cont = false;        /* don't indent the '{' itself
-                                                */
+               ps.line_is_stmt_cont = false;
        if (ps.in_decl && ps.in_var_decl) {
                ps.di_stack[ps.decl_level] = ps.decl_ind;
                if (++ps.decl_level == (int)array_length(ps.di_stack)) {
@@ -768,7 +767,7 @@ process_rbrace(void)
        buf_add_char(&code, '}');
        ps.want_blank = true;
        ps.in_stmt_or_decl = false;     // XXX: Initializers don't end a stmt
-       ps.in_stmt_cont = false;
+       ps.line_is_stmt_cont = false;
 
        if (ps.decl_level > 0) {        /* multi-level structure declaration */
                ps.decl_ind = ps.di_stack[--ps.decl_level];
@@ -925,7 +924,7 @@ process_type_outside_parentheses(void)
        if (ps.in_func_def_params && opt.indent_parameters &&
            ps.decl_level == 0) {
                ps.ind_level = ps.ind_level_follow = 1;
-               ps.in_stmt_cont = false;
+               ps.line_is_stmt_cont = false;
        }
 
        ps.in_var_decl = /* maybe */ true;
diff -r 10a52a5ba77f -r 712922d8110c usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Thu Jun 15 10:34:12 2023 +0000
+++ b/usr.bin/indent/indent.h   Thu Jun 15 10:59:06 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.197 2023/06/14 20:46:08 rillig Exp $      */
+/*     $NetBSD: indent.h,v 1.198 2023/06/15 10:59:06 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -342,7 +342,7 @@ extern struct parser_state {
                                 * currently prepared for output */
        int ind_level_follow;   /* the level to which ind_level should be set
                                 * after the current line is printed */
-       bool in_stmt_cont;      /* whether the current line should have an
+       bool line_is_stmt_cont; /* whether the current line should have an
                                 * extra indentation level because we are in
                                 * the middle of a statement */
        int decl_level;         /* current nesting level for a structure
diff -r 10a52a5ba77f -r 712922d8110c usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Thu Jun 15 10:34:12 2023 +0000
+++ b/usr.bin/indent/io.c       Thu Jun 15 10:59:06 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.223 2023/06/15 10:34:12 rillig Exp $  */
+/*     $NetBSD: io.c,v 1.224 2023/06/15 10:59:06 rillig Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: io.c,v 1.223 2023/06/15 10:34:12 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.224 2023/06/15 10:59:06 rillig Exp $");
 
 #include <stdio.h>
 
@@ -254,7 +254,7 @@ compute_code_indent(void)
        int base_ind = ps.ind_level * opt.indent_size;
 
        if (ps.ind_paren_level == 0) {
-               if (ps.in_stmt_cont)
+               if (ps.line_is_stmt_cont)
                        return base_ind + opt.continuation_indent;
                return base_ind;
        }
@@ -342,7 +342,7 @@ output_indented_line(void)
 
        /* This kludge aligns function definitions correctly. */
        if (ps.ind_level == 0)
-               ps.in_stmt_cont = false;
+               ps.line_is_stmt_cont = false;
 
        if (opt.blank_line_after_decl && ps.declaration == decl_end
            && ps.psyms.len > 2) {
@@ -393,7 +393,7 @@ output_line(void)
 
        ps.line_has_decl = ps.in_decl;
        ps.line_has_func_def = false;
-       ps.in_stmt_cont = ps.in_stmt_or_decl
+       ps.line_is_stmt_cont = ps.in_stmt_or_decl
            && (!ps.in_decl || ps.in_init)
            && ps.init_level == 0;
        ps.decl_indent_done = false;



Home | Main Index | Thread Index | Old Index