Module Name:    src
Committed By:   rillig
Date:           Fri Oct  8 23:43:33 UTC 2021

Modified Files:
        src/usr.bin/indent: indent.c indent.h lexi.c

Log Message:
indent: rename in_or_st to init_or_struct

This makes a few comments redundant.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.85 -r1.86 src/usr.bin/indent/lexi.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/indent.c
diff -u src/usr.bin/indent/indent.c:1.133 src/usr.bin/indent/indent.c:1.134
--- src/usr.bin/indent/indent.c:1.133	Fri Oct  8 21:13:58 2021
+++ src/usr.bin/indent/indent.c	Fri Oct  8 23:43:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.133 2021/10/08 21:13:58 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.134 2021/10/08 23:43:33 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.133 2021/10/08 21:13:58 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.134 2021/10/08 23:43:33 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -443,7 +443,7 @@ main_init_globals(void)
     line_no = 1;
     had_eof = ps.in_decl = ps.decl_on_line = break_comma = false;
 
-    ps.in_or_st = false;
+    ps.init_or_struct = false;
     ps.want_blank = ps.in_stmt = ps.ind_stmt = false;
     ps.is_case_label = false;
 
@@ -736,14 +736,13 @@ process_lparen_or_lbracket(int decl_ind,
 	debug_println("paren_indent[0] is now %d", ps.paren_indents[0]);
     }
 
-    if (ps.in_or_st && *token.s == '(' && ps.tos <= 2) {
+    if (ps.init_or_struct && *token.s == '(' && ps.tos <= 2) {
 	/*
 	 * this is a kluge to make sure that declarations will be aligned
 	 * right if proc decl has an explicit type on it, i.e. "int a(x) {..."
 	 */
 	parse(semicolon);	/* I said this was a kluge... */
-	ps.in_or_st = false;	/* turn off flag for structure decl or
-				 * initialization */
+	ps.init_or_struct = false;
     }
 
     /* parenthesized type following sizeof or offsetof is not a cast */
@@ -847,7 +846,7 @@ process_colon(int *seen_quest, bool *for
 	return;
     }
 
-    if (ps.in_or_st) {		/* bit-field */
+    if (ps.init_or_struct) {		/* bit-field */
 	*code.e++ = ':';
 	ps.want_blank = false;
 	return;
@@ -872,8 +871,8 @@ process_semicolon(bool *seen_case, int *
     bool *force_nl)
 {
     if (ps.decl_nest == 0)
-	ps.in_or_st = false;	/* we are not in an initialization or
-				 * structure declaration */
+	ps.init_or_struct = false;	/* we are not in an initialization or
+					 * structure declaration */
     *seen_case = false;		/* these will only need resetting in an error */
     *seen_quest = 0;
     if (ps.last_token == rparen_or_rbracket)
@@ -939,7 +938,7 @@ process_lbrace(bool *force_nl, bool *sp_
 	if (!opt.brace_same_line) {
 	    dump_line();
 	    ps.want_blank = false;
-	} else if (ps.in_parameter_declaration && !ps.in_or_st) {
+	} else if (ps.in_parameter_declaration && !ps.init_or_struct) {
 	    ps.ind_level_follow = 0;
 	    if (opt.function_brace_split) {	/* dump the line prior to the
 						 * brace ... */
@@ -965,8 +964,7 @@ process_lbrace(bool *force_nl, bool *sp_
 
     if (code.s == code.e)
 	ps.ind_stmt = false;	/* don't indent the '{' itself */
-    if (ps.in_decl && ps.in_or_st) {	/* this is either a structure
-					 * declaration or an init */
+    if (ps.in_decl && ps.init_or_struct) {
 	di_stack[ps.decl_nest] = *decl_ind;
 	if (++ps.decl_nest == di_stack_cap) {
 	    diag(0, "Reached internal limit of %d struct levels",
@@ -1088,10 +1086,9 @@ process_decl(int *decl_ind, bool *tabs_t
 	ps.ind_stmt = false;
     }
 
-    ps.in_or_st = true;		/* this might be a structure or initialization
-				 * declaration */
+    ps.init_or_struct = /* maybe */ true;
     ps.in_decl = ps.decl_on_line = ps.last_token != type_def;
-    if ( /* !ps.in_or_st && */ ps.decl_nest <= 0)
+    if (ps.decl_nest <= 0)
 	ps.just_saw_decl = 2;
 
     prefix_blankline_requested = false;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.36 src/usr.bin/indent/indent.h:1.37
--- src/usr.bin/indent/indent.h:1.36	Fri Oct  8 22:17:35 2021
+++ src/usr.bin/indent/indent.h	Fri Oct  8 23:43:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.36 2021/10/08 22:17:35 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.37 2021/10/08 23:43:33 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -269,9 +269,9 @@ extern struct parser_state {
 				 * initialization */
     bool last_nl;		/* whether the last thing scanned was a
 				 * newline */
-    bool in_or_st;		/* true iff there has been a declarator (e.g.
-				 * int or char) and no left paren since the
-				 * last semicolon. When true, a '{' is
+    bool init_or_struct;	/* whether there has been a declarator (e.g.
+				 * int or char) and no left parenthesis since
+				 * the last semicolon. When true, a '{' is
 				 * starting a structure definition or an
 				 * initialization list */
     bool col_1;			/* whether the last token started in column 1 */

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.85 src/usr.bin/indent/lexi.c:1.86
--- src/usr.bin/indent/lexi.c:1.85	Fri Oct  8 23:40:08 2021
+++ src/usr.bin/indent/lexi.c	Fri Oct  8 23:43:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.85 2021/10/08 23:40:08 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.86 2021/10/08 23:43:33 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.85 2021/10/08 23:40:08 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.86 2021/10/08 23:43:33 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -616,7 +616,7 @@ lexi(struct parser_state *state)
 				 * switch */
 
     case '=':
-	if (state->in_or_st)
+	if (state->init_or_struct)
 	    state->block_init = true;
 	if (*inp.s == '=') {	/* == */
 	    *token.e++ = *inp.s++;

Reply via email to