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: fix indentation of initializers in co...



details:   https://anonhg.NetBSD.org/src/rev/2a2c950129ed
branches:  trunk
changeset: 376198:2a2c950129ed
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jun 04 13:49:00 2023 +0000

description:
indent: fix indentation of initializers in compound expressions

diffstat:

 tests/usr.bin/indent/lsym_lbrace.c             |  14 ++------------
 tests/usr.bin/indent/lsym_lparen_or_lbracket.c |   5 ++---
 tests/usr.bin/indent/lsym_rbrace.c             |  14 ++------------
 usr.bin/indent/io.c                            |   7 ++++---
 4 files changed, 10 insertions(+), 30 deletions(-)

diffs (97 lines):

diff -r 93625da3c116 -r 2a2c950129ed tests/usr.bin/indent/lsym_lbrace.c
--- a/tests/usr.bin/indent/lsym_lbrace.c        Sun Jun 04 13:26:06 2023 +0000
+++ b/tests/usr.bin/indent/lsym_lbrace.c        Sun Jun 04 13:49:00 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_lbrace.c,v 1.7 2023/06/03 21:44:08 rillig Exp $ */
+/* $NetBSD: lsym_lbrace.c,v 1.8 2023/06/04 13:49:00 rillig Exp $ */
 
 /*
  * Tests for the token lsym_lbrace, which represents a '{' in these contexts:
@@ -62,14 +62,4 @@ origin(void)
 }
 //indent end
 
-//indent run
-struct point
-origin(void)
-{
-       return (struct point){
-               .x = 0,
-/* $ FIXME: All initializers must be indented to the same level. */
-                       .y = 0,
-       };
-}
-//indent end
+//indent run-equals-input
diff -r 93625da3c116 -r 2a2c950129ed tests/usr.bin/indent/lsym_lparen_or_lbracket.c
--- a/tests/usr.bin/indent/lsym_lparen_or_lbracket.c    Sun Jun 04 13:26:06 2023 +0000
+++ b/tests/usr.bin/indent/lsym_lparen_or_lbracket.c    Sun Jun 04 13:49:00 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.10 2023/06/04 13:26:07 rillig Exp $ */
+/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.11 2023/06/04 13:49:00 rillig Exp $ */
 
 /*
  * Tests for the token lsym_lparen_or_lbracket, which represents a '(' or '['
@@ -215,8 +215,7 @@ function(void)
        return (struct point){.x = 0, .y = 0};
        return (struct point){
                .x = 0,
-// $ FIXME: The initializers must be indented the same.
-                       .y = 0,
+               .y = 0,
        };
 }
 //indent end
diff -r 93625da3c116 -r 2a2c950129ed tests/usr.bin/indent/lsym_rbrace.c
--- a/tests/usr.bin/indent/lsym_rbrace.c        Sun Jun 04 13:26:06 2023 +0000
+++ b/tests/usr.bin/indent/lsym_rbrace.c        Sun Jun 04 13:49:00 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_rbrace.c,v 1.5 2023/06/03 21:44:08 rillig Exp $ */
+/* $NetBSD: lsym_rbrace.c,v 1.6 2023/06/04 13:49:00 rillig Exp $ */
 
 /*
  * Tests for the token lsym_rbrace, which represents a '}' in these contexts:
@@ -65,14 +65,4 @@ origin(void)
 }
 //indent end
 
-//indent run
-struct point
-origin(void)
-{
-       return (struct point){
-               .x = 0,
-/* $ FIXME: All initializers must be indented to the same level. */
-                       .y = 0,
-       };
-}
-//indent end
+//indent run-equals-input
diff -r 93625da3c116 -r 2a2c950129ed usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Sun Jun 04 13:26:06 2023 +0000
+++ b/usr.bin/indent/io.c       Sun Jun 04 13:49:00 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.188 2023/06/04 11:09:18 rillig Exp $  */
+/*     $NetBSD: io.c,v 1.189 2023/06/04 13:49:00 rillig Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: io.c,v 1.188 2023/06/04 11:09:18 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.189 2023/06/04 13:49:00 rillig Exp $");
 
 #include <stdio.h>
 
@@ -300,7 +300,8 @@ output_line(void)
 
 dont_write_line:
        ps.decl_on_line = ps.in_decl;   /* for proper comment indentation */
-       ps.in_stmt_cont = ps.in_stmt_or_decl && !ps.in_decl;
+       ps.in_stmt_cont = ps.in_stmt_or_decl
+           && !ps.in_decl && ps.block_init_level <= 0;
        ps.decl_indent_done = false;
        if (ps.extra_expr_indent == eei_last)
                ps.extra_expr_indent = eei_no;



Home | Main Index | Thread Index | Old Index