Module Name: src
Committed By: rillig
Date: Mon May 15 09:22:53 UTC 2023
Modified Files:
src/usr.bin/indent: .indent.pro indent.c lexi.c pr_comment.c
Log Message:
indent: let indent format its own code
With manual corrections, as indent does not properly indent multi-line
'?:' expressions nor multi-line controlling expressions.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/indent/.indent.pro
cvs rdiff -u -r1.272 -r1.273 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.187 -r1.188 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.140 -r1.141 src/usr.bin/indent/pr_comment.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/indent/.indent.pro
diff -u src/usr.bin/indent/.indent.pro:1.3 src/usr.bin/indent/.indent.pro:1.4
--- src/usr.bin/indent/.indent.pro:1.3 Tue Oct 26 19:36:30 2021
+++ src/usr.bin/indent/.indent.pro Mon May 15 09:22:53 2023
@@ -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
Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.272 src/usr.bin/indent/indent.c:1.273
--- src/usr.bin/indent/indent.c:1.272 Mon May 15 08:56:39 2023
+++ src/usr.bin/indent/indent.c Mon May 15 09:22:53 2023
@@ -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;
}
}
Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.187 src/usr.bin/indent/lexi.c:1.188
--- src/usr.bin/indent/lexi.c:1.187 Mon May 15 08:02:01 2023
+++ src/usr.bin/indent/lexi.c Mon May 15 09:22:53 2023
@@ -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);
Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.140 src/usr.bin/indent/pr_comment.c:1.141
--- src/usr.bin/indent/pr_comment.c:1.140 Mon May 15 07:28:45 2023
+++ src/usr.bin/indent/pr_comment.c Mon May 15 09:22:53 2023
@@ -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;