From 3239d7f6ae36b059e9a19a2e5d8854be31296917 Mon Sep 17 00:00:00 2001 From: bde Date: Mon, 9 Feb 2004 15:27:02 +0000 Subject: 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. --- usr.bin/indent/lexi.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'usr.bin/indent') 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); -- cgit v1.1