Module Name: src Committed By: rillig Date: Mon May 22 23:03:16 UTC 2023
Modified Files: src/tests/usr.bin/indent: fmt_block.c src/usr.bin/indent: indent.c Log Message: indent: fix spacing between block braces To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/fmt_block.c cvs rdiff -u -r1.303 -r1.304 src/usr.bin/indent/indent.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/fmt_block.c diff -u src/tests/usr.bin/indent/fmt_block.c:1.6 src/tests/usr.bin/indent/fmt_block.c:1.7 --- src/tests/usr.bin/indent/fmt_block.c:1.6 Sat May 13 06:52:48 2023 +++ src/tests/usr.bin/indent/fmt_block.c Mon May 22 23:03:16 2023 @@ -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 Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.303 src/usr.bin/indent/indent.c:1.304 --- src/usr.bin/indent/indent.c:1.303 Mon May 22 10:28:59 2023 +++ src/usr.bin/indent/indent.c Mon May 22 23:03:16 2023 @@ -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;