From ef1978d6ed1e4defe18d250226460409e6cd5447 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 27 Mar 2018 18:15:39 -0400 Subject: [PATCH] Update pgindent's typedefs blacklist, and make it easier to adjust. It seems that all buildfarm members are now using the code path, so that none of them report "bool" as a typedef. We still need it to be treated that way, so adjust pgindent to force that whether or not it's in the given list. Also, the recent introduction of LLVM infrastructure has caused the appearance of some typedef names that we definitely *don't* want treated as typedefs, such as "string" and "abs". Extend the existing blacklist to include these. (Additions based on comparing v10's typedefs list to what the buildfarm is currently emitting.) Rearrange the code so that the lists of whitelisted/blacklisted names are a bit easier to find and modify. Andrew Dunstan and Tom Lane Discussion: https://postgr.es/m/28690.1521912334@sss.pgh.pa.us --- src/tools/pgindent/pgindent | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent index a32aaa64f3..37dfccab6b 100755 --- a/src/tools/pgindent/pgindent +++ b/src/tools/pgindent/pgindent @@ -50,6 +50,19 @@ $code_base ||= '.' unless @ARGV; $excludes ||= "$code_base/src/tools/pgindent/exclude_file_patterns" if $code_base && -f "$code_base/src/tools/pgindent/exclude_file_patterns"; +# The typedef list that's mechanically extracted by the buildfarm may omit +# some names we want to treat like typedefs, e.g. "bool" (which is a macro +# according to ), and may include some names we don't want +# treated as typedefs, although various headers that some builds include +# might make them so. For the moment we just hardwire a whitelist of names +# to add and a blacklist of names to remove; eventually this may need to be +# easier to configure. Note that the typedefs need trailing newlines. +my @whitelist = ("bool\n"); + +my %blacklist = map { +"$_\n" => 1 } + qw( FD_SET date interval timestamp ANY + abs allocfunc iterator other pointer printfunc reference string type ); + # globals my @files; my $filtered_typedefs_fh; @@ -118,9 +131,11 @@ sub load_typedefs } } - # remove certain entries - @typedefs = - grep { !m/^(FD_SET|date|interval|timestamp|ANY)\n?$/ } @typedefs; + # add whitelisted entries + push(@typedefs, @whitelist); + + # remove blacklisted entries + @typedefs = grep { ! $blacklist{$_} } @typedefs; # write filtered typedefs my $filter_typedefs_fh = new File::Temp(TEMPLATE => "pgtypedefXXXXX");