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: rename search_brace to search_stmt
details: https://anonhg.NetBSD.org/src/rev/789ee7162f2c
branches: trunk
changeset: 1024481:789ee7162f2c
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Oct 25 19:56:03 2021 +0000
description:
indent: rename search_brace to search_stmt
No functional change.
diffstat:
usr.bin/indent/indent.c | 40 ++++++++++++++++++++--------------------
usr.bin/indent/indent.h | 8 ++++----
usr.bin/indent/parse.c | 12 ++++++------
3 files changed, 30 insertions(+), 30 deletions(-)
diffs (230 lines):
diff -r 5eb37a380fcc -r 789ee7162f2c usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Mon Oct 25 17:05:43 2021 +0000
+++ b/usr.bin/indent/indent.c Mon Oct 25 19:56:03 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.157 2021/10/25 01:06:13 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.158 2021/10/25 19:56:03 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.157 2021/10/25 01:06:13 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.158 2021/10/25 19:56:03 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -157,7 +157,7 @@
}
static void
-search_brace_newline(bool *force_nl)
+search_stmt_newline(bool *force_nl)
{
if (sc_end == NULL) {
save_com = sc_buf;
@@ -180,7 +180,7 @@
}
static void
-search_brace_comment(bool *comment_buffered)
+search_stmt_comment(bool *comment_buffered)
{
if (sc_end == NULL) {
/*
@@ -215,7 +215,7 @@
}
static bool
-search_brace_lbrace(void)
+search_stmt_lbrace(void)
{
/*
* Put KNF-style lbraces before the buffered up tokens and jump out of
@@ -239,7 +239,7 @@
}
static bool
-search_brace_other(lexer_symbol lsym, bool *force_nl,
+search_stmt_other(lexer_symbol lsym, bool *force_nl,
bool comment_buffered, bool last_else)
{
bool remove_newlines;
@@ -254,7 +254,7 @@
if (sc_end == NULL) { /* ignore buffering if comment wasn't saved
* up */
- ps.search_brace = false;
+ ps.search_stmt = false;
return false;
}
@@ -289,7 +289,7 @@
static void
switch_buffer(void)
{
- ps.search_brace = false; /* stop looking for start of stmt */
+ ps.search_stmt = false;
saved_inp_s = inp.s; /* save current input buffer */
saved_inp_e = inp.e;
inp.s = save_com; /* fix so that subsequent calls to lexi will
@@ -301,7 +301,7 @@
}
static void
-search_brace_lookahead(lexer_symbol *lsym)
+search_stmt_lookahead(lexer_symbol *lsym)
{
if (*lsym == lsym_eof)
return;
@@ -337,37 +337,37 @@
transient_state = ps;
*lsym = lexi(&transient_state); /* read another token */
if (*lsym != lsym_newline && *lsym != lsym_form_feed &&
- *lsym != lsym_comment && !transient_state.search_brace) {
+ *lsym != lsym_comment && !transient_state.search_stmt) {
ps = transient_state;
}
}
static void
-search_brace(lexer_symbol *lsym, bool *force_nl,
+search_stmt(lexer_symbol *lsym, bool *force_nl,
bool *comment_buffered, bool *last_else)
{
- while (ps.search_brace) {
+ while (ps.search_stmt) {
switch (*lsym) {
case lsym_newline:
- search_brace_newline(force_nl);
+ search_stmt_newline(force_nl);
break;
case lsym_form_feed:
break;
case lsym_comment:
- search_brace_comment(comment_buffered);
+ search_stmt_comment(comment_buffered);
break;
case lsym_lbrace:
- if (search_brace_lbrace())
+ if (search_stmt_lbrace())
goto switch_buffer;
/* FALLTHROUGH */
default: /* it is the start of a normal statement */
- if (!search_brace_other(*lsym, force_nl,
+ if (!search_stmt_other(*lsym, force_nl,
*comment_buffered, *last_else))
return;
switch_buffer:
switch_buffer();
}
- search_brace_lookahead(lsym);
+ search_stmt_lookahead(lsym);
}
*last_else = false;
@@ -792,7 +792,7 @@
* This should ensure that constructs such as main(){...} and int[]{...}
* have their braces put in the right place.
*/
- ps.search_brace = opt.brace_same_line;
+ ps.search_stmt = opt.brace_same_line;
}
static void
@@ -1028,7 +1028,7 @@
blank_line_before = false;
parse(psym_rbrace);
- ps.search_brace = opt.cuddle_else
+ ps.search_stmt = opt.cuddle_else
&& ps.s_sym[ps.tos] == psym_if_expr_stmt
&& ps.s_ind_level[ps.tos] >= ps.ind_level;
@@ -1357,7 +1357,7 @@
* proper handling of both kinds of brace placement (-br, -bl) and
* cuddling "else" (-ce).
*/
- search_brace(&lsym, &force_nl, &comment_buffered, &last_else);
+ search_stmt(&lsym, &force_nl, &comment_buffered, &last_else);
if (lsym == lsym_eof) {
process_end_of_file();
diff -r 5eb37a380fcc -r 789ee7162f2c usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h Mon Oct 25 17:05:43 2021 +0000
+++ b/usr.bin/indent/indent.h Mon Oct 25 19:56:03 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.49 2021/10/25 00:54:37 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.50 2021/10/25 19:56:03 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -326,9 +326,9 @@
* to the enclosing statement */
bool is_case_label; /* 'case' and 'default' labels are indented
* differently from regular labels */
- bool search_brace; /* whether it is necessary to buffer up all
- * info up to the start of a stmt after an if,
- * while, etc */
+ bool search_stmt; /* whether it is necessary to buffer up all
+ * text up to the start of a statement after
+ * an 'if', 'while', etc. */
bool want_blank; /* whether the following token should be
* prefixed by a blank. (Said prefixing is
* ignored in some cases.) */
diff -r 5eb37a380fcc -r 789ee7162f2c usr.bin/indent/parse.c
--- a/usr.bin/indent/parse.c Mon Oct 25 17:05:43 2021 +0000
+++ b/usr.bin/indent/parse.c Mon Oct 25 19:56:03 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.39 2021/10/25 00:54:37 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.40 2021/10/25 19:56:03 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -104,7 +104,7 @@
switch (psym) {
case psym_decl:
- ps.search_brace = opt.brace_same_line;
+ ps.search_stmt = opt.brace_same_line;
/* indicate that following brace should be on same line */
if (ps.s_sym[ps.tos] != psym_decl) { /* only put one declaration
@@ -139,7 +139,7 @@
ps.s_sym[++ps.tos] = psym;
ps.s_ind_level[ps.tos] = ps.ind_level = ps.ind_level_follow;
++ps.ind_level_follow; /* subsequent statements should be indented 1 */
- ps.search_brace = opt.brace_same_line;
+ ps.search_stmt = opt.brace_same_line;
break;
case psym_lbrace:
@@ -180,7 +180,7 @@
ps.s_sym[++ps.tos] = psym_while_expr;
ps.s_ind_level[ps.tos] = ps.ind_level_follow;
++ps.ind_level_follow;
- ps.search_brace = opt.brace_same_line;
+ ps.search_stmt = opt.brace_same_line;
}
break;
@@ -194,7 +194,7 @@
ps.ind_level_follow = ps.ind_level + 1;
ps.s_sym[ps.tos] = psym_if_expr_stmt_else;
/* remember if with else */
- ps.search_brace = opt.brace_same_line || opt.else_if;
+ ps.search_stmt = opt.brace_same_line || opt.else_if;
}
break;
@@ -216,7 +216,7 @@
case_ind = (float)ps.ind_level_follow + opt.case_indent;
/* statements should be two levels deeper */
ps.ind_level_follow += (int)opt.case_indent + 1;
- ps.search_brace = opt.brace_same_line;
+ ps.search_stmt = opt.brace_same_line;
break;
case psym_semicolon: /* this indicates a simple stmt */
Home |
Main Index |
Thread Index |
Old Index