svn commit: r334480 - in head/usr.bin/indent: . tests
Piotr Pawel Stefaniak
pstef at FreeBSD.org
Fri Jun 1 09:58:46 UTC 2018
Author: pstef
Date: Fri Jun 1 09:58:44 2018
New Revision: 334480
URL: https://svnweb.freebsd.org/changeset/base/334480
Log:
indent(1): don't add unneeded space to function pointer declarations
If the current token is an opening parenthesis, it's either a function call
(or sizeof or offsetof) or a declaration. The former doesn't need a space
before the parenthesis.
Modified:
head/usr.bin/indent/indent.c
head/usr.bin/indent/tests/declarations.0.stdout
Modified: head/usr.bin/indent/indent.c
==============================================================================
--- head/usr.bin/indent/indent.c Fri Jun 1 09:44:23 2018 (r334479)
+++ head/usr.bin/indent/indent.c Fri Jun 1 09:58:44 2018 (r334480)
@@ -542,15 +542,6 @@ check_type:
nitems(ps.paren_indents));
ps.p_l_follow--;
}
- if (ps.want_blank && *token != '[' &&
- ((ps.last_token != ident && ps.last_token != funcname) ||
- proc_calls_space ||
- /* offsetof (1) is never allowed a space; sizeof (2) gets
- * one iff -bs; all other keywords (>2) always get a space
- * before lparen */
- ps.keyword + Bill_Shannon > 2))
- *e_code++ = ' ';
- ps.want_blank = false;
if (ps.in_decl && !ps.block_init && !ps.dumped_decl_indent &&
!is_procname && ps.paren_level == 0) {
/* function pointer declarations */
@@ -563,6 +554,14 @@ check_type:
}
ps.dumped_decl_indent = true;
}
+ else if (ps.want_blank && *token != '[' &&
+ ((ps.last_token != ident && ps.last_token != funcname) ||
+ /* offsetof (1) is never allowed a space; sizeof (2) gets
+ * one iff -bs; all other keywords (>2) always get a space
+ * before lparen */
+ ps.keyword + Bill_Shannon > 2))
+ *e_code++ = ' ';
+ ps.want_blank = false;
if (!troff)
*e_code++ = token[0];
ps.paren_indents[ps.p_l_follow - 1] = count_spaces_until(1, s_code, e_code) - 1;
Modified: head/usr.bin/indent/tests/declarations.0.stdout
==============================================================================
--- head/usr.bin/indent/tests/declarations.0.stdout Fri Jun 1 09:44:23 2018 (r334479)
+++ head/usr.bin/indent/tests/declarations.0.stdout Fri Jun 1 09:58:44 2018 (r334480)
@@ -32,7 +32,7 @@ t2(char *x, int y)
int a, b, c;
int
*d, *e, *f;
- int (*g) (), (*h) (), (*i) ();
+ int (*g) (), (*h) (), (*i) ();
int j, k, l;
int m
,n
More information about the svn-src-head
mailing list