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 spacing between block braces
details: https://anonhg.NetBSD.org/src/rev/53b0488fbea4
branches: trunk
changeset: 375956:53b0488fbea4
user: rillig <rillig%NetBSD.org@localhost>
date: Mon May 22 23:03:16 2023 +0000
description:
indent: fix spacing between block braces
diffstat:
tests/usr.bin/indent/fmt_block.c | 20 +++-----------------
usr.bin/indent/indent.c | 7 ++++---
2 files changed, 7 insertions(+), 20 deletions(-)
diffs (64 lines):
diff -r 7b4d2e839fcc -r 53b0488fbea4 tests/usr.bin/indent/fmt_block.c
--- a/tests/usr.bin/indent/fmt_block.c Mon May 22 23:01:27 2023 +0000
+++ b/tests/usr.bin/indent/fmt_block.c Mon May 22 23:03:16 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fmt_block.c,v 1.6 2023/05/13 06:52:48 rillig Exp $ */
+/* $NetBSD: fmt_block.c,v 1.7 2023/05/22 23:03:16 rillig Exp $ */
/*
* Tests for formatting blocks of statements and declarations.
@@ -47,24 +47,10 @@ void
function(void)
{
{
-/* $ FIXME: '{' must start a new line. */
- } {
- }
-}
-//indent end
-
-/*
- * The buggy behavior only occurs with the default setting '-br', which
- * places an opening brace to the right of the preceding 'if (expr)' or
- * similar statements.
- */
-//indent run -bl
-void
-function(void)
-{
- {
}
{
}
}
//indent end
+
+//indent run-equals-prev-output -bl
diff -r 7b4d2e839fcc -r 53b0488fbea4 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Mon May 22 23:01:27 2023 +0000
+++ b/usr.bin/indent/indent.c Mon May 22 23:03:16 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.303 2023/05/22 10:28:59 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.304 2023/05/22 23:03:16 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.303 2023/05/22 10:28:59 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.304 2023/05/22 23:03:16 rillig Exp $");
#include <sys/param.h>
#include <err.h>
@@ -669,7 +669,8 @@ process_lbrace(void)
ps.block_init_level++;
if (code.len > 0 && !ps.block_init) {
- if (!opt.brace_same_line)
+ if (!opt.brace_same_line ||
+ (code.len > 0 && code.mem[code.len - 1] == '}'))
output_line();
else if (ps.in_func_def_params && !ps.init_or_struct) {
ps.ind_level_follow = 0;
Home |
Main Index |
Thread Index |
Old Index