summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2020-05-16 15:36:23 +0000
committerTom Lane2020-05-16 15:36:23 +0000
commit5e19d6df5ef407f1ca94ddbcfe4d3c1aa832fd3c (patch)
tree49725925ad0e01683fc8d68e770d83c3b506329c
parent93d76541520ce8c2d47d422c6c3f46648b6449f2 (diff)
Fix formatting of macros that take types.
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/[email protected]
-rw-r--r--indent.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/indent.c b/indent.c
index 5da3401..62d4d01 100644
--- a/indent.c
+++ b/indent.c
@@ -570,8 +570,13 @@ check_type:
ps.in_or_st = false; /* turn off flag for structure decl or
* initialization */
}
- /* parenthesized type following sizeof or offsetof is not a cast */
- if (ps.keyword == 1 || ps.keyword == 2)
+ /*
+ * parenthesized type following sizeof or offsetof is not a cast,
+ * and we assume the same for any other non-keyword identifier,
+ * to support macros that take types
+ */
+ if (ps.last_token == ident &&
+ (ps.keyword == 0 || ps.keyword == 1 || ps.keyword == 2))
ps.not_cast_mask |= 1 << ps.p_l_follow;
break;