Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/indent indent: clean up function and variable names
details: https://anonhg.NetBSD.org/src/rev/147d6dd7c7e4
branches: trunk
changeset: 376311:147d6dd7c7e4
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jun 10 07:42:41 2023 +0000
description:
indent: clean up function and variable names
diffstat:
usr.bin/indent/debug.c | 6 +++---
usr.bin/indent/indent.c | 34 ++++++++++++++--------------------
usr.bin/indent/indent.h | 7 +++----
usr.bin/indent/io.c | 7 +++----
usr.bin/indent/lexi.c | 8 ++++----
5 files changed, 27 insertions(+), 35 deletions(-)
diffs (239 lines):
diff -r da7219c44193 -r 147d6dd7c7e4 usr.bin/indent/debug.c
--- a/usr.bin/indent/debug.c Sat Jun 10 07:33:32 2023 +0000
+++ b/usr.bin/indent/debug.c Sat Jun 10 07:42:41 2023 +0000
@@ -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);
diff -r da7219c44193 -r 147d6dd7c7e4 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Sat Jun 10 07:33:32 2023 +0000
+++ b/usr.bin/indent/indent.c Sat Jun 10 07:42:41 2023 +0000
@@ -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.in_stmt_or_decl = false;
ps.next_unary = true;
- ps.in_stmt_or_decl = false;
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, ' ');
diff -r da7219c44193 -r 147d6dd7c7e4 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h Sat Jun 10 07:33:32 2023 +0000
+++ b/usr.bin/indent/indent.h Sat Jun 10 07:42:41 2023 +0000
@@ -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
diff -r da7219c44193 -r 147d6dd7c7e4 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c Sat Jun 10 07:33:32 2023 +0000
+++ b/usr.bin/indent/io.c Sat Jun 10 07:42:41 2023 +0000
@@ -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;
diff -r da7219c44193 -r 147d6dd7c7e4 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Sat Jun 10 07:33:32 2023 +0000
+++ b/usr.bin/indent/lexi.c Sat Jun 10 07:42:41 2023 +0000
@@ -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
Home |
Main Index |
Thread Index |
Old Index