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 ps.in_stmt to in_stmt_or_decl



details:   https://anonhg.NetBSD.org/src/rev/df8ebf2a3058
branches:  trunk
changeset: 1026444:df8ebf2a3058
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Nov 25 07:45:32 2021 +0000

description:
indent: rename ps.in_stmt to in_stmt_or_decl

The previous name didn't match reality.

No functional change.

diffstat:

 usr.bin/indent/indent.c |  25 +++++++++++++------------
 usr.bin/indent/indent.h |   7 +++----
 usr.bin/indent/io.c     |   6 +++---
 usr.bin/indent/lexi.c   |   8 ++++----
 4 files changed, 23 insertions(+), 23 deletions(-)

diffs (186 lines):

diff -r d00af71b33db -r df8ebf2a3058 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Thu Nov 25 07:41:13 2021 +0000
+++ b/usr.bin/indent/indent.c   Thu Nov 25 07:45:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.230 2021/11/25 07:41:13 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.231 2021/11/25 07:45:32 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.230 2021/11/25 07:41:13 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.231 2021/11/25 07:45:32 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -730,7 +730,8 @@
        *spaced_expr = false;
        *force_nl = true;       /* must force newline after if */
        ps.next_unary = true;
-       ps.in_stmt = false;     /* don't use stmt continuation indentation */
+       ps.in_stmt_or_decl = false;     /* don't use stmt continuation
+                                        * indentation */
 
        parse_stmt_head(hd);
     }
@@ -817,7 +818,7 @@
     buf_terminate(&lab);
     buf_reset(&code);
 
-    ps.in_stmt = false;
+    ps.in_stmt_or_decl = false;
     ps.is_case_label = *seen_case;
     *force_nl = *seen_case;
     *seen_case = false;
@@ -866,7 +867,7 @@
     }
     *code.e++ = ';';
     ps.want_blank = true;
-    ps.in_stmt = ps.p_l_follow > 0;
+    ps.in_stmt_or_decl = ps.p_l_follow > 0;
 
     if (!*spaced_expr) {       /* if not if for (;;) */
        parse(psym_semicolon);  /* let parser know about end of stmt */
@@ -878,7 +879,7 @@
 process_lbrace(bool *force_nl, bool *spaced_expr, stmt_head hd,
     int *di_stack, int di_stack_cap, int *decl_ind)
 {
-    ps.in_stmt = false;                /* don't indent the {} */
+    ps.in_stmt_or_decl = false;                /* don't indent the {} */
 
     if (!ps.block_init)
        *force_nl = true;       /* force other stuff on same line as '{' onto
@@ -969,7 +970,7 @@
 
     *code.e++ = '}';
     ps.want_blank = true;
-    ps.in_stmt = false;
+    ps.in_stmt_or_decl = false;
     ps.in_stmt_cont = false;
 
     if (ps.decl_level > 0) { /* we are in multi-level structure declaration */
@@ -995,7 +996,7 @@
 static void
 process_do(bool *force_nl, bool *last_else)
 {
-    ps.in_stmt = false;
+    ps.in_stmt_or_decl = false;
 
     if (code.e != code.s) {    /* make sure this starts a line */
        if (opt.verbose)
@@ -1012,7 +1013,7 @@
 static void
 process_else(bool *force_nl, bool *last_else)
 {
-    ps.in_stmt = false;
+    ps.in_stmt_or_decl = false;
 
     if (code.e > code.s && !(opt.cuddle_else && code.e[-1] == '}')) {
        if (opt.verbose)
@@ -1085,7 +1086,7 @@
        *spaced_expr = false;
        *force_nl = true;
        ps.next_unary = true;
-       ps.in_stmt = false;
+       ps.in_stmt_or_decl = false;
        parse_stmt_head(hd);
     }
 }
@@ -1298,8 +1299,8 @@
            force_nl = false;
        else if (lsym != lsym_comment) {
            maybe_break_line(lsym, &force_nl);
-           ps.in_stmt = true;  /* add an extra level of indentation; turned
-                                * off again by a ';' or '}' */
+           ps.in_stmt_or_decl = true;  /* add an extra level of indentation;
+                                        * turned off again by a ';' or '}' */
            if (com.s != com.e)
                move_com_to_code();
        }
diff -r d00af71b33db -r df8ebf2a3058 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Thu Nov 25 07:41:13 2021 +0000
+++ b/usr.bin/indent/indent.h   Thu Nov 25 07:45:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.99 2021/11/25 07:41:13 rillig Exp $       */
+/*     $NetBSD: indent.h,v 1.100 2021/11/25 07:45:32 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -313,9 +313,8 @@
     bool decl_indent_done;     /* whether the indentation for a declaration
                                 * has been added to the code buffer. */
 
-    bool in_stmt;              /* TODO: rename to something appropriate; this
-                                * is set to true in struct declarations as
-                                * well, so 'stmt' isn't accurate */
+    bool in_stmt_or_decl;      /* whether in a statement or a struct
+                                * declaration or a plain declaration */
     bool in_stmt_cont;         /* whether the next line should have an extra
                                 * indentation level because we are in the
                                 * middle of a statement */
diff -r d00af71b33db -r df8ebf2a3058 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Thu Nov 25 07:41:13 2021 +0000
+++ b/usr.bin/indent/io.c       Thu Nov 25 07:45:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.130 2021/11/25 07:41:13 rillig Exp $  */
+/*     $NetBSD: io.c,v 1.131 2021/11/25 07:45:32 rillig Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.130 2021/11/25 07:41:13 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.131 2021/11/25 07:45:32 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -496,7 +496,7 @@
     }
 
     ps.decl_on_line = ps.in_decl;      /* for proper comment indentation */
-    ps.in_stmt_cont = ps.in_stmt && !ps.in_decl;
+    ps.in_stmt_cont = ps.in_stmt_or_decl && !ps.in_decl;
     ps.decl_indent_done = false;
 
     *(lab.e = lab.s) = '\0';   /* reset buffers */
diff -r d00af71b33db -r df8ebf2a3058 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Thu Nov 25 07:41:13 2021 +0000
+++ b/usr.bin/indent/lexi.c     Thu Nov 25 07:45:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.151 2021/11/25 07:41:13 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.152 2021/11/25 07:45:32 rillig Exp $        */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.151 2021/11/25 07:41:13 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.152 2021/11/25 07:45:32 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -304,7 +304,7 @@
     debug_ps_bool(in_parameter_declaration);
     debug_ps_bool(decl_indent_done);
 
-    debug_ps_bool(in_stmt);
+    debug_ps_bool(in_stmt_or_decl);
     debug_ps_bool(in_stmt_cont);
     debug_ps_bool(is_case_label);
 
@@ -396,7 +396,7 @@
 static bool
 probably_typename(void)
 {
-    if (ps.block_init || ps.in_stmt)
+    if (ps.block_init || ps.in_stmt_or_decl)
        return false;
     if (inp_peek() == '*' && inp_lookahead(1) != '=')
        goto maybe;



Home | Main Index | Thread Index | Old Index