summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2004-02-09 15:27:02 +0000
committerbde <bde@FreeBSD.org>2004-02-09 15:27:02 +0000
commit3239d7f6ae36b059e9a19a2e5d8854be31296917 (patch)
treefb3b7e9c82d5f19873df42bc21d4df00195663a5 /usr.bin
parent7d2a30ec45c5332e217c7c4c3602909138da8206 (diff)
downloadFreeBSD-src-3239d7f6ae36b059e9a19a2e5d8854be31296917.zip
FreeBSD-src-3239d7f6ae36b059e9a19a2e5d8854be31296917.tar.gz
Fixed misformatting of "struct foo *bar" in function parameter lists. It
was mangled to "struct foo * bar". There should be an option to control this, but no space is normal. This finishes fixing the bugs in rev.1.4. indent(1) still doesn't really understand types in parameter lists. It thinks keywords inside parentheses are for casts or sizeofs. This works accidentally for scalar types and this quick fix makes it work similarly but not so accidentally for struct/union/enum types.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/indent/lexi.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/usr.bin/indent/lexi.c b/usr.bin/indent/lexi.c
index d2d2c1c..3d30bb3 100644
--- a/usr.bin/indent/lexi.c
+++ b/usr.bin/indent/lexi.c
@@ -234,14 +234,18 @@ lexi(void)
}
ps.its_a_keyword = false;
ps.sizeof_keyword = false;
- if (l_struct) { /* if last token was 'struct', then this token
+ if (l_struct && !ps.p_l_follow) {
+ /* if last token was 'struct' and we're not
+ * in parentheses, then this token
* should be treated as a declaration */
l_struct = false;
last_code = ident;
ps.last_u_d = true;
return (decl);
}
- ps.last_u_d = false; /* Operator after identifier is binary */
+ ps.last_u_d = l_struct; /* Operator after identifier is binary
+ * unless last token was 'struct' */
+ l_struct = false;
last_code = ident; /* Remember that this is the code we will
* return */
@@ -273,18 +277,17 @@ lexi(void)
return (casestmt);
case 3: /* a "struct" */
- if (ps.p_l_follow)
- break; /* inside parens: cast */
- l_struct = true;
-
/*
* Next time around, we will want to know that we have had a
* 'struct'
*/
+ l_struct = true;
+ /* FALLTHROUGH */
+
case 4: /* one of the declaration keywords */
if (ps.p_l_follow) {
- ps.cast_mask |= 1 << ps.p_l_follow;
- break; /* inside parens: cast */
+ ps.cast_mask |= (1 << ps.p_l_follow) & ~ps.sizeof_mask;
+ break; /* inside parens: cast, param list or sizeof */
}
last_code = decl;
return (decl);
OpenPOWER on IntegriCloud