summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2004-02-12 16:25:12 +0000
committerbde <bde@FreeBSD.org>2004-02-12 16:25:12 +0000
commit8827bc9d32492fd8a06aa71cc135eb6a8752a7da (patch)
tree6cc94d660024fab2b2de30a050a5b972a8ab25ed
parenta059eb3a326c7a5efb9863919466e59f8f13ecfc (diff)
downloadFreeBSD-src-8827bc9d32492fd8a06aa71cc135eb6a8752a7da.zip
FreeBSD-src-8827bc9d32492fd8a06aa71cc135eb6a8752a7da.tar.gz
Only indent once for continuation lines when not lining up with
parentheses if the continuation indent is exactly half of the main indent. Indenting one contination indent for every level of parentheses gives bad results in most cases and is not what is done in about 90% of properly hand-formatted KNF code (sys/kern/*.c, nvi/common/*.c). The main advantage of the non-default KNF options -nlp -ci4 is that continuation lines don't accidentally line up with the next main indentation level or march to the right, and increasing their indentation defeats this. This behaviour change is limited to when the continuation indent is exactly half of the main indent to avoid adding yet another option.
-rw-r--r--usr.bin/indent/indent.15
-rw-r--r--usr.bin/indent/io.c3
2 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/indent/indent.1 b/usr.bin/indent/indent.1
index 1720c99..822f64f 100644
--- a/usr.bin/indent/indent.1
+++ b/usr.bin/indent/indent.1
@@ -34,7 +34,7 @@
.\" @(#)indent.1 8.1 (Berkeley) 7/1/93
.\" $FreeBSD$
.\"
-.Dd July 1, 1993
+.Dd Februrary 13, 2004
.Dt INDENT 1
.Os
.Sh NAME
@@ -196,7 +196,8 @@ lines will be indented that far from the beginning of the first line of the
statement. Parenthesized expressions have extra indentation added to
indicate the nesting, unless
.Fl \&lp
-is in effect.
+is in effect
+or the contination indent is exactly half of the main indent.
.Fl \&ci
defaults to the same value as
.Fl i .
diff --git a/usr.bin/indent/io.c b/usr.bin/indent/io.c
index 7af2d19..3a2eaf4 100644
--- a/usr.bin/indent/io.c
+++ b/usr.bin/indent/io.c
@@ -295,7 +295,8 @@ compute_code_target(void)
if (ps.paren_level)
if (!lineup_to_parens)
- target_col += continuation_indent * ps.paren_level;
+ target_col += continuation_indent
+ * (2 * continuation_indent == ps.ind_size ? 1 : ps.paren_level);
else {
int w;
int t = paren_target;
OpenPOWER on IntegriCloud