Wed Jun 14 08:25:15 2023 UTC ()
indent: remove a redundant flag from the parser state

No functional change.


(rillig)
diff -r1.11 -r1.12 src/tests/usr.bin/indent/lsym_binary_op.c
diff -r1.54 -r1.55 src/usr.bin/indent/debug.c
diff -r1.189 -r1.190 src/usr.bin/indent/indent.h
diff -r1.225 -r1.226 src/usr.bin/indent/lexi.c
diff -r1.161 -r1.162 src/usr.bin/indent/pr_comment.c

cvs diff -r1.11 -r1.12 src/tests/usr.bin/indent/lsym_binary_op.c (expand / switch to context diff)
--- src/tests/usr.bin/indent/lsym_binary_op.c 2023/06/04 22:57:18 1.11
+++ src/tests/usr.bin/indent/lsym_binary_op.c 2023/06/14 08:25:15 1.12
@@ -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 @@
  * 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 //

cvs diff -r1.54 -r1.55 src/usr.bin/indent/debug.c (expand / switch to context diff)
--- src/usr.bin/indent/debug.c 2023/06/14 07:20:55 1.54
+++ src/usr.bin/indent/debug.c 2023/06/14 08:25:15 1.55
@@ -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_ps_bool(blank_line_after_decl);
 
 	state.heading = "comments";
-	debug_ps_bool(curr_col_1);
 	debug_ps_bool(next_col_1);
 
 	state.heading = NULL;

cvs diff -r1.189 -r1.190 src/usr.bin/indent/indent.h (expand / switch to context diff)
--- src/usr.bin/indent/indent.h 2023/06/14 07:20:55 1.189
+++ src/usr.bin/indent/indent.h 2023/06/14 08:25:15 1.190
@@ -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 @@
 
 	/* 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 {

cvs diff -r1.225 -r1.226 src/usr.bin/indent/lexi.c (expand / switch to context diff)
--- src/usr.bin/indent/lexi.c 2023/06/10 16:43:56 1.225
+++ src/usr.bin/indent/lexi.c 2023/06/14 08:25:15 1.226
@@ -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 @@
 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++;

cvs diff -r1.161 -r1.162 src/usr.bin/indent/pr_comment.c (expand / switch to context diff)
--- src/usr.bin/indent/pr_comment.c 2023/06/10 16:43:56 1.161
+++ src/usr.bin/indent/pr_comment.c 2023/06/14 08:25:15 1.162
@@ -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 @@
 	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 {