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 struct field, for better symmetry



details:   https://anonhg.NetBSD.org/src/rev/c63078a4c089
branches:  trunk
changeset: 376199:c63078a4c089
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jun 04 14:20:00 2023 +0000

description:
indent: rename struct field, for better symmetry

No binary change outside debug mode.

diffstat:

 tests/usr.bin/indent/lsym_lparen_or_lbracket.c |   6 ++--
 usr.bin/indent/debug.c                         |   8 ++--
 usr.bin/indent/indent.c                        |  38 +++++++++++++-------------
 usr.bin/indent/indent.h                        |   7 ++--
 usr.bin/indent/lexi.c                          |  34 +++++++++++-----------
 5 files changed, 46 insertions(+), 47 deletions(-)

diffs (truncated from 315 to 300 lines):

diff -r 2a2c950129ed -r c63078a4c089 tests/usr.bin/indent/lsym_lparen_or_lbracket.c
--- a/tests/usr.bin/indent/lsym_lparen_or_lbracket.c    Sun Jun 04 13:49:00 2023 +0000
+++ b/tests/usr.bin/indent/lsym_lparen_or_lbracket.c    Sun Jun 04 14:20:00 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.11 2023/06/04 13:49:00 rillig Exp $ */
+/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.12 2023/06/04 14:20:01 rillig Exp $ */
 
 /*
  * Tests for the token lsym_lparen_or_lbracket, which represents a '(' or '['
@@ -242,7 +242,7 @@ int array[] = {
 //indent input
 void cover_want_blank_before_lparen(void)
 {
-       /* ps.prev_token can never be 'newline'. */
+       /* ps.prev_lsym can never be 'newline'. */
        int newline =
        (3);
 
@@ -287,7 +287,7 @@ void cover_want_blank_before_lparen(void
 void
 cover_want_blank_before_lparen(void)
 {
-       /* ps.prev_token can never be 'newline'. */
+       /* ps.prev_lsym can never be 'newline'. */
        int newline =
        (3);
 
diff -r 2a2c950129ed -r c63078a4c089 usr.bin/indent/debug.c
--- a/usr.bin/indent/debug.c    Sun Jun 04 13:49:00 2023 +0000
+++ b/usr.bin/indent/debug.c    Sun Jun 04 14:20:00 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: debug.c,v 1.30 2023/06/04 12:46:57 rillig Exp $        */
+/*     $NetBSD: debug.c,v 1.31 2023/06/04 14:20:00 rillig Exp $        */
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: debug.c,v 1.30 2023/06/04 12:46:57 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.31 2023/06/04 14:20:00 rillig Exp $");
 
 #include <stdarg.h>
 
@@ -294,8 +294,8 @@ debug_parser_state(void)
        static struct parser_state prev_ps;
 
        debug_blank_line();
-       debug_println("           ps.prev_token = %s",
-           lsym_name[ps.prev_token]);
+       debug_println("           ps.prev_lsym = %s",
+           lsym_name[ps.prev_lsym]);
        debug_ps_bool(curr_col_1);
        debug_ps_bool(next_col_1);
        debug_ps_bool(next_unary);
diff -r 2a2c950129ed -r c63078a4c089 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sun Jun 04 13:49:00 2023 +0000
+++ b/usr.bin/indent/indent.c   Sun Jun 04 14:20:00 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.323 2023/06/04 13:26:06 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.324 2023/06/04 14:20:00 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.323 2023/06/04 13:26:06 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.324 2023/06/04 14:20:00 rillig Exp $");
 
 #include <sys/param.h>
 #include <err.h>
@@ -179,7 +179,7 @@ static void
 init_globals(void)
 {
        ps.s_sym[0] = psym_stmt_list;
-       ps.prev_token = lsym_semicolon;
+       ps.prev_lsym = lsym_semicolon;
        ps.next_col_1 = true;
 
        const char *suffix = getenv("SIMPLE_BACKUP_SUFFIX");
@@ -362,7 +362,7 @@ update_ps_decl_ptr(lexer_symbol lsym)
        case dp_other:
                if (lsym == lsym_semicolon || lsym == lsym_rbrace)
                        ps.decl_ptr = dp_start;
-               if (lsym == lsym_lparen && ps.prev_token != lsym_sizeof)
+               if (lsym == lsym_lparen && ps.prev_lsym != lsym_sizeof)
                        ps.decl_ptr = dp_start;
                if (lsym == lsym_comma && ps.in_decl)
                        ps.decl_ptr = dp_start;
@@ -425,7 +425,7 @@ maybe_break_line(lexer_symbol lsym)
        if (lsym == lsym_semicolon)
                return;
        if (lsym == lsym_lbrace && opt.brace_same_line
-           && ps.prev_token != lsym_lbrace)
+           && ps.prev_lsym != lsym_lbrace)
                return;
 
        if (opt.verbose)
@@ -449,7 +449,7 @@ move_com_to_code(lexer_symbol lsym)
 static void
 process_newline(void)
 {
-       if (ps.prev_token == lsym_comma
+       if (ps.prev_lsym == lsym_comma
            && ps.nparen == 0 && !ps.block_init
            && !opt.break_after_comma && ps.break_after_comma
            && lab.len == 0 /* for preprocessing lines */
@@ -483,13 +483,13 @@ want_blank_before_lparen(void)
                return false;
        if (opt.proc_calls_space)
                return true;
-       if (ps.prev_token == lsym_rparen || ps.prev_token == lsym_rbracket)
+       if (ps.prev_lsym == lsym_rparen || ps.prev_lsym == lsym_rbracket)
                return false;
-       if (ps.prev_token == lsym_offsetof)
+       if (ps.prev_lsym == lsym_offsetof)
                return false;
-       if (ps.prev_token == lsym_sizeof)
+       if (ps.prev_lsym == lsym_sizeof)
                return opt.blank_after_sizeof;
-       if (ps.prev_token == lsym_word || ps.prev_token == lsym_funcname)
+       if (ps.prev_lsym == lsym_word || ps.prev_lsym == lsym_funcname)
                return false;
        return true;
 }
@@ -530,7 +530,7 @@ process_lparen(void)
                indent = 2 * opt.indent_size;
 
        enum paren_level_cast cast = cast_unknown;
-       if (ps.prev_token == lsym_offsetof || ps.prev_token == lsym_sizeof
+       if (ps.prev_lsym == lsym_offsetof || ps.prev_lsym == lsym_sizeof
            || ps.is_function_definition)
                cast = cast_no;
 
@@ -545,9 +545,9 @@ want_blank_before_lbracket(void)
 {
        if (code.len == 0)
                return false;
-       if (ps.prev_token == lsym_comma)
+       if (ps.prev_lsym == lsym_comma)
                return true;
-       if (ps.prev_token == lsym_binary_op)
+       if (ps.prev_lsym == lsym_binary_op)
                return true;
        return false;
 }
@@ -727,7 +727,7 @@ process_semicolon(void)
                ps.init_or_struct = false;
        ps.seen_case = false;   /* only needs to be reset on error */
        ps.quest_level = 0;     /* only needs to be reset on error */
-       if (ps.prev_token == lsym_rparen)
+       if (ps.prev_lsym == lsym_rparen)
                ps.in_func_def_params = false;
        ps.block_init = false;
        ps.block_init_level = 0;
@@ -770,7 +770,7 @@ static void
 process_lbrace(void)
 {
        parser_symbol psym = ps.s_sym[ps.tos];
-       if (ps.prev_token == lsym_rparen
+       if (ps.prev_lsym == lsym_rparen
            && ps.tos >= 2
            && !(psym == psym_for_exprs || psym == psym_if_expr
                    || psym == psym_switch_expr || psym == psym_while_expr)) {
@@ -918,7 +918,7 @@ process_type(void)
 {
        parse(psym_decl);       /* let the parser worry about indentation */
 
-       if (ps.prev_token == lsym_rparen && ps.tos <= 1) {
+       if (ps.prev_lsym == lsym_rparen && ps.tos <= 1) {
                if (code.len > 0)
                        output_line();
        }
@@ -930,7 +930,7 @@ process_type(void)
        }
 
        ps.init_or_struct = /* maybe */ true;
-       ps.in_decl = ps.decl_on_line = ps.prev_token != lsym_typedef;
+       ps.in_decl = ps.decl_on_line = ps.prev_lsym != lsym_typedef;
        if (ps.decl_level <= 0)
                ps.declaration = decl_begin;
 
@@ -1261,7 +1261,7 @@ indent(void)
                if (lsym == lsym_eof)
                        return process_eof();
 
-               if (lsym == lsym_if && ps.prev_token == lsym_else
+               if (lsym == lsym_if && ps.prev_lsym == lsym_else
                    && opt.else_if)
                        ps.force_nl = false;
 
@@ -1288,7 +1288,7 @@ indent(void)
 
                if (lsym != lsym_comment && lsym != lsym_newline &&
                    lsym != lsym_preprocessing)
-                       ps.prev_token = lsym;
+                       ps.prev_lsym = lsym;
        }
 }
 
diff -r 2a2c950129ed -r c63078a4c089 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Sun Jun 04 13:49:00 2023 +0000
+++ b/usr.bin/indent/indent.h   Sun Jun 04 14:20:00 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.167 2023/06/04 12:46:57 rillig Exp $      */
+/*     $NetBSD: indent.h,v 1.168 2023/06/04 14:20:00 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -286,9 +286,8 @@ typedef struct paren_level_props {
  * comments.
  */
 extern struct parser_state {
-       lexer_symbol prev_token;        /* the previous token, but never
-                                        * comment, newline or preprocessing
-                                        * line */
+       lexer_symbol prev_lsym; /* the previous token, but never comment,
+                                * newline or preprocessing line */
 
        /* Token classification */
 
diff -r 2a2c950129ed -r c63078a4c089 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Sun Jun 04 13:49:00 2023 +0000
+++ b/usr.bin/indent/lexi.c     Sun Jun 04 14:20:00 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.210 2023/06/04 12:46:57 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.211 2023/06/04 14:20:00 rillig Exp $        */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: lexi.c,v 1.210 2023/06/04 12:46:57 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.211 2023/06/04 14:20:00 rillig Exp $");
 
 #include <stdlib.h>
 #include <string.h>
@@ -253,7 +253,7 @@ lex_char_or_string(void)
 static bool
 probably_typename(void)
 {
-       if (ps.prev_token == lsym_modifier)
+       if (ps.prev_lsym == lsym_modifier)
                return true;
        if (ps.block_init)
                return false;
@@ -266,9 +266,9 @@ probably_typename(void)
                goto maybe;
        return false;
 maybe:
-       return ps.prev_token == lsym_semicolon ||
-           ps.prev_token == lsym_lbrace ||
-           ps.prev_token == lsym_rbrace;
+       return ps.prev_lsym == lsym_semicolon ||
+           ps.prev_lsym == lsym_lbrace ||
+           ps.prev_lsym == lsym_rbrace;
 }
 
 static int
@@ -372,10 +372,10 @@ lexi_alnum(void)
        while (ch_isblank(inp.st[0]))
                inp.st++;
 
-       ps.next_unary = ps.prev_token == lsym_tag
-           || ps.prev_token == lsym_typedef;
+       ps.next_unary = ps.prev_lsym == lsym_tag
+           || ps.prev_lsym == lsym_typedef;
 
-       if (ps.prev_token == lsym_tag && ps.nparen == 0)
+       if (ps.prev_lsym == lsym_tag && ps.nparen == 0)
                return lsym_type_outside_parentheses;
 
        token_add_char('\0');
@@ -402,8 +402,8 @@ found_typename:
                        if (ps.paren[ps.nparen - 1].cast == cast_unknown)
                                ps.paren[ps.nparen - 1].cast = cast_maybe;
                }
-               if (ps.prev_token != lsym_period
-                   && ps.prev_token != lsym_unary_op) {
+               if (ps.prev_lsym != lsym_period
+                   && ps.prev_lsym != lsym_unary_op) {
                        if (kw != NULL && kw->lsym == lsym_tag)
                                return lsym_tag;
                        if (ps.nparen == 0)
@@ -436,9 +436,9 @@ is_asterisk_unary(void)
                return true;
        if (ps.next_unary || ps.in_func_def_params)
                return true;
-       if (ps.prev_token == lsym_word ||
-           ps.prev_token == lsym_rparen ||
-           ps.prev_token == lsym_rbracket)
+       if (ps.prev_lsym == lsym_word ||
+           ps.prev_lsym == lsym_rparen ||
+           ps.prev_lsym == lsym_rbracket)
                return false;



Home | Main Index | Thread Index | Old Index