indent: remove newline between 'switch' and '{'

This commit is contained in:
rillig 2023-06-02 14:34:14 +00:00
parent e3f25515e3
commit 9e6f62d1d8
3 changed files with 12 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fmt_decl.c,v 1.47 2023/06/02 14:21:55 rillig Exp $ */
/* $NetBSD: fmt_decl.c,v 1.48 2023/06/02 14:34:14 rillig Exp $ */
/*
* Tests for declarations of global variables, external functions, and local
@ -920,8 +920,9 @@ ch_isalpha(char ch)
//indent run -i4 -di0
// $ FIXME: 'buffer' is classified as 'word'.
// $
// $ XXX: 'char' is classified as 'type_in_parentheses'; check whether this
// $ XXX: lexer symbol should only be used for types in cast expressions.
// $ XXX: 'char' is classified as 'type_in_parentheses'; check whether
// $ XXX: lsym_type_in_parentheses should only be used for types in cast
// $ XXX: expressions.
// $
// $ FIXME: 'size_t' is classified as 'word'.
void buf_add_chars(struct buffer *, const char *, size_t);

View File

@ -1,4 +1,4 @@
/* $NetBSD: label.c,v 1.6 2023/05/13 09:40:47 rillig Exp $ */
/* $NetBSD: label.c,v 1.7 2023/06/02 14:34:14 rillig Exp $ */
/* See FreeBSD r303489 */
@ -20,9 +20,7 @@ U: ;
void
t(void)
{
switch (1)
/* $ TODO: Move the '{' up to the ')'. */
{
switch (1) {
case 1: /* test */
case 2: /* test */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: indent.c,v 1.313 2023/06/02 14:21:55 rillig Exp $ */
/* $NetBSD: indent.c,v 1.314 2023/06/02 14:34:14 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: indent.c,v 1.313 2023/06/02 14:21:55 rillig Exp $");
__RCSID("$NetBSD: indent.c,v 1.314 2023/06/02 14:34:14 rillig Exp $");
#include <sys/param.h>
#include <err.h>
@ -455,6 +455,10 @@ process_newline(void)
&& lab.len == 0 /* for preprocessing lines */
&& com.len == 0)
goto stay_in_line;
if (ps.s_sym[ps.tos] == psym_switch_expr && opt.brace_same_line) {
ps.force_nl = true;
goto stay_in_line;
}
output_line();