Module Name: src
Committed By: rillig
Date: Fri Jun 9 07:20:31 UTC 2023
Modified Files:
src/usr.bin/indent: indent.c io.c lexi.c parse.c pr_comment.c
Log Message:
indent: format its own code
To generate a diff of this commit:
cvs rdiff -u -r1.341 -r1.342 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.205 -r1.206 src/usr.bin/indent/io.c
cvs rdiff -u -r1.217 -r1.218 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.69 -r1.70 src/usr.bin/indent/parse.c
cvs rdiff -u -r1.157 -r1.158 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.c
diff -u src/usr.bin/indent/indent.c:1.341 src/usr.bin/indent/indent.c:1.342
--- src/usr.bin/indent/indent.c:1.341 Thu Jun 8 21:18:54 2023
+++ src/usr.bin/indent/indent.c Fri Jun 9 07:20:30 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.341 2023/06/08 21:18:54 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.342 2023/06/09 07:20:30 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.341 2023/06/08 21:18:54 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.342 2023/06/09 07:20:30 rillig Exp $");
#include <sys/param.h>
#include <err.h>
@@ -569,7 +569,7 @@ process_unary_op(void)
indent_declarator(ind, ps.tabs_to_var);
ps.want_blank = false;
} else if ((token.s[0] == '+' || token.s[0] == '-')
- && code.len > 0 && code.s[code.len - 1] == token.s[0])
+ && code.len > 0 && code.s[code.len - 1] == token.s[0])
ps.want_blank = true;
if (ps.want_blank)
@@ -682,7 +682,7 @@ process_lbrace(void)
if (ps.prev_lsym == lsym_rparen
&& ps.psyms.top >= 2
&& !(psym == psym_for_exprs || psym == psym_if_expr
- || psym == psym_switch_expr || psym == psym_while_expr)) {
+ || psym == psym_switch_expr || psym == psym_while_expr)) {
ps.block_init = true;
ps.init_or_struct = true;
}
@@ -901,8 +901,8 @@ process_comma(void)
ps.block_init = false;
int typical_varname_length = 8;
if (ps.break_after_comma && (opt.break_after_comma ||
- ind_add(compute_code_indent(), code.s, code.len)
- >= opt.max_line_length - typical_varname_length))
+ ind_add(compute_code_indent(), code.s, code.len)
+ >= opt.max_line_length - typical_varname_length))
ps.force_nl = true;
}
}
Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.205 src/usr.bin/indent/io.c:1.206
--- src/usr.bin/indent/io.c:1.205 Fri Jun 9 06:36:57 2023
+++ src/usr.bin/indent/io.c Fri Jun 9 07:20:30 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.205 2023/06/09 06:36:57 rillig Exp $ */
+/* $NetBSD: io.c,v 1.206 2023/06/09 07:20:30 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: io.c,v 1.205 2023/06/09 06:36:57 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.206 2023/06/09 07:20:30 rillig Exp $");
#include <stdio.h>
@@ -375,7 +375,7 @@ prepare_next_line:
if (ps.extra_expr_indent == eei_last)
ps.extra_expr_indent = eei_no;
if (!(ps.psyms.sym[ps.psyms.top] == psym_if_expr_stmt_else
- && ps.nparen > 0))
+ && ps.nparen > 0))
ps.ind_level = ps.ind_level_follow;
ps.line_start_nparen = ps.nparen;
ps.want_blank = false;
Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.217 src/usr.bin/indent/lexi.c:1.218
--- src/usr.bin/indent/lexi.c:1.217 Thu Jun 8 21:18:54 2023
+++ src/usr.bin/indent/lexi.c Fri Jun 9 07:20:30 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.217 2023/06/08 21:18:54 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.218 2023/06/09 07:20:30 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: lexi.c,v 1.217 2023/06/08 21:18:54 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.218 2023/06/09 07:20:30 rillig Exp $");
#include <stdlib.h>
#include <string.h>
@@ -689,7 +689,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/parse.c
diff -u src/usr.bin/indent/parse.c:1.69 src/usr.bin/indent/parse.c:1.70
--- src/usr.bin/indent/parse.c:1.69 Wed Jun 7 15:46:12 2023
+++ src/usr.bin/indent/parse.c Fri Jun 9 07:20:30 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.69 2023/06/07 15:46:12 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.70 2023/06/09 07:20:30 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: parse.c,v 1.69 2023/06/07 15:46:12 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.70 2023/06/09 07:20:30 rillig Exp $");
#include <err.h>
@@ -236,7 +236,7 @@ parse(parser_symbol psym)
case psym_rbrace:
/* stack should have <lbrace> <stmt> or <lbrace> <stmt_list> */
if (!(psyms->top > 0
- && is_lbrace(psyms->sym[psyms->top - 1]))) {
+ && is_lbrace(psyms->sym[psyms->top - 1]))) {
diag(1, "Statement nesting error");
break;
}
Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.157 src/usr.bin/indent/pr_comment.c:1.158
--- src/usr.bin/indent/pr_comment.c:1.157 Fri Jun 9 07:18:52 2023
+++ src/usr.bin/indent/pr_comment.c Fri Jun 9 07:20:30 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.157 2023/06/09 07:18:52 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.158 2023/06/09 07:20:30 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pr_comment.c,v 1.157 2023/06/09 07:18:52 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.158 2023/06/09 07:20:30 rillig Exp $");
#include <string.h>
@@ -198,9 +198,8 @@ copy_comment_wrap_text(int line_length,
output_line();
com_add_delim();
- /* Assume that output_line and com_add_delim don't
- * invalidate the "unused" part of the buffer beyond
- * com.s + com.len. */
+ /* Assume that output_line and com_add_delim don't invalidate the
+ * "unused" part of the buffer beyond com.s + com.len. */
memmove(com.s + com.len, last_word_s, last_word_len);
com.len += last_word_len;
*last_blank = -1;