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: remove a redundant flag from the pars...



details:   https://anonhg.NetBSD.org/src/rev/8a567c5cc9c7
branches:  trunk
changeset: 376365:8a567c5cc9c7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Jun 14 08:25:15 2023 +0000

description:
indent: remove a redundant flag from the parser state

No functional change.

diffstat:

 tests/usr.bin/indent/lsym_binary_op.c |   4 ++--
 usr.bin/indent/debug.c                |   5 ++---
 usr.bin/indent/indent.h               |   7 +++----
 usr.bin/indent/lexi.c                 |  10 ++++------
 usr.bin/indent/pr_comment.c           |   6 +++---
 5 files changed, 14 insertions(+), 18 deletions(-)

diffs (127 lines):

diff -r a83100b5854c -r 8a567c5cc9c7 tests/usr.bin/indent/lsym_binary_op.c
--- a/tests/usr.bin/indent/lsym_binary_op.c     Wed Jun 14 07:20:54 2023 +0000
+++ b/tests/usr.bin/indent/lsym_binary_op.c     Wed Jun 14 08:25:15 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_binary_op.c,v 1.11 2023/06/04 22:57:18 rillig Exp $ */
+/* $NetBSD: lsym_binary_op.c,v 1.12 2023/06/14 08:25:15 rillig Exp $ */
 
 /*
  * Tests for the token lsym_binary_op, which represents a binary operator in
@@ -147,7 +147,7 @@ joined_unary_and_binary_operators(void)
  * Ensure that the result of the indentation does not depend on whether a
  * token from the input starts in column 1 or 9.
  *
- * See process_binary_op, ps.curr_col_1.
+ * See process_binary_op.
  */
 //indent input
 int col_1 //
diff -r a83100b5854c -r 8a567c5cc9c7 usr.bin/indent/debug.c
--- a/usr.bin/indent/debug.c    Wed Jun 14 07:20:54 2023 +0000
+++ b/usr.bin/indent/debug.c    Wed Jun 14 08:25:15 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: debug.c,v 1.54 2023/06/14 07:20:55 rillig Exp $        */
+/*     $NetBSD: debug.c,v 1.55 2023/06/14 08:25:15 rillig Exp $        */
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: debug.c,v 1.54 2023/06/14 07:20:55 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.55 2023/06/14 08:25:15 rillig Exp $");
 
 #include <stdarg.h>
 #include <string.h>
@@ -375,7 +375,6 @@ debug_parser_state(void)
        debug_ps_bool(blank_line_after_decl);
 
        state.heading = "comments";
-       debug_ps_bool(curr_col_1);
        debug_ps_bool(next_col_1);
 
        state.heading = NULL;
diff -r a83100b5854c -r 8a567c5cc9c7 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Wed Jun 14 07:20:54 2023 +0000
+++ b/usr.bin/indent/indent.h   Wed Jun 14 08:25:15 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.189 2023/06/14 07:20:55 rillig Exp $      */
+/*     $NetBSD: indent.h,v 1.190 2023/06/14 08:25:15 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -405,9 +405,8 @@ extern struct parser_state {
 
        /* Comments */
 
-       bool curr_col_1;        /* whether the current token started in column
-                                * 1 of the original input */
-       bool next_col_1;
+       bool next_col_1;        /* whether the next token starts in column 1 of
+                                * the original input */
 } ps;
 
 extern struct output_state {
diff -r a83100b5854c -r 8a567c5cc9c7 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Wed Jun 14 07:20:54 2023 +0000
+++ b/usr.bin/indent/lexi.c     Wed Jun 14 08:25:15 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.225 2023/06/10 16:43:56 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.226 2023/06/14 08:25:15 rillig Exp $        */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: lexi.c,v 1.225 2023/06/10 16:43:56 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.226 2023/06/14 08:25:15 rillig Exp $");
 
 #include <stdlib.h>
 #include <string.h>
@@ -532,14 +532,12 @@ lexer_symbol
 lexi(void)
 {
        buf_clear(&token);
-       ps.curr_col_1 = ps.next_col_1;
        ps.next_col_1 = false;
 
        for (;;) {
-               if (ch_isblank(inp_p[0])) {
-                       ps.curr_col_1 = false;
+               if (ch_isblank(inp_p[0]))
                        inp_p++;
-               } else if (inp_p[0] == '\\' && inp_p[1] == '\n') {
+               else if (inp_p[0] == '\\' && inp_p[1] == '\n') {
                        inp_p++;
                        inp_skip();
                        line_no++;
diff -r a83100b5854c -r 8a567c5cc9c7 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c       Wed Jun 14 07:20:54 2023 +0000
+++ b/usr.bin/indent/pr_comment.c       Wed Jun 14 08:25:15 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pr_comment.c,v 1.161 2023/06/10 16:43:56 rillig Exp $  */
+/*     $NetBSD: pr_comment.c,v 1.162 2023/06/14 08:25:15 rillig Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pr_comment.c,v 1.161 2023/06/10 16:43:56 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.162 2023/06/14 08:25:15 rillig Exp $");
 
 #include <string.h>
 
@@ -84,7 +84,7 @@ analyze_comment(bool *p_may_wrap, bool *
        int ind;
        int line_length = opt.max_line_length;
 
-       if (ps.curr_col_1 && !opt.format_col1_comments) {
+       if (inp_p - inp.s == 2 && !opt.format_col1_comments) {
                may_wrap = false;
                ind = 0;
        } else {



Home | Main Index | Thread Index | Old Index