Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcea258b

Browse files
committed
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 toconfuse pgindent. (Which probably indicates a bug in BSD indent, butI can't get excited about trying to fix it.)For the same reasons, add src/backend/utils/fmgrtab.c to the set offiles excluded by src/tools/pgindent/exclude_file_patterns.The point of doing this is that it makes it safe to run pgindent overthe tree without doing "make maintainer-clean" first. While these arenot the only derived .c/.h files in the tree, they are the only onespgindent fails on. Removing that prerequisite step results in one lessway to mess up a pgindent run, and it's necessary if we ever hope to getto the ease of running pgindent via "make indent".
1 parent57fb1d6 commitcea258b

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

‎src/tools/pgindent/README

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,21 @@ DOING THE INDENT RUN:
2222

2323
1) Change directory to the top of the source tree.
2424

25-
2) Remove all derived files (pgindent has trouble with flex files, and it
26-
would be pointless to run it on them anyway):
27-
28-
make maintainer-clean
29-
Or:
30-
git clean -fdx
31-
32-
3) Download the latest typedef file from the buildfarm:
25+
2) Download the latest typedef file from the buildfarm:
3326

3427
wget -O src/tools/pgindent/typedefs.list https://buildfarm.postgresql.org/cgi-bin/typedefs.pl
3528

3629
(See https://www.pgbuildfarm.org/cgi-bin/typedefs.pl?show_list for a full
3730
list of typedef files, if you want to indent some back branch.)
3831

39-
4) Run pgindent on the C files:
32+
3) Run pgindent on the C files:
4033

4134
src/tools/pgindent/pgindent
4235

4336
If any files generate errors, restore their original versions with
4437
"git checkout", and see below for cleanup ideas.
4538

46-
5) Indent the Perl code using perltidy:
39+
4) Indent the Perl code using perltidy:
4740

4841
src/tools/pgindent/pgperltidy
4942

@@ -53,11 +46,12 @@ DOING THE INDENT RUN:
5346
VALIDATION:
5447

5548
1) Check for any newly-created files using "git status"; there shouldn't
56-
be any. (perltidy tends to leave *.LOG files behind if it has trouble.)
49+
be any. (pgindent leaves *.BAK files behind if it has trouble, while
50+
perltidy leaves *.LOG files behind.)
5751

5852
2) Do a full test build:
5953

60-
./configure ...
54+
make -s clean
6155
make -s all# look for unexpected warnings, and errors of course
6256
make check-world
6357

@@ -127,21 +121,26 @@ Which files are processed
127121
-------------------------
128122

129123
The pgindent run processes (nearly) all PostgreSQL *.c and *.h files,
130-
but we currently exclude *.y and *.l files. Exceptions are listed
124+
but we currently exclude *.y and *.l files, as well as *.c and *.h files
125+
derived from *.y and *.l files. Additional exceptions are listed
131126
in exclude_file_patterns:
132127

133128
src/include/storage/s_lock.h and src/include/port/atomics/ are excluded
134129
because they contain assembly code that pgindent tends to mess up.
135130

131+
src/backend/utils/fmgrtab.c is excluded because it confuses pgindent
132+
and it's a derived file anyway.
133+
136134
src/interfaces/ecpg/test/expected/ is excluded to avoid breaking the ecpg
137135
regression tests. Several *.h files are included in regression output so
138-
should not be changed.
136+
they must not be changed.
139137

140138
src/include/snowball/libstemmer/ and src/backend/snowball/libstemmer/
141139
are excluded because those files are imported from an external project,
142140
not maintained locally, and are machine-generated anyway. Likewise for
143141
plperl/ppport.h.
144142

143+
145144
The perltidy run processes all *.pl and *.pm files, plus a few
146145
executable Perl scripts that are not named that way. See the "find"
147146
rules in pgperltidy for details.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#list of file patterns to exclude from pgindent runs, see notes in README
2-
/s_lock\.h$
3-
/atomics/
2+
/storage/s_lock\.h$
3+
/port/atomics/
4+
/utils/fmgrtab\.c$
45
/ecpg/test/expected/
56
/snowball/libstemmer/
67
/pl/plperl/ppport\.h$

‎src/tools/pgindent/pgindent

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,15 @@ push(@files, @ARGV);
534534

535535
foreachmy$source_filename (@files)
536536
{
537+
# Automatically ignore .c and .h files that correspond to a .y or .l
538+
# file. indent tends to get badly confused by Bison/flex output,
539+
# and there's no value in indenting derived files anyway.
540+
my$otherfile =$source_filename;
541+
$otherfile =~s/\.[ch]$/.y/;
542+
nextif$otherfilene$source_filename &&-f$otherfile;
543+
$otherfile =~s/\.y$/.l/;
544+
nextif$otherfilene$source_filename &&-f$otherfile;
545+
537546
my$source = read_source($source_filename);
538547
my$error_message ='';
539548

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp