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: indent multi-line expressions accordi...
details: https://anonhg.NetBSD.org/src/rev/e996006d5ebe
branches: trunk
changeset: 376281:e996006d5ebe
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Jun 09 06:36:57 2023 +0000
description:
indent: indent multi-line expressions according to parentheses
This reverts the FreeBSD change from 2004-02-12 that had been imported
on 2019-04-04.
diffstat:
tests/usr.bin/indent/opt_ci.c | 21 ++++++++-------------
tests/usr.bin/indent/opt_lp.c | 10 +++-------
usr.bin/indent/indent.1 | 7 +++----
usr.bin/indent/io.c | 10 +++-------
4 files changed, 17 insertions(+), 31 deletions(-)
diffs (146 lines):
diff -r 6fb127444f19 -r e996006d5ebe tests/usr.bin/indent/opt_ci.c
--- a/tests/usr.bin/indent/opt_ci.c Fri Jun 09 03:43:02 2023 +0000
+++ b/tests/usr.bin/indent/opt_ci.c Fri Jun 09 06:36:57 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_ci.c,v 1.9 2023/05/18 05:33:27 rillig Exp $ */
+/* $NetBSD: opt_ci.c,v 1.10 2023/06/09 06:36:58 rillig Exp $ */
/*
* Tests for the option '-ci', which controls the indentation of continuation
@@ -47,17 +47,18 @@ int top_level = (1 +
//indent end
/*
- * Since '-ci4' is half an indentation level, indent all continuations using
- * the same level, no matter how many parentheses there are. The rationale for
- * this may have been to prevent that the continuation line has the same
- * indentation as a follow-up statement, such as in 'if' statements.
+ * Between 2019-04-04 and 2023-06-09, there was a special rule that prevented
+ * indentation based on the number of open parentheses, in the case that the
+ * continuation indentation is half an indentation level, maybe to prevent that
+ * the continuation line has the same indentation as a follow-up statement,
+ * such as in 'if' statements. To prevent such ambiguities, see '-eei'.
*/
//indent run -ci4 -nlp
int top_level = 1 +
2;
int top_level = (1 +
2 + (
- 3));
+ 3));
//indent end
@@ -165,12 +166,6 @@ sum(int a, int b)
}
//indent end
-/*
- * Since '-ci4' is half an indentation level, indent all continuations using
- * the same level, no matter how many parentheses there are. The rationale for
- * this may have been to prevent that the continuation line has the same
- * indentation as a follow-up statement, such as in 'if' statements.
- */
//indent run -ci4 -nlp
int
sum(int a, int b)
@@ -179,7 +174,7 @@ sum(int a, int b)
b);
return (first +
second + (
- third));
+ third));
}
//indent end
diff -r 6fb127444f19 -r e996006d5ebe tests/usr.bin/indent/opt_lp.c
--- a/tests/usr.bin/indent/opt_lp.c Fri Jun 09 03:43:02 2023 +0000
+++ b/tests/usr.bin/indent/opt_lp.c Fri Jun 09 06:36:57 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_lp.c,v 1.9 2023/06/08 20:36:35 rillig Exp $ */
+/* $NetBSD: opt_lp.c,v 1.10 2023/06/09 06:36:58 rillig Exp $ */
/*
* Tests for the options '-lp' and '-nlp'.
@@ -66,10 +66,6 @@ example(void)
}
//indent end
-/*
- * XXX: Combining the options '-nlp' and '-ci4' is counterproductive as the
- * indentation does not make the nesting level of the function calls visible.
- */
//indent run -nlp -ci4
void
example(void)
@@ -78,9 +74,9 @@ example(void)
third_procedure(p4, p5));
p1 = first_procedure(second_procedure(p2,
- p3),
+ p3),
third_procedure(p4,
- p5));
+ p5));
p1 = first_procedure(
second_procedure(p2, p3),
diff -r 6fb127444f19 -r e996006d5ebe usr.bin/indent/indent.1
--- a/usr.bin/indent/indent.1 Fri Jun 09 03:43:02 2023 +0000
+++ b/usr.bin/indent/indent.1 Fri Jun 09 06:36:57 2023 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: indent.1,v 1.32 2023/06/05 10:12:21 rillig Exp $
+.\" $NetBSD: indent.1,v 1.33 2023/06/09 06:36:57 rillig Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -32,7 +32,7 @@
.\" @(#)indent.1 8.1 (Berkeley) 7/1/93
.\" $FreeBSD: head/usr.bin/indent/indent.1 334944 2018-06-11 05:35:57Z pstef $
.\"
-.Dd June 5, 2023
+.Dd June 9, 2023
.Dt INDENT 1
.Os
.Sh NAME
@@ -246,8 +246,7 @@ statement.
Parenthesized expressions have extra indentation added to
indicate the nesting, unless
.Fl \&lp
-is in effect
-or the continuation indent is exactly half of the main indent.
+is in effect.
.Fl \&ci
defaults to the same value as
.Fl i .
diff -r 6fb127444f19 -r e996006d5ebe usr.bin/indent/io.c
--- a/usr.bin/indent/io.c Fri Jun 09 03:43:02 2023 +0000
+++ b/usr.bin/indent/io.c Fri Jun 09 06:36:57 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.204 2023/06/08 20:36:35 rillig Exp $ */
+/* $NetBSD: io.c,v 1.205 2023/06/09 06:36:57 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: io.c,v 1.204 2023/06/08 20:36:35 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.205 2023/06/09 06:36:57 rillig Exp $");
#include <stdio.h>
@@ -252,11 +252,7 @@ compute_code_indent(void)
if (ps.extra_expr_indent != eei_no)
return base_ind + 2 * opt.continuation_indent;
- if (2 * opt.continuation_indent == opt.indent_size)
- return base_ind + opt.continuation_indent;
- else
- return base_ind +
- opt.continuation_indent * ps.line_start_nparen;
+ return base_ind + opt.continuation_indent * ps.line_start_nparen;
}
static void
Home |
Main Index |
Thread Index |
Old Index