summaryrefslogtreecommitdiff
path: root/indent.c
AgeCommit message (Collapse)Author
2020-06-30Avoid duplicate declarations of bsdindent's global variables.Tom Lane
Arrange for all the variable declarations in indent_globs.h to look like "extern" declarations to every .c file except indent.c. This prevents linker failure due to duplicated global variables when the code is built with -fno-common, which is soon to be gcc's default. The method of temporarily #define'ing "extern" to empty is a hack, no doubt, but it avoids requiring a duplicate set of variable definitions, so it seemed like the best way. Discussion: https://postgr.es/m/20200629165051.xlfqhstajf6ynxyv@alap3.anarazel.de
2020-05-16Fix formatting of macros that take types.Tom Lane
Previously, we would assume that a macro like IsA() in the following example was a cast just because it mentions a known type between parens, and that messed up the formatting of any binary operator that followed: if (IsA(outer_path, UniquePath) ||path->skip_mark_restore) This change errs on the side of assuming that function-like macros are similar to sizeof() and offsetof(), so that operators are formatted correctly: if (IsA(outer_path, UniquePath) || path->skip_mark_restore) Thomas Munro Discussion: https://postgr.es/m/20200114221814.GA19630@alvherre.pgsql
2020-05-16Silence -Wimplicit-fallthrough warnings in pg_bsd_indent.Tom Lane
Since the recommended build method uses Postgres' preferred CFLAGS, and those now include -Wimplicit-fallthrough, we now see these warnings where we did not before. Michael Paquier Discussion: https://postgr.es/m/20200515060318.GB79590@paquier.xyz
2019-05-19Rip out -kr/-nkr switches again.Tom Lane
The upstream maintainer doesn't want these, so drop 'em. Also, teach is_func_definition() about //-style comments. The main lexi.c code doesn't know about those either, but I assume somebody will wish to fix that at some point.
2019-05-18Improve indent's ability to distinguish function defs from decls.Tom Lane
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.
2017-06-20Adjust in_decl logic to avoid messing up enum declarations.Tom Lane
This is a workaround for an acknowledged upstream bug; it basically reverts this logic to the way it was in NetBSD indent. While there may eventually be a different upstream fix, this will do for our purposes. Add a regression test case that illustrates the problem, and tweak declarations.0.stdout for slightly different formatting produced for a function pointer typedef.
2017-06-20Add feature patch for -tpg/-ntpg.Tom Lane
This switch enables using Postgres' rules for using tabs vs spaces in indents, to match the output of our old "entab" program. The FreeBSD maintainer wants no part of this, so we'll have to carry this as a forked patch. (The alternative is to go over to use-tabs- whenever-possible rules, but that would result in circa 10K lines of invisible whitespace diffs in the PG sources, which seems like lots more pain than is justified.)
2017-06-20Adjust #include's to build in Postgres rather than FreeBSD environment.Tom Lane
Remove '#include <sys/cdefs.h>', which will fail in many non-BSD environments, as well as the __FBSDID() FreeBSD-ism. Replace them with '#include "c.h"', which will allow use of the Postgres project's portability infrastructure. This is intended to be a permanent diff between the FreeBSD upstream files and our copy.
2017-06-20Import current development version of FreeBSD indent.Tom Lane
This commit copies Piotr Stefaniak's development repo https://github.com/pstef/freebsd_indent as of commit 5d3b621cd54de672983c51d9622dee84d458dd83 (2017-06-18). But I've omitted Makefile and Makefile.depend, as they are of no use in non-BSD build environments.