Improve indent's ability to distinguish function defs from decls.
authorTom Lane <[email protected]>
Sat, 18 May 2019 23:59:04 +0000 (19:59 -0400)
committerTom Lane <[email protected]>
Sat, 18 May 2019 23:59:04 +0000 (19:59 -0400)
commit4119af8f726646505834bd4cc05ff1925fae3046
tree863fc467bcfdc20fba2947f9d79021ccb4afaec0
parent691ff7ca0ec314b9845934f5df006469d1e24172
Improve indent's ability to distinguish function defs from decls.

The previous coding for deciding whether "foo(" begins a function
definition or just a declaration was quite stupid: it could be
fooled by nested parentheses in the parameter list, or comments
in or after the parameter list, or whitespace just after the
parameter list.  And it didn't work if the parameter list crossed
a line boundary, either.

We can upgrade all those cases without any objectionable side
effects, I believe.  However, there's one more case that's
problematic: if there's non-punctuation stuff after the
parenthesized arguments, it's difficult to tell whether that
stuff is K&R-style parameter declarations or function attributes.
I don't care to try to make the lookahead code smart enough to
tell the difference, so instead let's invent a switch to tell
what to do.  The '-kr' mode is backward-compatible, hence the
default.  The '-nkr' mode will do the right thing with function
attributes and the wrong thing with pre-ANSI function declarations;
but for a code base with none of the latter, that hardly matters.
args.c
indent.1
indent.c
indent_globs.h
lexi.c