From 545ff05aaa5496948e4168d66fd0c48030c53a41 Mon Sep 17 00:00:00 2001 From: rillig Date: Fri, 9 Jun 2023 07:20:30 +0000 Subject: [PATCH] indent: format its own code --- usr.bin/indent/indent.c | 12 ++++++------ usr.bin/indent/io.c | 6 +++--- usr.bin/indent/lexi.c | 6 +++--- usr.bin/indent/parse.c | 6 +++--- usr.bin/indent/pr_comment.c | 9 ++++----- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c index 2e0d7453a987..34943a80ac1a 100644 --- a/usr.bin/indent/indent.c +++ b/usr.bin/indent/indent.c @@ -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 -__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 #include @@ -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; } } diff --git a/usr.bin/indent/io.c b/usr.bin/indent/io.c index 5905d426b8d9..bfa69b4b6482 100644 --- a/usr.bin/indent/io.c +++ b/usr.bin/indent/io.c @@ -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 -__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 @@ -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; diff --git a/usr.bin/indent/lexi.c b/usr.bin/indent/lexi.c index c6693e65bc3f..d3d1085b9284 100644 --- a/usr.bin/indent/lexi.c +++ b/usr.bin/indent/lexi.c @@ -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 -__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 #include @@ -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); diff --git a/usr.bin/indent/parse.c b/usr.bin/indent/parse.c index 012a715ed380..065204d7b18d 100644 --- a/usr.bin/indent/parse.c +++ b/usr.bin/indent/parse.c @@ -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 -__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 @@ -236,7 +236,7 @@ parse(parser_symbol psym) case psym_rbrace: /* stack should have or */ if (!(psyms->top > 0 - && is_lbrace(psyms->sym[psyms->top - 1]))) { + && is_lbrace(psyms->sym[psyms->top - 1]))) { diag(1, "Statement nesting error"); break; } diff --git a/usr.bin/indent/pr_comment.c b/usr.bin/indent/pr_comment.c index 067723c84de3..3627ddc03ada 100644 --- a/usr.bin/indent/pr_comment.c +++ b/usr.bin/indent/pr_comment.c @@ -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 -__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 @@ -198,9 +198,8 @@ copy_comment_wrap_text(int line_length, ssize_t *last_blank) 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;