Module Name: src
Committed By: rillig
Date: Sun Jun 4 13:49:00 UTC 2023
Modified Files:
src/tests/usr.bin/indent: lsym_lbrace.c lsym_lparen_or_lbracket.c
lsym_rbrace.c
src/usr.bin/indent: io.c
Log Message:
indent: fix indentation of initializers in compound expressions
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/lsym_lbrace.c
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/lsym_rbrace.c
cvs rdiff -u -r1.188 -r1.189 src/usr.bin/indent/io.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/indent/lsym_lbrace.c
diff -u src/tests/usr.bin/indent/lsym_lbrace.c:1.7 src/tests/usr.bin/indent/lsym_lbrace.c:1.8
--- src/tests/usr.bin/indent/lsym_lbrace.c:1.7 Sat Jun 3 21:44:08 2023
+++ src/tests/usr.bin/indent/lsym_lbrace.c Sun Jun 4 13:49:00 2023
@@ -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
Index: src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c
diff -u src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.10 src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.11
--- src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.10 Sun Jun 4 13:26:07 2023
+++ src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c Sun Jun 4 13:49:00 2023
@@ -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
Index: src/tests/usr.bin/indent/lsym_rbrace.c
diff -u src/tests/usr.bin/indent/lsym_rbrace.c:1.5 src/tests/usr.bin/indent/lsym_rbrace.c:1.6
--- src/tests/usr.bin/indent/lsym_rbrace.c:1.5 Sat Jun 3 21:44:08 2023
+++ src/tests/usr.bin/indent/lsym_rbrace.c Sun Jun 4 13:49:00 2023
@@ -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
Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.188 src/usr.bin/indent/io.c:1.189
--- src/usr.bin/indent/io.c:1.188 Sun Jun 4 11:09:18 2023
+++ src/usr.bin/indent/io.c Sun Jun 4 13:49:00 2023
@@ -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;