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: force each statement on a new line
details: https://anonhg.NetBSD.org/src/rev/40558a67f926
branches: trunk
changeset: 376134:40558a67f926
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Jun 02 15:07:46 2023 +0000
description:
indent: force each statement on a new line
Previously, '{} while (cond)' was kept on a single line, even though the
'while' was independent of the '{}'.
diffstat:
tests/usr.bin/indent/lsym_while.c | 6 +++---
tests/usr.bin/indent/psym_stmt_list.c | 6 +++---
tests/usr.bin/indent/psym_while_expr.c | 7 +++----
usr.bin/indent/indent.c | 9 +++++++--
4 files changed, 16 insertions(+), 12 deletions(-)
diffs (91 lines):
diff -r 20588459fddb -r 40558a67f926 tests/usr.bin/indent/lsym_while.c
--- a/tests/usr.bin/indent/lsym_while.c Fri Jun 02 14:34:14 2023 +0000
+++ b/tests/usr.bin/indent/lsym_while.c Fri Jun 02 15:07:46 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_while.c,v 1.5 2023/05/13 06:52:48 rillig Exp $ */
+/* $NetBSD: lsym_while.c,v 1.6 2023/06/02 15:07:46 rillig Exp $ */
/*
* Tests for the token 'lsym_while', which represents the keyword 'while' that
@@ -44,7 +44,7 @@ void
function(void)
{
{
-/* $ FIXME: The '} while' is misleading. */
- } while (0);
+ }
+ while (0);
}
//indent end
diff -r 20588459fddb -r 40558a67f926 tests/usr.bin/indent/psym_stmt_list.c
--- a/tests/usr.bin/indent/psym_stmt_list.c Fri Jun 02 14:34:14 2023 +0000
+++ b/tests/usr.bin/indent/psym_stmt_list.c Fri Jun 02 15:07:46 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: psym_stmt_list.c,v 1.4 2022/04/24 10:36:37 rillig Exp $ */
+/* $NetBSD: psym_stmt_list.c,v 1.5 2023/06/02 15:07:46 rillig Exp $ */
/*
* Tests for the parser symbol psym_stmt_list, which represents a list of
@@ -41,7 +41,7 @@ void
return_after_rbrace(void)
{
{
-// $ FIXME: The 'return' must go in a separate line.
- } return;
+ }
+ return;
}
//indent end
diff -r 20588459fddb -r 40558a67f926 tests/usr.bin/indent/psym_while_expr.c
--- a/tests/usr.bin/indent/psym_while_expr.c Fri Jun 02 14:34:14 2023 +0000
+++ b/tests/usr.bin/indent/psym_while_expr.c Fri Jun 02 15:07:46 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: psym_while_expr.c,v 1.4 2022/04/24 09:04:12 rillig Exp $ */
+/* $NetBSD: psym_while_expr.c,v 1.5 2023/06/02 15:07:46 rillig Exp $ */
/*
* Tests for the parser symbol psym_while_expr, which represents the keyword
@@ -38,11 +38,10 @@ function(void)
} while (cond);
if (cmd)
- /* $ XXX: Where does the code say that ';' stays on the same line? */
while (cond);
{
- /* $ FIXME: the '}' must be on a line of its own. */
- } while (cond);
+ }
+ while (cond);
}
//indent end
diff -r 20588459fddb -r 40558a67f926 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Fri Jun 02 14:34:14 2023 +0000
+++ b/usr.bin/indent/indent.c Fri Jun 02 15:07:46 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.314 2023/06/02 14:34:14 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.315 2023/06/02 15:07:46 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.314 2023/06/02 14:34:14 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.315 2023/06/02 15:07:46 rillig Exp $");
#include <sys/param.h>
#include <err.h>
@@ -829,6 +829,11 @@ process_rbrace(void)
out.line_kind = lk_func_end;
parse(psym_rbrace);
+
+ if (!ps.init_or_struct
+ && ps.s_sym[ps.tos] != psym_do_stmt
+ && ps.s_sym[ps.tos] != psym_if_expr_stmt)
+ ps.force_nl = true;
}
static void
Home |
Main Index |
Thread Index |
Old Index