Teach pgindent to skip files generated by bison or flex automatically.
If a .c or .h file corresponds to a .y or .l file, skip indenting it. There's no point in reindenting derived files, and these files tend to confuse pgindent. (Which probably indicates a bug in BSD indent, but I can't get excited about trying to fix it.) For the same reasons, add src/backend/utils/fmgrtab.c to the set of files excluded by src/tools/pgindent/exclude_file_patterns. The point of doing this is that it makes it safe to run pgindent over the tree without doing "make maintainer-clean" first. While these are not the only derived .c/.h files in the tree, they are the only ones pgindent fails on. Removing that prerequisite step results in one less way to mess up a pgindent run, and it's necessary if we ever hope to get to the ease of running pgindent via "make indent".
This commit is contained in:
parent
57fb1d677d
commit
cea258b63d
|
@ -22,28 +22,21 @@ DOING THE INDENT RUN:
|
|||
|
||||
1) Change directory to the top of the source tree.
|
||||
|
||||
2) Remove all derived files (pgindent has trouble with flex files, and it
|
||||
would be pointless to run it on them anyway):
|
||||
|
||||
make maintainer-clean
|
||||
Or:
|
||||
git clean -fdx
|
||||
|
||||
3) Download the latest typedef file from the buildfarm:
|
||||
2) Download the latest typedef file from the buildfarm:
|
||||
|
||||
wget -O src/tools/pgindent/typedefs.list https://buildfarm.postgresql.org/cgi-bin/typedefs.pl
|
||||
|
||||
(See https://www.pgbuildfarm.org/cgi-bin/typedefs.pl?show_list for a full
|
||||
list of typedef files, if you want to indent some back branch.)
|
||||
|
||||
4) Run pgindent on the C files:
|
||||
3) Run pgindent on the C files:
|
||||
|
||||
src/tools/pgindent/pgindent
|
||||
|
||||
If any files generate errors, restore their original versions with
|
||||
"git checkout", and see below for cleanup ideas.
|
||||
|
||||
5) Indent the Perl code using perltidy:
|
||||
4) Indent the Perl code using perltidy:
|
||||
|
||||
src/tools/pgindent/pgperltidy
|
||||
|
||||
|
@ -53,11 +46,12 @@ DOING THE INDENT RUN:
|
|||
VALIDATION:
|
||||
|
||||
1) Check for any newly-created files using "git status"; there shouldn't
|
||||
be any. (perltidy tends to leave *.LOG files behind if it has trouble.)
|
||||
be any. (pgindent leaves *.BAK files behind if it has trouble, while
|
||||
perltidy leaves *.LOG files behind.)
|
||||
|
||||
2) Do a full test build:
|
||||
|
||||
./configure ...
|
||||
make -s clean
|
||||
make -s all # look for unexpected warnings, and errors of course
|
||||
make check-world
|
||||
|
||||
|
@ -127,21 +121,26 @@ Which files are processed
|
|||
-------------------------
|
||||
|
||||
The pgindent run processes (nearly) all PostgreSQL *.c and *.h files,
|
||||
but we currently exclude *.y and *.l files. Exceptions are listed
|
||||
but we currently exclude *.y and *.l files, as well as *.c and *.h files
|
||||
derived from *.y and *.l files. Additional exceptions are listed
|
||||
in exclude_file_patterns:
|
||||
|
||||
src/include/storage/s_lock.h and src/include/port/atomics/ are excluded
|
||||
because they contain assembly code that pgindent tends to mess up.
|
||||
|
||||
src/backend/utils/fmgrtab.c is excluded because it confuses pgindent
|
||||
and it's a derived file anyway.
|
||||
|
||||
src/interfaces/ecpg/test/expected/ is excluded to avoid breaking the ecpg
|
||||
regression tests. Several *.h files are included in regression output so
|
||||
should not be changed.
|
||||
they must not be changed.
|
||||
|
||||
src/include/snowball/libstemmer/ and src/backend/snowball/libstemmer/
|
||||
are excluded because those files are imported from an external project,
|
||||
not maintained locally, and are machine-generated anyway. Likewise for
|
||||
plperl/ppport.h.
|
||||
|
||||
|
||||
The perltidy run processes all *.pl and *.pm files, plus a few
|
||||
executable Perl scripts that are not named that way. See the "find"
|
||||
rules in pgperltidy for details.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#list of file patterns to exclude from pgindent runs, see notes in README
|
||||
/s_lock\.h$
|
||||
/atomics/
|
||||
/storage/s_lock\.h$
|
||||
/port/atomics/
|
||||
/utils/fmgrtab\.c$
|
||||
/ecpg/test/expected/
|
||||
/snowball/libstemmer/
|
||||
/pl/plperl/ppport\.h$
|
||||
|
|
|
@ -534,6 +534,15 @@ push(@files, @ARGV);
|
|||
|
||||
foreach my $source_filename (@files)
|
||||
{
|
||||
# Automatically ignore .c and .h files that correspond to a .y or .l
|
||||
# file. indent tends to get badly confused by Bison/flex output,
|
||||
# and there's no value in indenting derived files anyway.
|
||||
my $otherfile = $source_filename;
|
||||
$otherfile =~ s/\.[ch]$/.y/;
|
||||
next if $otherfile ne $source_filename && -f $otherfile;
|
||||
$otherfile =~ s/\.y$/.l/;
|
||||
next if $otherfile ne $source_filename && -f $otherfile;
|
||||
|
||||
my $source = read_source($source_filename);
|
||||
my $error_message = '';
|
||||
|
||||
|
|
Loading…
Reference in New Issue