Module Name:    src
Committed By:   rillig
Date:           Sat Jun 10 21:36:38 UTC 2023

Modified Files:
        src/usr.bin/indent: debug.c indent.c indent.h io.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.356 -r1.357 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.187 -r1.188 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.216 -r1.217 src/usr.bin/indent/io.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/debug.c
diff -u src/usr.bin/indent/debug.c:1.52 src/usr.bin/indent/debug.c:1.53
--- src/usr.bin/indent/debug.c:1.52	Sat Jun 10 20:37:12 2023
+++ src/usr.bin/indent/debug.c	Sat Jun 10 21:36:38 2023
@@ -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 @@ debug_parser_state(void)
 	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();
 

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.356 src/usr.bin/indent/indent.c:1.357
--- src/usr.bin/indent/indent.c:1.356	Sat Jun 10 20:37:12 2023
+++ src/usr.bin/indent/indent.c	Sat Jun 10 21:36:38 2023
@@ -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 @@ is_function_pointer_declaration(void)
 	    && !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 @@ process_rparen(void)
 		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 @@ process_rbracket(void)
 
 	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 @@ process_comma(void)
 					 * 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 @@ process_semicolon(void)
 	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 @@ process_word(lexer_symbol lsym)
 			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;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.187 src/usr.bin/indent/indent.h:1.188
--- src/usr.bin/indent/indent.h:1.187	Sat Jun 10 16:43:56 2023
+++ src/usr.bin/indent/indent.h	Sat Jun 10 21:36:38 2023
@@ -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 @@ extern struct parser_state {
 	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,

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.216 src/usr.bin/indent/io.c:1.217
--- src/usr.bin/indent/io.c:1.216	Sat Jun 10 16:43:56 2023
+++ src/usr.bin/indent/io.c	Sat Jun 10 21:36:38 2023
@@ -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 @@ compute_code_indent(void)
 {
 	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 @@ compute_code_indent(void)
 		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 @@ output_line(void)
 	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) {

Reply via email to