Module Name:    src
Committed By:   rillig
Date:           Sat Jun 10 07:42:41 UTC 2023

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

Log Message:
indent: clean up function and variable names


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/indent/debug.c
cvs rdiff -u -r1.350 -r1.351 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.184 -r1.185 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.209 -r1.210 src/usr.bin/indent/io.c
cvs rdiff -u -r1.221 -r1.222 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/debug.c
diff -u src/usr.bin/indent/debug.c:1.45 src/usr.bin/indent/debug.c:1.46
--- src/usr.bin/indent/debug.c:1.45	Sat Jun 10 07:05:18 2023
+++ src/usr.bin/indent/debug.c	Sat Jun 10 07:42:41 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.45 2023/06/10 07:05:18 rillig Exp $	*/
+/*	$NetBSD: debug.c,v 1.46 2023/06/10 07:42:41 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: debug.c,v 1.45 2023/06/10 07:05:18 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.46 2023/06/10 07:42:41 rillig Exp $");
 
 #include <stdarg.h>
 
@@ -299,7 +299,7 @@ debug_parser_state(void)
 	debug_ps_bool(in_var_decl);
 	debug_ps_bool(in_init);
 	debug_ps_int(init_level);
-	debug_ps_bool(in_func_def_line);
+	debug_ps_bool(line_has_func_def);
 	debug_ps_bool(in_func_def_params);
 	debug_ps_bool(line_has_decl);
 	debug_ps_enum(lbrace_kind, psym_name);

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.350 src/usr.bin/indent/indent.c:1.351
--- src/usr.bin/indent/indent.c:1.350	Sat Jun 10 06:52:35 2023
+++ src/usr.bin/indent/indent.c	Sat Jun 10 07:42:41 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.350 2023/06/10 06:52:35 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.351 2023/06/10 07:42:41 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.350 2023/06/10 06:52:35 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.351 2023/06/10 07:42:41 rillig Exp $");
 
 #include <sys/param.h>
 #include <err.h>
@@ -372,7 +372,7 @@ is_function_pointer_declaration(void)
 	return ps.in_decl
 	    && !ps.in_init
 	    && !ps.decl_indent_done
-	    && !ps.in_func_def_line
+	    && !ps.line_has_func_def
 	    && ps.line_start_nparen == 0;
 }
 
@@ -545,7 +545,7 @@ process_lparen(void)
 	    || ps.prev_lsym == lsym_if
 	    || ps.prev_lsym == lsym_switch
 	    || ps.prev_lsym == lsym_while
-	    || ps.in_func_def_line)
+	    || ps.line_has_func_def)
 		cast = cast_no;
 
 	ps.paren[ps.nparen - 1].indent = indent;
@@ -779,21 +779,15 @@ static void
 process_question(void)
 {
 	ps.quest_level++;
-	if (code.len == 0) {
-		ps.in_stmt_cont = true;
-		ps.in_stmt_or_decl = true;
-		ps.in_decl = false;
-	}
+	if (code.len == 0)
+		ps.in_stmt_cont = true;	// XXX: should be unnecessary.
 }
 
 static void
 process_colon_question(void)
 {
-	if (code.len == 0) {
-		ps.in_stmt_cont = true;
-		ps.in_stmt_or_decl = true;
-		ps.in_decl = false;
-	}
+	if (code.len == 0)
+		ps.in_stmt_cont = true;	// XXX: should be unnecessary.
 }
 
 static void
@@ -802,7 +796,7 @@ process_comma(void)
 	ps.want_blank = code.len > 0;	/* only put blank after comma if comma
 					 * does not start the line */
 
-	if (ps.in_decl && !ps.in_func_def_line && !ps.in_init &&
+	if (ps.in_decl && !ps.line_has_func_def && !ps.in_init &&
 	    !ps.decl_indent_done && ps.line_start_nparen == 0) {
 		/* indent leading commas and not the actual identifiers */
 		indent_declarator(ps.decl_ind - 1, ps.tabs_to_var);
@@ -891,7 +885,7 @@ process_semicolon(void)
 }
 
 static void
-process_type(void)
+process_type_outside_parentheses(void)
 {
 	parse(psym_decl);	/* let the parser worry about indentation */
 
@@ -918,7 +912,7 @@ process_type(void)
 }
 
 static void
-process_ident(lexer_symbol lsym)
+process_word(lexer_symbol lsym)
 {
 	if (ps.in_decl) {
 		if (lsym == lsym_funcname) {
@@ -940,8 +934,8 @@ process_ident(lexer_symbol lsym)
 
 	} else if (ps.spaced_expr_psym != psym_0 && ps.nparen == 0) {
 		ps.force_nl = true;
-		ps.next_unary = true;
 		ps.in_stmt_or_decl = false;
+		ps.next_unary = true;
 		parse(ps.spaced_expr_psym);
 		ps.spaced_expr_psym = psym_0;
 	}
@@ -1014,7 +1008,7 @@ process_lsym(lexer_symbol lsym)
 			goto copy_token;
 		/* FALLTHROUGH */
 	case lsym_type_outside_parentheses:
-		process_type();
+		process_type_outside_parentheses();
 		goto copy_token;
 
 	case lsym_type_in_parentheses:
@@ -1023,7 +1017,7 @@ process_lsym(lexer_symbol lsym)
 	case lsym_word:
 	case lsym_funcname:
 	case lsym_return:
-		process_ident(lsym);
+		process_word(lsym);
 copy_token:
 		if (ps.want_blank)
 			buf_add_char(&code, ' ');

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.184 src/usr.bin/indent/indent.h:1.185
--- src/usr.bin/indent/indent.h:1.184	Sat Jun 10 06:38:21 2023
+++ src/usr.bin/indent/indent.h	Sat Jun 10 07:42:41 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.184 2023/06/10 06:38:21 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.185 2023/06/10 07:42:41 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -314,12 +314,11 @@ extern struct parser_state {
 				 * starts an initializer */
 	bool in_init;		/* whether inside an initializer */
 	int init_level;		/* the number of '{}' in an initializer */
-	bool in_func_def_line;	/* starts either at the 'name(' from a function
+	bool line_has_func_def;	/* starts either at the 'name(' from a function
 				 * definition if it occurs at the beginning of
 				 * a line, or at the first '*' from inside a
 				 * declaration when the line starts with words
-				 * followed by a '('; ends at the end of that
-				 * line */
+				 * followed by a '(' */
 	bool in_func_def_params;	/* for old-style functions */
 	bool line_has_decl;	/* whether this line of code has part of a
 				 * declaration on it; used for indenting

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.209 src/usr.bin/indent/io.c:1.210
--- src/usr.bin/indent/io.c:1.209	Sat Jun 10 06:38:21 2023
+++ src/usr.bin/indent/io.c	Sat Jun 10 07:42:41 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.209 2023/06/10 06:38:21 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.210 2023/06/10 07:42:41 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: io.c,v 1.209 2023/06/10 06:38:21 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.210 2023/06/10 07:42:41 rillig Exp $");
 
 #include <stdio.h>
 
@@ -349,8 +349,6 @@ output_line(void)
 	debug_printf("%s", __func__);
 	debug_buffers();
 
-	ps.in_func_def_line = false;
-
 	if (indent_enabled == indent_on) {
 		if (lab.len == 0 && code.len == 0 && com.len == 0)
 			out.line_kind = lk_blank;
@@ -397,6 +395,7 @@ prepare_next_line:
 	com.len = 0;
 
 	ps.line_has_decl = ps.in_decl;
+	ps.line_has_func_def = false;
 	// XXX: don't reset in_stmt_cont here; see process_colon_question.
 	ps.in_stmt_cont = ps.in_stmt_or_decl
 	    && !ps.in_decl && ps.init_level == 0;

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.221 src/usr.bin/indent/lexi.c:1.222
--- src/usr.bin/indent/lexi.c:1.221	Sat Jun 10 06:38:21 2023
+++ src/usr.bin/indent/lexi.c	Sat Jun 10 07:42:41 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.221 2023/06/10 06:38:21 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.222 2023/06/10 07:42:41 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: lexi.c,v 1.221 2023/06/10 06:38:21 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.222 2023/06/10 07:42:41 rillig Exp $");
 
 #include <stdlib.h>
 #include <string.h>
@@ -419,7 +419,7 @@ found_typename:
 	    !ps.in_func_def_params && !ps.in_init) {
 
 		if (ps.nparen == 0 && probably_looking_at_definition()) {
-			ps.in_func_def_line = true;
+			ps.line_has_func_def = true;
 			if (ps.in_decl)
 				ps.in_func_def_params = true;
 			return lsym_funcname;
@@ -473,7 +473,7 @@ lex_asterisk_unary(void)
 	}
 
 	if (ps.in_decl && probably_in_function_definition())
-		ps.in_func_def_line = true;
+		ps.line_has_func_def = true;
 }
 
 static void

Reply via email to