Sat Jun 10 21:36:38 2023 UTC ()
indent: rename misleading variable

The name started with 'line_start', but the value is not always the
value from the beginning of the line.

No functional change.


(rillig)
diff -r1.52 -r1.53 src/usr.bin/indent/debug.c
diff -r1.356 -r1.357 src/usr.bin/indent/indent.c
diff -r1.187 -r1.188 src/usr.bin/indent/indent.h
diff -r1.216 -r1.217 src/usr.bin/indent/io.c

cvs diff -r1.52 -r1.53 src/usr.bin/indent/debug.c (expand / switch to context diff)
--- src/usr.bin/indent/debug.c 2023/06/10 20:37:12 1.52
+++ src/usr.bin/indent/debug.c 2023/06/10 21:36:38 1.53
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.52 2023/06/10 20:37:12 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.53 2023/06/10 21:36:38 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: debug.c,v 1.52 2023/06/10 20:37:12 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.53 2023/06/10 21:36:38 rillig Exp $");
 
 #include <stdarg.h>
 #include <string.h>
@@ -360,7 +360,7 @@
 	state.heading = "spacing inside a statement or declaration";
 	debug_ps_bool(next_unary);
 	debug_ps_bool(want_blank);
-	debug_ps_int(line_start_nparen);
+	debug_ps_int(ind_paren_level);
 	debug_ps_int(nparen);
 	debug_ps_paren();
 

cvs diff -r1.356 -r1.357 src/usr.bin/indent/indent.c (expand / switch to context diff)
--- src/usr.bin/indent/indent.c 2023/06/10 20:37:12 1.356
+++ src/usr.bin/indent/indent.c 2023/06/10 21:36:38 1.357
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.356 2023/06/10 20:37:12 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.357 2023/06/10 21:36:38 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.356 2023/06/10 20:37:12 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.357 2023/06/10 21:36:38 rillig Exp $");
 
 #include <sys/param.h>
 #include <err.h>
@@ -378,7 +378,7 @@
 	    && !ps.in_init
 	    && !ps.decl_indent_done
 	    && !ps.line_has_func_def
-	    && ps.line_start_nparen == 0;
+	    && ps.ind_paren_level == 0;
 }
 
 static int
@@ -580,7 +580,7 @@
 		ps.want_blank = true;
 
 	if (code.len == 0)
-		ps.line_start_nparen = ps.nparen;
+		ps.ind_paren_level = ps.nparen;
 
 unbalanced:
 	buf_add_char(&code, token.s[0]);
@@ -631,7 +631,7 @@
 
 	ps.want_blank = true;
 	if (code.len == 0)
-		ps.line_start_nparen = ps.nparen;
+		ps.ind_paren_level = ps.nparen;
 
 unbalanced:
 	buf_add_char(&code, token.s[0]);
@@ -788,7 +788,7 @@
 					 * does not start the line */
 
 	if (ps.in_decl && !ps.line_has_func_def && !ps.in_init &&
-	    !ps.decl_indent_done && ps.line_start_nparen == 0) {
+	    !ps.decl_indent_done && ps.ind_paren_level == 0) {
 		/* indent leading commas and not the actual identifiers */
 		indent_declarator(ps.decl_ind - 1, ps.tabs_to_var);
 	}
@@ -844,7 +844,7 @@
 	ps.declaration = ps.declaration == decl_begin ? decl_end : decl_no;
 
 	if (ps.in_decl && code.len == 0 && !ps.in_init &&
-	    !ps.decl_indent_done && ps.line_start_nparen == 0) {
+	    !ps.decl_indent_done && ps.ind_paren_level == 0) {
 		/* indent stray semicolons in declarations */
 		indent_declarator(ps.decl_ind - 1, ps.tabs_to_var);
 	}
@@ -915,7 +915,7 @@
 			ps.want_blank = false;
 
 		} else if (!ps.in_init && !ps.decl_indent_done &&
-		    ps.line_start_nparen == 0) {
+		    ps.ind_paren_level == 0) {
 			if (opt.decl_indent == 0
 			    && code.len > 0 && code.s[code.len - 1] == '}')
 				ps.decl_ind = ind_add(0, code.s, code.len) + 1;

cvs diff -r1.187 -r1.188 src/usr.bin/indent/indent.h (expand / switch to context diff)
--- src/usr.bin/indent/indent.h 2023/06/10 16:43:56 1.187
+++ src/usr.bin/indent/indent.h 2023/06/10 21:36:38 1.188
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.187 2023/06/10 16:43:56 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.188 2023/06/10 21:36:38 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -368,10 +368,9 @@
 	bool want_blank;	/* whether the following token should be
 				 * prefixed by a blank. (Said prefixing is
 				 * ignored in some cases.) */
-	int line_start_nparen;	/* the number of parentheses or brackets that
-				 * were open at the beginning of the current
-				 * line; used to indent within statements,
-				 * initializers and declarations */
+	int ind_paren_level;	/* the number of parentheses or brackets that
+				 * is used for indenting a continuation line of
+				 * a declaration, initializer or statement */
 	int nparen;		/* the number of parentheses or brackets that
 				 * are currently open; used to indent the
 				 * remaining lines of the statement,

cvs diff -r1.216 -r1.217 src/usr.bin/indent/io.c (expand / switch to context diff)
--- src/usr.bin/indent/io.c 2023/06/10 16:43:56 1.216
+++ src/usr.bin/indent/io.c 2023/06/10 21:36:38 1.217
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.216 2023/06/10 16:43:56 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.217 2023/06/10 21:36:38 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: io.c,v 1.216 2023/06/10 16:43:56 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.217 2023/06/10 21:36:38 rillig Exp $");
 
 #include <stdio.h>
 
@@ -249,7 +249,7 @@
 {
 	int base_ind = ps.ind_level * opt.indent_size;
 
-	if (ps.line_start_nparen == 0) {
+	if (ps.ind_paren_level == 0) {
 		if (ps.psyms.top >= 1
 		    && ps.psyms.sym[ps.psyms.top - 1] == psym_lbrace_enum)
 			return base_ind;
@@ -264,7 +264,7 @@
 		return compute_lined_up_code_indent(base_ind);
 	}
 
-	int rel_ind = opt.continuation_indent * ps.line_start_nparen;
+	int rel_ind = opt.continuation_indent * ps.ind_paren_level;
 	if (ps.extra_expr_indent != eei_no && rel_ind == opt.indent_size)
 		rel_ind += opt.continuation_indent;
 	return base_ind + rel_ind;
@@ -397,7 +397,7 @@
 	if (!(ps.psyms.sym[ps.psyms.top] == psym_if_expr_stmt_else
 		&& ps.nparen > 0))
 		ps.ind_level = ps.ind_level_follow;
-	ps.line_start_nparen = ps.nparen;
+	ps.ind_paren_level = ps.nparen;
 	ps.want_blank = false;
 
 	if (ps.nparen > 0) {