Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ef1978d

Browse files
committed
Update pgindent's typedefs blacklist, and make it easier to adjust.
It seems that all buildfarm members are now using the <stdbool.h> 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
1 parent 442accc commit ef1978d

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/tools/pgindent/pgindent

+18-3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ $code_base ||= '.' unless @ARGV;
5050
$excludes ||= "$code_base/src/tools/pgindent/exclude_file_patterns"
5151
if $code_base && -f "$code_base/src/tools/pgindent/exclude_file_patterns";
5252

53+
# The typedef list that's mechanically extracted by the buildfarm may omit
54+
# some names we want to treat like typedefs, e.g. "bool" (which is a macro
55+
# according to <stdbool.h>), and may include some names we don't want
56+
# treated as typedefs, although various headers that some builds include
57+
# might make them so. For the moment we just hardwire a whitelist of names
58+
# to add and a blacklist of names to remove; eventually this may need to be
59+
# easier to configure. Note that the typedefs need trailing newlines.
60+
my @whitelist = ("bool\n");
61+
62+
my %blacklist = map { +"$_\n" => 1 }
63+
qw( FD_SET date interval timestamp ANY
64+
abs allocfunc iterator other pointer printfunc reference string type );
65+
5366
# globals
5467
my @files;
5568
my $filtered_typedefs_fh;
@@ -118,9 +131,11 @@ sub load_typedefs
118131
}
119132
}
120133

121-
# remove certain entries
122-
@typedefs =
123-
grep { !m/^(FD_SET|date|interval|timestamp|ANY)\n?$/ } @typedefs;
134+
# add whitelisted entries
135+
push(@typedefs, @whitelist);
136+
137+
# remove blacklisted entries
138+
@typedefs = grep { ! $blacklist{$_} } @typedefs;
124139

125140
# write filtered typedefs
126141
my $filter_typedefs_fh = new File::Temp(TEMPLATE => "pgtypedefXXXXX");

0 commit comments

Comments
 (0)