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: run indent on its own source code
details: https://anonhg.NetBSD.org/src/rev/5825911fc241
branches: trunk
changeset: 1024458:5825911fc241
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Oct 24 19:14:33 2021 +0000
description:
indent: run indent on its own source code
With manual corrections afterwards. Indent still does not get
extra_expr_indent correctly, it also indents global variables after
tagged declarations too deep.
No functional change.
diffstat:
usr.bin/indent/args.c | 8 ++++----
usr.bin/indent/indent.c | 40 +++++++++++++++++++---------------------
usr.bin/indent/lexi.c | 14 +++++++-------
usr.bin/indent/parse.c | 6 +++---
usr.bin/indent/pr_comment.c | 8 ++++----
5 files changed, 37 insertions(+), 39 deletions(-)
diffs (232 lines):
diff -r 36e8efb88a30 -r 5825911fc241 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c Sun Oct 24 18:45:46 2021 +0000
+++ b/usr.bin/indent/args.c Sun Oct 24 19:14:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: args.c,v 1.58 2021/10/24 11:19:25 rillig Exp $ */
+/* $NetBSD: args.c,v 1.59 2021/10/24 19:14:33 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.58 2021/10/24 11:19:25 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.59 2021/10/24 19:14:33 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
#endif
@@ -162,7 +162,7 @@
break;
} else if (n >= array_length(buf) - 5) {
diag(1, "buffer overflow in %s, starting with '%.10s'",
- fname, buf);
+ fname, buf);
exit(1);
} else
buf[n++] = (char)ch;
@@ -308,7 +308,7 @@
if (!(errno == 0 && *end == '\0' &&
p->i_min <= num && num <= p->i_max))
errx(1, "%s: invalid argument \"%s\" for option \"-%s\"",
- option_source, param_start, p->p_name);
+ option_source, param_start, p->p_name);
*(int *)p->p_var = (int)num;
}
}
diff -r 36e8efb88a30 -r 5825911fc241 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Sun Oct 24 18:45:46 2021 +0000
+++ b/usr.bin/indent/indent.c Sun Oct 24 19:14:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.148 2021/10/24 17:19:48 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.149 2021/10/24 19:14:33 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.148 2021/10/24 17:19:48 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.149 2021/10/24 19:14:33 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -309,19 +309,18 @@
return;
/*
- * The only intended purpose of calling lexi() below is to categorize
- * the next token in order to decide whether to continue buffering
- * forthcoming tokens. Once the buffering is over, lexi() will be
- * called again elsewhere on all of the tokens - this time for normal
- * processing.
+ * The only intended purpose of calling lexi() below is to categorize the
+ * next token in order to decide whether to continue buffering forthcoming
+ * tokens. Once the buffering is over, lexi() will be called again
+ * elsewhere on all of the tokens - this time for normal processing.
*
- * Calling it for this purpose is a bug, because lexi() also changes
- * the parser state and discards leading whitespace, which is needed
- * mostly for comment-related considerations.
+ * Calling it for this purpose is a bug, because lexi() also changes the
+ * parser state and discards leading whitespace, which is needed mostly
+ * for comment-related considerations.
*
- * Work around the former problem by giving lexi() a copy of the
- * current parser state and discard it if the call turned out to be
- * just a lookahead.
+ * Work around the former problem by giving lexi() a copy of the current
+ * parser state and discard it if the call turned out to be just a
+ * lookahead.
*
* Work around the latter problem by copying all whitespace characters
* into the buffer so that the later lexi() call will read them.
@@ -367,7 +366,7 @@
if (!search_brace_other(*ttype, force_nl,
*comment_buffered, *last_else))
return;
- switch_buffer:
+ switch_buffer:
switch_buffer();
}
search_brace_lookahead(ttype);
@@ -490,7 +489,7 @@
const char *last_slash = strrchr(in_name, '/');
snprintf(bakfile, sizeof(bakfile), "%s%s",
- last_slash != NULL ? last_slash + 1 : in_name, backup_suffix);
+ last_slash != NULL ? last_slash + 1 : in_name, backup_suffix);
/* copy in_name to backup file */
bak_fd = creat(bakfile, 0600);
@@ -853,7 +852,7 @@
return;
}
- if (ps.init_or_struct) { /* bit-field */
+ if (ps.init_or_struct) { /* bit-field */
*code.e++ = ':';
ps.want_blank = false;
return;
@@ -1100,8 +1099,8 @@
int len = (int)buf_len(&token) + 1;
int ind = ps.ind_level == 0 || ps.decl_nest > 0
- ? opt.decl_indent /* global variable or local member */
- : opt.local_decl_indent; /* local variable */
+ ? opt.decl_indent /* global variable or local member */
+ : opt.local_decl_indent; /* local variable */
*decl_ind = ind > 0 ? ind : len;
*tabs_to_var = opt.use_tabs && ind > 0;
}
@@ -1181,9 +1180,8 @@
if (ps.block_init_level <= 0)
ps.block_init = false;
if (break_comma && (opt.break_after_comma ||
- indentation_after_range(
- compute_code_indent(), code.s, code.e)
- >= opt.max_line_length - opt.tabsize))
+ indentation_after_range(compute_code_indent(), code.s, code.e)
+ >= opt.max_line_length - opt.tabsize))
*force_nl = true;
}
}
diff -r 36e8efb88a30 -r 5825911fc241 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Sun Oct 24 18:45:46 2021 +0000
+++ b/usr.bin/indent/lexi.c Sun Oct 24 19:14:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.94 2021/10/24 11:19:25 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.95 2021/10/24 19:14:33 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.94 2021/10/24 11:19:25 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.95 2021/10/24 19:14:33 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -291,8 +291,8 @@
lex_word(void)
{
while (isalnum((unsigned char)*inp.s) ||
- *inp.s == '\\' ||
- *inp.s == '_' || *inp.s == '$') {
+ *inp.s == '\\' ||
+ *inp.s == '_' || *inp.s == '$') {
if (*inp.s == '\\') {
if (inp.s[1] == '\n') {
@@ -382,8 +382,8 @@
lexi_alnum(struct parser_state *state)
{
if (!(isalnum((unsigned char)*inp.s) ||
- *inp.s == '_' || *inp.s == '$' ||
- (inp.s[0] == '.' && isdigit((unsigned char)inp.s[1]))))
+ *inp.s == '_' || *inp.s == '$' ||
+ (inp.s[0] == '.' && isdigit((unsigned char)inp.s[1]))))
return end_of_file; /* just as a placeholder */
if (isdigit((unsigned char)*inp.s) ||
@@ -686,7 +686,7 @@
unary_delim = true;
}
- if (inp.s >= inp.e) /* check for input buffer empty */
+ if (inp.s >= inp.e) /* check for input buffer empty */
inbuf_read_line();
state->next_unary = unary_delim;
diff -r 36e8efb88a30 -r 5825911fc241 usr.bin/indent/parse.c
--- a/usr.bin/indent/parse.c Sun Oct 24 18:45:46 2021 +0000
+++ b/usr.bin/indent/parse.c Sun Oct 24 19:14:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.36 2021/10/20 05:26:46 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.37 2021/10/24 19:14:33 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -117,8 +117,8 @@
break_comma = false; /* don't break comma in an initializer list */
if (ps.s_ttype[ps.tos] == stmt || ps.s_ttype[ps.tos] == decl
|| ps.s_ttype[ps.tos] == stmt_list)
- ++ps.ind_level_follow; /* it is a random, isolated stmt
- * group or a declaration */
+ ++ps.ind_level_follow; /* it is a random, isolated stmt group
+ * or a declaration */
else {
if (code.s == code.e) {
/* it is a group as part of a while, for, etc. */
diff -r 36e8efb88a30 -r 5825911fc241 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c Sun Oct 24 18:45:46 2021 +0000
+++ b/usr.bin/indent/pr_comment.c Sun Oct 24 19:14:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.82 2021/10/24 11:17:05 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.83 2021/10/24 19:14:33 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.82 2021/10/24 11:17:05 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.83 2021/10/24 19:14:33 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -181,8 +181,8 @@
* much will have to be ignored by dump_line(). This is a box comment,
* so nothing changes -- not even indentation.
*
- * The comment we're about to read usually comes from inp.buf,
- * unless it has been copied into save_com.
+ * The comment we're about to read usually comes from inp.buf, unless
+ * it has been copied into save_com.
*/
const char *start;
Home |
Main Index |
Thread Index |
Old Index