Module Name: src Committed By: rillig Date: Fri Jun 9 06:36:58 UTC 2023
Modified Files: src/tests/usr.bin/indent: opt_ci.c opt_lp.c src/usr.bin/indent: indent.1 io.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/opt_ci.c \ src/tests/usr.bin/indent/opt_lp.c cvs rdiff -u -r1.32 -r1.33 src/usr.bin/indent/indent.1 cvs rdiff -u -r1.204 -r1.205 src/usr.bin/indent/io.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/opt_ci.c diff -u src/tests/usr.bin/indent/opt_ci.c:1.9 src/tests/usr.bin/indent/opt_ci.c:1.10 --- src/tests/usr.bin/indent/opt_ci.c:1.9 Thu May 18 05:33:27 2023 +++ src/tests/usr.bin/indent/opt_ci.c Fri Jun 9 06:36:58 2023 @@ -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 Index: src/tests/usr.bin/indent/opt_lp.c diff -u src/tests/usr.bin/indent/opt_lp.c:1.9 src/tests/usr.bin/indent/opt_lp.c:1.10 --- src/tests/usr.bin/indent/opt_lp.c:1.9 Thu Jun 8 20:36:35 2023 +++ src/tests/usr.bin/indent/opt_lp.c Fri Jun 9 06:36:58 2023 @@ -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), Index: src/usr.bin/indent/indent.1 diff -u src/usr.bin/indent/indent.1:1.32 src/usr.bin/indent/indent.1:1.33 --- src/usr.bin/indent/indent.1:1.32 Mon Jun 5 10:12:21 2023 +++ src/usr.bin/indent/indent.1 Fri Jun 9 06:36:57 2023 @@ -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 . Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.204 src/usr.bin/indent/io.c:1.205 --- src/usr.bin/indent/io.c:1.204 Thu Jun 8 20:36:35 2023 +++ src/usr.bin/indent/io.c Fri Jun 9 06:36:57 2023 @@ -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