indent(1): Fix indent's confusion about custom FreeBSD macros.
Teach indent(1) about storage-class specifiers. Don't assume "in_parameter_declaration" state if "in_decl" hasn't been set. Don't set "in_decl" for storage-class specifiers. That set of changes helps with recognizing the difference between file scope declarations like this: static LIST_HEAD(, alq) ald_active; static int ald_shuttingdown = 0; struct thread *ald_thread; and old style function declarators like this: static int do_execve(td, args, mac_p) struct thread *td; struct image_args *args; struct mac *mac_p; { Unfortunately, at the same time this change makes indent(1) require explicit int in declarations like "static a;", in order to understand that it's part of a declaration. On the other hand, declarations like in the first example are no longer indented as if ald_shuttingdown and ald_thread were parameters of a function named LIST_HEAD. Submitted by: Piotr Stefaniak
This commit is contained in:
parent
28db0a5e74
commit
f171328eaa
@ -920,8 +920,11 @@ main(int argc, char **argv)
|
||||
}
|
||||
goto copy_id; /* move the token into line */
|
||||
|
||||
case decl: /* we have a declaration type (int, register,
|
||||
* etc.) */
|
||||
case storage:
|
||||
prefix_blankline_requested = 0;
|
||||
goto copy_id;
|
||||
|
||||
case decl: /* we have a declaration type (int, etc.) */
|
||||
parse(decl); /* let parser worry about indentation */
|
||||
if (ps.last_token == rparen && ps.tos <= 1) {
|
||||
ps.in_parameter_declaration = 1;
|
||||
|
@ -69,3 +69,4 @@
|
||||
#define elsehead 31
|
||||
#define period 32
|
||||
#define strpfx 33
|
||||
#define storage 34
|
||||
|
@ -70,6 +70,7 @@ struct templ {
|
||||
*/
|
||||
struct templ specials[] =
|
||||
{
|
||||
{"auto", 10},
|
||||
{"break", 9},
|
||||
{"case", 8},
|
||||
{"char", 4},
|
||||
@ -79,7 +80,7 @@ struct templ specials[] =
|
||||
{"double", 4},
|
||||
{"else", 6},
|
||||
{"enum", 3},
|
||||
{"extern", 4},
|
||||
{"extern", 10},
|
||||
{"float", 4},
|
||||
{"for", 5},
|
||||
{"global", 4},
|
||||
@ -88,14 +89,14 @@ struct templ specials[] =
|
||||
{"int", 4},
|
||||
{"long", 4},
|
||||
{"offsetof", 1},
|
||||
{"register", 4},
|
||||
{"register", 10},
|
||||
{"return", 9},
|
||||
{"short", 4},
|
||||
{"sizeof", 2},
|
||||
{"static", 4},
|
||||
{"static", 10},
|
||||
{"struct", 3},
|
||||
{"switch", 7},
|
||||
{"typedef", 4},
|
||||
{"typedef", 10},
|
||||
{"union", 3},
|
||||
{"unsigned", 4},
|
||||
{"void", 4},
|
||||
@ -312,6 +313,9 @@ lexi(void)
|
||||
case 6: /* do, else */
|
||||
return (sp_nparen);
|
||||
|
||||
case 10: /* storage class specifier */
|
||||
return (storage);
|
||||
|
||||
default: /* all others are treated like any other
|
||||
* identifier */
|
||||
return (ident);
|
||||
@ -323,7 +327,8 @@ lexi(void)
|
||||
if (*tp++ == ')' && (*tp == ';' || *tp == ','))
|
||||
goto not_proc;
|
||||
strncpy(ps.procname, token, sizeof ps.procname - 1);
|
||||
ps.in_parameter_declaration = 1;
|
||||
if (ps.in_decl)
|
||||
ps.in_parameter_declaration = 1;
|
||||
rparen_count = 1;
|
||||
not_proc:;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user