From ae466e022e32b4b72435351b39db7c596626315c Mon Sep 17 00:00:00 2001 From: obrien Date: Sat, 9 Dec 2000 09:45:09 +0000 Subject: "Implement -[n]fcb (formatting of block comments) and attempt to implement no-space=after-sizeof (not optional) and no-space-after 'struct foo *' (not optional). Without these, indent unKNFizes even more perfectly KNF code." Submitted by: bde --- usr.bin/indent/lexi.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'usr.bin/indent/lexi.c') diff --git a/usr.bin/indent/lexi.c b/usr.bin/indent/lexi.c index 7a0929f..2db3e0a 100644 --- a/usr.bin/indent/lexi.c +++ b/usr.bin/indent/lexi.c @@ -35,6 +35,7 @@ #ifndef lint static char sccsid[] = "@(#)lexi.c 8.1 (Berkeley) 6/6/93"; +static char rcsid[] = "@(#)$FreeBSD$"; #endif /* not lint */ /* @@ -58,7 +59,7 @@ struct templ { int rwcode; }; -struct templ specials[100] = +struct templ specials[1000] = { "switch", 1, "case", 2, @@ -88,6 +89,8 @@ struct templ specials[100] = "else", 6, "do", 6, "sizeof", 7, + "const", 9, + "volatile", 9, 0, 0 }; @@ -257,18 +260,27 @@ lexi() return (casestmt); case 3: /* a "struct" */ - if (ps.p_l_follow) - break; /* inside parens: cast */ + /* + * Next time around, we may want to know that we have had a + * 'struct' + */ l_struct = true; /* - * Next time around, we will want to know that we have had a - * 'struct' + * Fall through to test for a cast, function prototype or + * sizeof(). */ case 4: /* one of the declaration keywords */ if (ps.p_l_follow) { ps.cast_mask |= 1 << ps.p_l_follow; - break; /* inside parens: cast */ + + /* + * Forget that we saw `struct' if we're in a sizeof(). + */ + if (ps.sizeof_mask) + l_struct = false; + + break; /* inside parens: cast, prototype or sizeof() */ } last_code = decl; return (decl); -- cgit v1.1