Module Name: src
Committed By: rillig
Date: Fri Jun 2 14:34:14 UTC 2023
Modified Files:
src/tests/usr.bin/indent: fmt_decl.c label.c
src/usr.bin/indent: indent.c
Log Message:
indent: remove newline between 'switch' and '{'
To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/label.c
cvs rdiff -u -r1.313 -r1.314 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_decl.c
diff -u src/tests/usr.bin/indent/fmt_decl.c:1.47 src/tests/usr.bin/indent/fmt_decl.c:1.48
--- src/tests/usr.bin/indent/fmt_decl.c:1.47 Fri Jun 2 14:21:55 2023
+++ src/tests/usr.bin/indent/fmt_decl.c Fri Jun 2 14:34:14 2023
@@ -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);
Index: src/tests/usr.bin/indent/label.c
diff -u src/tests/usr.bin/indent/label.c:1.6 src/tests/usr.bin/indent/label.c:1.7
--- src/tests/usr.bin/indent/label.c:1.6 Sat May 13 09:40:47 2023
+++ src/tests/usr.bin/indent/label.c Fri Jun 2 14:34:14 2023
@@ -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 */
}
Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.313 src/usr.bin/indent/indent.c:1.314
--- src/usr.bin/indent/indent.c:1.313 Fri Jun 2 14:21:55 2023
+++ src/usr.bin/indent/indent.c Fri Jun 2 14:34:14 2023
@@ -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();