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 prev_newline and prev_col_1 to...
details: https://anonhg.NetBSD.org/src/rev/06bb57879371
branches: trunk
changeset: 1024680:06bb57879371
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Oct 30 22:36:07 2021 +0000
description:
indent: rename prev_newline and prev_col_1 to curr
These two flags describe the token that is currently processed.
In process_binary_op, curr_newline can never be true since newline is
not a binary operator, so remove that condition.
No functional change.
diffstat:
tests/usr.bin/indent/token_binary_op.c | 4 ++--
tests/usr.bin/indent/token_comment.c | 4 ++--
usr.bin/indent/indent.c | 8 ++++----
usr.bin/indent/indent.h | 9 ++++-----
usr.bin/indent/lexi.c | 18 +++++++++---------
usr.bin/indent/pr_comment.c | 12 ++++++------
6 files changed, 27 insertions(+), 28 deletions(-)
diffs (217 lines):
diff -r 98b0145f6857 -r 06bb57879371 tests/usr.bin/indent/token_binary_op.c
--- a/tests/usr.bin/indent/token_binary_op.c Sat Oct 30 22:25:11 2021 +0000
+++ b/tests/usr.bin/indent/token_binary_op.c Sat Oct 30 22:36:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token_binary_op.c,v 1.5 2021/10/29 22:37:25 rillig Exp $ */
+/* $NetBSD: token_binary_op.c,v 1.6 2021/10/30 22:36:07 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -245,7 +245,7 @@
* Ensure that the result of the indentation does not depend on whether a
* token from the input starts in column 1 or 9.
*
- * See process_binary_op, ps.prev_col_1.
+ * See process_binary_op, ps.curr_col_1.
*/
#indent input
int col_1 //
diff -r 98b0145f6857 -r 06bb57879371 tests/usr.bin/indent/token_comment.c
--- a/tests/usr.bin/indent/token_comment.c Sat Oct 30 22:25:11 2021 +0000
+++ b/tests/usr.bin/indent/token_comment.c Sat Oct 30 22:36:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.14 2021/10/30 16:57:18 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.15 2021/10/30 22:36:07 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -41,7 +41,7 @@
* - with varying opt.comment_column (-c0, -c1, -c33, -c80)
* - with varying opt.decl_comment_column (-cd0, -cd1, -cd20, -cd33, -cd80)
* - with/without ps.decl_on_line
- * - with/without ps.prev_newline
+ * - with/without ps.curr_newline
*
* - very long comments that overflow the buffer 'com'
* - comments that come from save_com
diff -r 98b0145f6857 -r 06bb57879371 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Sat Oct 30 22:25:11 2021 +0000
+++ b/usr.bin/indent/indent.c Sat Oct 30 22:36:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.194 2021/10/30 20:01:46 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.195 2021/10/30 22:36:07 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.194 2021/10/30 20:01:46 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.195 2021/10/30 22:36:07 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -512,7 +512,7 @@
ps.s_sym[0] = psym_stmt_list;
ps.prev_token = lsym_semicolon;
- ps.prev_newline = true;
+ ps.curr_newline = true;
const char *suffix = getenv("SIMPLE_BACKUP_SUFFIX");
if (suffix != NULL)
@@ -850,7 +850,7 @@
static void
process_binary_op(void)
{
- if (!ps.prev_newline && buf_len(&code) > 0)
+ if (buf_len(&code) > 0)
buf_add_char(&code, ' ');
buf_add_buf(&code, &token);
ps.want_blank = true;
diff -r 98b0145f6857 -r 06bb57879371 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h Sat Oct 30 22:25:11 2021 +0000
+++ b/usr.bin/indent/indent.h Sat Oct 30 22:36:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.65 2021/10/30 22:15:51 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.66 2021/10/30 22:36:07 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -282,12 +282,11 @@
* means exactly the same thing.
*/
lexer_symbol prev_token;
- bool prev_newline; /* whether the last thing scanned was a
- * newline */
- bool prev_col_1; /* whether the last token started in column 1
- * of the unformatted input */
enum keyword_kind prev_keyword;
enum keyword_kind curr_keyword;
+ bool curr_newline;
+ bool curr_col_1; /* whether the current token started in column
+ * 1 of the unformatted input */
bool next_unary; /* whether the following operator should be
* unary */
diff -r 98b0145f6857 -r 06bb57879371 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Sat Oct 30 22:25:11 2021 +0000
+++ b/usr.bin/indent/lexi.c Sat Oct 30 22:36:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.116 2021/10/30 22:25:11 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.117 2021/10/30 22:36:07 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.116 2021/10/30 22:25:11 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.117 2021/10/30 22:36:07 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -310,10 +310,10 @@
debug_print_buf("comment", &com);
// prev_token
- debug_ps_bool(prev_newline);
- debug_ps_bool(prev_col_1);
debug_ps_keyword(prev_keyword);
debug_ps_keyword(curr_keyword);
+ debug_ps_bool(curr_newline);
+ debug_ps_bool(curr_col_1);
debug_ps_bool(next_unary);
// procname
debug_ps_bool(want_blank);
@@ -603,13 +603,13 @@
lexi(void)
{
token.e = token.s;
- ps.prev_col_1 = ps.prev_newline;
- ps.prev_newline = false;
+ ps.curr_col_1 = ps.curr_newline;
+ ps.curr_newline = false;
ps.prev_keyword = ps.curr_keyword;
ps.curr_keyword = kw_0;
while (ch_isblank(*inp.s)) {
- ps.prev_col_1 = false;
+ ps.curr_col_1 = false;
inbuf_skip();
}
@@ -630,7 +630,7 @@
switch (*token.s) {
case '\n':
unary_delim = ps.next_unary;
- ps.prev_newline = true;
+ ps.curr_newline = true;
/* if data has been exhausted, the newline is a dummy. */
lsym = had_eof ? lsym_eof : lsym_newline;
break;
@@ -684,7 +684,7 @@
case '\f':
unary_delim = ps.next_unary;
- ps.prev_newline = true;
+ ps.curr_newline = true;
lsym = lsym_form_feed;
break;
diff -r 98b0145f6857 -r 06bb57879371 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c Sat Oct 30 22:25:11 2021 +0000
+++ b/usr.bin/indent/pr_comment.c Sat Oct 30 22:36:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.92 2021/10/30 18:23:17 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.93 2021/10/30 22:36:07 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.92 2021/10/30 18:23:17 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.93 2021/10/30 22:36:07 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -135,7 +135,7 @@
/* Figure where to align and how to treat the comment */
- if (ps.prev_col_1 && !opt.format_col1_comments) {
+ if (ps.curr_col_1 && !opt.format_col1_comments) {
may_wrap = false;
break_delim = false;
com_ind = 0;
@@ -249,7 +249,7 @@
}
last_blank = -1;
- if (!may_wrap || ps.prev_newline) { /* if this is a boxed comment,
+ if (!may_wrap || ps.curr_newline) { /* if this is a boxed comment,
* we handle the newline */
if (com.s == com.e)
com_add_char(' ');
@@ -262,7 +262,7 @@
com_add_delim();
} else {
- ps.prev_newline = true;
+ ps.curr_newline = true;
if (!ch_isblank(com.e[-1]))
com_add_char(' ');
last_blank = com.e - 1 - com.buf;
@@ -329,7 +329,7 @@
break;
}
- ps.prev_newline = false;
+ ps.curr_newline = false;
if (now_len <= adj_max_line_length || !may_wrap)
break;
Home |
Main Index |
Thread Index |
Old Index