Module Name:    src
Committed By:   rillig
Date:           Thu Nov 25 18:48:38 UTC 2021

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

Log Message:
indent: rename ps.in_function_parameters to match reality

This flag is only set while parsing the parameters of a function
definition, but not for a function declaration. See buffer_add in the
test fmt_decl.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.101 -r1.102 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.163 -r1.164 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.231 src/usr.bin/indent/indent.c:1.232
--- src/usr.bin/indent/indent.c:1.231	Thu Nov 25 07:45:32 2021
+++ src/usr.bin/indent/indent.c	Thu Nov 25 18:48:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.231 2021/11/25 07:45:32 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.232 2021/11/25 18:48:37 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.231 2021/11/25 07:45:32 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.232 2021/11/25 18:48:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -834,7 +834,7 @@ process_semicolon(bool *seen_case, int *
     *seen_case = false;		/* these will only need resetting in an error */
     *quest_level = 0;
     if (ps.prev_token == lsym_rparen_or_rbracket)
-	ps.in_parameter_declaration = false;
+	ps.in_func_def_params = false;
     ps.cast_mask = 0;
     ps.not_cast_mask = 0;
     ps.block_init = false;
@@ -893,7 +893,7 @@ process_lbrace(bool *force_nl, bool *spa
 	if (!opt.brace_same_line) {
 	    dump_line();
 	    ps.want_blank = false;
-	} else if (ps.in_parameter_declaration && !ps.init_or_struct) {
+	} else if (ps.in_func_def_params && !ps.init_or_struct) {
 	    ps.ind_level_follow = 0;
 	    if (opt.function_brace_split) {	/* dump the line prior to the
 						 * brace ... */
@@ -904,7 +904,7 @@ process_lbrace(bool *force_nl, bool *spa
 	}
     }
 
-    if (ps.in_parameter_declaration)
+    if (ps.in_func_def_params)
 	blank_line_before = false;
 
     if (ps.p_l_follow > 0) {
@@ -930,9 +930,9 @@ process_lbrace(bool *force_nl, bool *spa
 	ps.decl_on_line = false;	/* we can't be in the middle of a
 					 * declaration, so don't do special
 					 * indentation of comments */
-	if (opt.blanklines_after_decl_at_top && ps.in_parameter_declaration)
+	if (opt.blanklines_after_decl_at_top && ps.in_func_def_params)
 	    blank_line_after = true;
-	ps.in_parameter_declaration = false;
+	ps.in_func_def_params = false;
 	ps.in_decl = false;
     }
 
@@ -975,7 +975,7 @@ process_rbrace(bool *spaced_expr, int *d
 
     if (ps.decl_level > 0) { /* we are in multi-level structure declaration */
 	*decl_ind = di_stack[--ps.decl_level];
-	if (ps.decl_level == 0 && !ps.in_parameter_declaration) {
+	if (ps.decl_level == 0 && !ps.in_func_def_params) {
 	    ps.just_saw_decl = 2;
 	    *decl_ind = ps.ind_level == 0
 		? opt.decl_indent : opt.local_decl_indent;
@@ -1039,7 +1039,7 @@ process_type(int *decl_ind, bool *tabs_t
 	}
     }
 
-    if (ps.in_parameter_declaration && opt.indent_parameters &&
+    if (ps.in_func_def_params && opt.indent_parameters &&
 	    ps.decl_level == 0) {
 	ps.ind_level = ps.ind_level_follow = 1;
 	ps.in_stmt_cont = false;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.101 src/usr.bin/indent/indent.h:1.102
--- src/usr.bin/indent/indent.h:1.101	Thu Nov 25 07:47:55 2021
+++ src/usr.bin/indent/indent.h	Thu Nov 25 18:48:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.101 2021/11/25 07:47:55 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.102 2021/11/25 18:48:37 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -309,7 +309,7 @@ extern struct parser_state {
 				 * processing of braces is then slightly
 				 * different */
     int just_saw_decl;
-    bool in_parameter_declaration;
+    bool in_func_def_params;
     bool decl_indent_done;	/* whether the indentation for a declaration
 				 * has been added to the code buffer. */
 

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.163 src/usr.bin/indent/lexi.c:1.164
--- src/usr.bin/indent/lexi.c:1.163	Thu Nov 25 18:36:30 2021
+++ src/usr.bin/indent/lexi.c	Thu Nov 25 18:48:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.163 2021/11/25 18:36:30 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.164 2021/11/25 18:48:37 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.163 2021/11/25 18:36:30 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.164 2021/11/25 18:48:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -301,7 +301,7 @@ debug_lexi(lexer_symbol lsym)
     debug_ps_bool(decl_on_line);
     debug_ps_bool(in_decl);
     debug_ps_int(just_saw_decl);
-    debug_ps_bool(in_parameter_declaration);
+    debug_ps_bool(in_func_def_params);
     debug_ps_bool(decl_indent_done);
 
     debug_ps_bool(in_stmt_or_decl);
@@ -535,12 +535,12 @@ found_typename:
     }
 
     if (inp_peek() == '(' && ps.tos <= 1 && ps.ind_level == 0 &&
-	!ps.in_parameter_declaration && !ps.block_init) {
+	!ps.in_func_def_params && !ps.block_init) {
 
 	if (ps.p_l_follow == 0 && probably_looking_at_definition()) {
 	    ps.is_function_definition = true;
 	    if (ps.in_decl)
-		ps.in_parameter_declaration = true;
+		ps.in_func_def_params = true;
 	    return lsym_funcname;
 	}
 
@@ -555,7 +555,7 @@ found_typename:
 static bool
 is_asterisk_unary(void)
 {
-    if (ps.next_unary || ps.in_parameter_declaration)
+    if (ps.next_unary || ps.in_func_def_params)
 	return true;
     if (ps.prev_token == lsym_word ||
 	    ps.prev_token == lsym_rparen_or_rbracket)

Reply via email to