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: let indent format its own code
details: https://anonhg.NetBSD.org/src/rev/ac8fefe05cdb
branches: trunk
changeset: 375335:ac8fefe05cdb
user: rillig <rillig%NetBSD.org@localhost>
date: Mon May 15 09:22:53 2023 +0000
description:
indent: let indent format its own code
With manual corrections, as indent does not properly indent multi-line
'?:' expressions nor multi-line controlling expressions.
diffstat:
usr.bin/indent/.indent.pro | 4 +++-
usr.bin/indent/indent.c | 12 ++++++------
usr.bin/indent/lexi.c | 6 +++---
usr.bin/indent/pr_comment.c | 8 ++++----
4 files changed, 16 insertions(+), 14 deletions(-)
diffs (128 lines):
diff -r c42c972c91fb -r ac8fefe05cdb usr.bin/indent/.indent.pro
--- a/usr.bin/indent/.indent.pro Mon May 15 09:05:08 2023 +0000
+++ b/usr.bin/indent/.indent.pro Mon May 15 09:22:53 2023 +0000
@@ -1,5 +1,6 @@
-/* $NetBSD: .indent.pro,v 1.3 2021/10/26 19:36:30 rillig Exp $ */
+/* $NetBSD: .indent.pro,v 1.4 2023/05/15 09:22:53 rillig Exp $ */
+-l78 /* Keep 2 columns distance from the 80-column margin. */
-di0 /* Do not indent variable names in global declarations. */
/* XXX: -eei does not work; the expressions are indented only a single level. */
-eei /* Indent expressions in 'if' and 'while' once more. */
@@ -10,5 +11,6 @@
-ta /* Identifiers ending in '_t' are considered type names. */
-TFILE /* Additional types, for proper formatting of '*'. */
-Tlexer_symbol
+-Tparen_level_props
-Tparser_symbol
-Tkeyword_kind
diff -r c42c972c91fb -r ac8fefe05cdb usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Mon May 15 09:05:08 2023 +0000
+++ b/usr.bin/indent/indent.c Mon May 15 09:22:53 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.272 2023/05/15 08:56:39 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.273 2023/05/15 09:22:53 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.272 2023/05/15 08:56:39 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.273 2023/05/15 09:22:53 rillig Exp $");
#include <sys/param.h>
#include <err.h>
@@ -608,7 +608,7 @@ process_semicolon(void)
ps.in_stmt_or_decl = ps.nparen > 0;
if (ps.spaced_expr_psym == psym_0) {
- parse(psym_0); /* let parser know about end of stmt */
+ parse(psym_0); /* let parser know about end of stmt */
ps.force_nl = true;
}
}
@@ -653,7 +653,7 @@ process_lbrace(void)
ps.di_stack[ps.decl_level] = ps.decl_ind;
if (++ps.decl_level == (int)array_length(ps.di_stack)) {
diag(0, "Reached internal limit of %d struct levels",
- (int)array_length(ps.di_stack));
+ (int)array_length(ps.di_stack));
ps.decl_level--;
}
} else {
@@ -714,7 +714,7 @@ process_do(void)
{
ps.in_stmt_or_decl = false;
- if (code.len > 0) { /* make sure this starts a line */
+ if (code.len > 0) { /* make sure this starts a line */
if (opt.verbose)
diag(0, "Line broken");
output_line();
@@ -947,7 +947,7 @@ process_preprocessing(void)
!substring_equals(dir, "define") &&
!substring_equals(dir, "include")) {
diag(1, "Unrecognized cpp directive \"%.*s\"",
- (int)(dir.e - dir.s), dir.s);
+ (int)(dir.e - dir.s), dir.s);
return;
}
}
diff -r c42c972c91fb -r ac8fefe05cdb usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Mon May 15 09:05:08 2023 +0000
+++ b/usr.bin/indent/lexi.c Mon May 15 09:22:53 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.187 2023/05/15 08:02:01 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.188 2023/05/15 09:22:53 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: lexi.c,v 1.187 2023/05/15 08:02:01 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.188 2023/05/15 09:22:53 rillig Exp $");
#include <stdlib.h>
#include <string.h>
@@ -626,7 +626,7 @@ register_typename(const char *name)
if (typenames.len >= typenames.cap) {
typenames.cap = 16 + 2 * typenames.cap;
typenames.items = nonnull(realloc(typenames.items,
- sizeof(typenames.items[0]) * typenames.cap));
+ sizeof(typenames.items[0]) * typenames.cap));
}
int pos = bsearch_typenames(name);
diff -r c42c972c91fb -r ac8fefe05cdb usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c Mon May 15 09:05:08 2023 +0000
+++ b/usr.bin/indent/pr_comment.c Mon May 15 09:22:53 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.140 2023/05/15 07:28:45 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.141 2023/05/15 09:22:53 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pr_comment.c,v 1.140 2023/05/15 07:28:45 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.141 2023/05/15 09:22:53 rillig Exp $");
#include <string.h>
@@ -272,8 +272,8 @@ copy_comment_wrap(int line_length, bool
com_add_delim();
/*
- * Assume that output_line and com_add_delim don't invalidate
- * the "unused" part of the buffer beyond com.mem + com.len.
+ * Assume that output_line and com_add_delim don't invalidate the
+ * "unused" part of the buffer beyond com.mem + com.len.
*/
memmove(com.mem + com.len, last_word_s, last_word_len);
com.len += last_word_len;
Home |
Main Index |
Thread Index |
Old Index