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: format its own code



details:   https://anonhg.NetBSD.org/src/rev/ea2da65fb73d
branches:  trunk
changeset: 376284:ea2da65fb73d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jun 09 07:20:30 2023 +0000

description:
indent: format its own code

diffstat:

 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(-)

diffs (158 lines):

diff -r 058d207b34d5 -r ea2da65fb73d usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Fri Jun 09 07:18:52 2023 +0000
+++ b/usr.bin/indent/indent.c   Fri Jun 09 07:20:30 2023 +0000
@@ -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;
        }
 }
diff -r 058d207b34d5 -r ea2da65fb73d usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Fri Jun 09 07:18:52 2023 +0000
+++ b/usr.bin/indent/io.c       Fri Jun 09 07:20:30 2023 +0000
@@ -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;
diff -r 058d207b34d5 -r ea2da65fb73d usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Fri Jun 09 07:18:52 2023 +0000
+++ b/usr.bin/indent/lexi.c     Fri Jun 09 07:20:30 2023 +0000
@@ -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);
diff -r 058d207b34d5 -r ea2da65fb73d usr.bin/indent/parse.c
--- a/usr.bin/indent/parse.c    Fri Jun 09 07:18:52 2023 +0000
+++ b/usr.bin/indent/parse.c    Fri Jun 09 07:20:30 2023 +0000
@@ -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;
                }
diff -r 058d207b34d5 -r ea2da65fb73d usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c       Fri Jun 09 07:18:52 2023 +0000
+++ b/usr.bin/indent/pr_comment.c       Fri Jun 09 07:20:30 2023 +0000
@@ -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;



Home | Main Index | Thread Index | Old Index