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

Commit 9bf8603

Browse files
committed
Call check_keywords.pl in maintainer-check
For that purpose, have check_keywords.pl print errors to stderr and return a useful exit status.
1 parent 1b63075 commit 9bf8603

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/backend/common.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ clean: clean-local
4545
clean-local:
4646
rm -f $(subsysfilename) $(OBJS)
4747

48-
$(call recurse,coverage)
48+
$(call recurse,coverage maintainer-check)

src/backend/parser/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,7 @@ gram.o keywords.o parser.o: gram.h
6565
# are not cleaned here.
6666
clean distclean maintainer-clean:
6767
rm -f lex.backup
68+
69+
70+
maintainer-check:
71+
$(PERL) $(top_srcdir)/src/tools/check_keywords.pl $(top_srcdir)

src/tools/check_keywords.pl

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77
#
88
# src/tools/check_keywords.pl
99

10+
my $errors = 0;
1011
my $path;
1112

13+
sub error(@) {
14+
print STDERR @_;
15+
$errors = 1;
16+
}
17+
1218
if (@ARGV) {
1319
$path = $ARGV[0];
1420
shift @ARGV;
@@ -102,7 +108,8 @@
102108
$bare_kword = $kword;
103109
$bare_kword =~ s/_P$//;
104110
if ($bare_kword le $prevkword) {
105-
print "'$bare_kword' after '$prevkword' in $kcat list is misplaced";
111+
error "'$bare_kword' after '$prevkword' in $kcat list is misplaced";
112+
$errors = 1;
106113
}
107114
$prevkword = $bare_kword;
108115
}
@@ -141,35 +148,35 @@
141148

142149
# Check that the list is in alphabetical order
143150
if ($kwstring le $prevkwstring) {
144-
print "'$kwstring' after '$prevkwstring' in kwlist.h is misplaced";
151+
error "'$kwstring' after '$prevkwstring' in kwlist.h is misplaced";
145152
}
146153
$prevkwstring = $kwstring;
147154

148155
# Check that the keyword string is valid: all lower-case ASCII chars
149156
if ($kwstring !~ /^[a-z_]*$/) {
150-
print "'$kwstring' is not a valid keyword string, must be all lower-case ASCII chars";
157+
error "'$kwstring' is not a valid keyword string, must be all lower-case ASCII chars";
151158
}
152159

153160
# Check that the keyword name is valid: all upper-case ASCII chars
154161
if ($kwname !~ /^[A-Z_]*$/) {
155-
print "'$kwname' is not a valid keyword name, must be all upper-case ASCII chars";
162+
error "'$kwname' is not a valid keyword name, must be all upper-case ASCII chars";
156163
}
157164

158165
# Check that the keyword string matches keyword name
159166
$bare_kwname = $kwname;
160167
$bare_kwname =~ s/_P$//;
161168
if ($bare_kwname ne uc($kwstring)) {
162-
print "keyword name '$kwname' doesn't match keyword string '$kwstring'";
169+
error "keyword name '$kwname' doesn't match keyword string '$kwstring'";
163170
}
164171

165172
# Check that the keyword is present in the grammar
166173
%kwhash = %{$kwhashes{$kwcat_id}};
167174

168175
if (!(%kwhash)) {
169-
#print "Unknown kwcat_id: $kwcat_id";
176+
#error "Unknown kwcat_id: $kwcat_id";
170177
} else {
171178
if (!($kwhash{$kwname})) {
172-
print "'$kwname' not present in $kwcat_id section of gram.y";
179+
error "'$kwname' not present in $kwcat_id section of gram.y";
173180
} else {
174181
# Remove it from the hash, so that we can complain at the end
175182
# if there's keywords left that were not found in kwlist.h
@@ -185,6 +192,8 @@
185192
%kwhash = %{$kwhashes{$kwcat_id}};
186193

187194
for my $kw ( keys %kwhash ) {
188-
print "'$kw' found in gram.y $kwcat category, but not in kwlist.h"
195+
error "'$kw' found in gram.y $kwcat category, but not in kwlist.h"
189196
}
190197
}
198+
199+
exit $errors;

0 commit comments

Comments
 (0)