Module Name: src
Committed By: rillig
Date: Sun Mar 14 01:44:37 UTC 2021
Modified Files:
src/usr.bin/indent: io.c
Log Message:
indent: make compute_code_indent more readable
The '?:' operator computing the factor was too hard to read. When
quickly scanning the code, the 1 in the expression looked too much like
it would be added to the indentation, which would turn the indentation
length into a column number, and that again would smell like an
off-by-one error.
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 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/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.48 src/usr.bin/indent/io.c:1.49
--- src/usr.bin/indent/io.c:1.48 Sun Mar 14 00:22:16 2021
+++ src/usr.bin/indent/io.c Sun Mar 14 01:44:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.48 2021/03/14 00:22:16 rillig Exp $ */
+/* $NetBSD: io.c,v 1.49 2021/03/14 01:44:37 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c 8.1 (Be
#include <sys/cdefs.h>
#ifndef lint
#if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.48 2021/03/14 00:22:16 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.49 2021/03/14 01:44:37 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -291,8 +291,10 @@ compute_code_indent(void)
if (ps.paren_level != 0) {
if (!opt.lineup_to_parens)
- target_ind += opt.continuation_indent *
- (2 * opt.continuation_indent == opt.indent_size ? 1 : ps.paren_level);
+ if (2 * opt.continuation_indent == opt.indent_size)
+ target_ind += opt.continuation_indent;
+ else
+ target_ind += opt.continuation_indent * ps.paren_level;
else if (opt.lineup_to_parens_always)
/*
* XXX: where does this '- 1' come from? It looks strange but is