Call check_keywords.pl in maintainer-check

For that purpose, have check_keywords.pl print errors to stderr and
return a useful exit status.
This commit is contained in:
Peter Eisentraut 2012-02-27 13:53:12 +02:00
parent 1b630751d0
commit 9bf8603c7a
3 changed files with 22 additions and 9 deletions

View File

@ -45,4 +45,4 @@ clean: clean-local
clean-local:
rm -f $(subsysfilename) $(OBJS)
$(call recurse,coverage)
$(call recurse,coverage maintainer-check)

View File

@ -65,3 +65,7 @@ gram.o keywords.o parser.o: gram.h
# are not cleaned here.
clean distclean maintainer-clean:
rm -f lex.backup
maintainer-check:
$(PERL) $(top_srcdir)/src/tools/check_keywords.pl $(top_srcdir)

View File

@ -7,8 +7,14 @@ use strict;
#
# src/tools/check_keywords.pl
my $errors = 0;
my $path;
sub error(@) {
print STDERR @_;
$errors = 1;
}
if (@ARGV) {
$path = $ARGV[0];
shift @ARGV;
@ -102,7 +108,8 @@ foreach $kcat (keys %keyword_categories) {
$bare_kword = $kword;
$bare_kword =~ s/_P$//;
if ($bare_kword le $prevkword) {
print "'$bare_kword' after '$prevkword' in $kcat list is misplaced";
error "'$bare_kword' after '$prevkword' in $kcat list is misplaced";
$errors = 1;
}
$prevkword = $bare_kword;
}
@ -141,35 +148,35 @@ kwlist_line: while (<KWLIST>) {
# Check that the list is in alphabetical order
if ($kwstring le $prevkwstring) {
print "'$kwstring' after '$prevkwstring' in kwlist.h is misplaced";
error "'$kwstring' after '$prevkwstring' in kwlist.h is misplaced";
}
$prevkwstring = $kwstring;
# Check that the keyword string is valid: all lower-case ASCII chars
if ($kwstring !~ /^[a-z_]*$/) {
print "'$kwstring' is not a valid keyword string, must be all lower-case ASCII chars";
error "'$kwstring' is not a valid keyword string, must be all lower-case ASCII chars";
}
# Check that the keyword name is valid: all upper-case ASCII chars
if ($kwname !~ /^[A-Z_]*$/) {
print "'$kwname' is not a valid keyword name, must be all upper-case ASCII chars";
error "'$kwname' is not a valid keyword name, must be all upper-case ASCII chars";
}
# Check that the keyword string matches keyword name
$bare_kwname = $kwname;
$bare_kwname =~ s/_P$//;
if ($bare_kwname ne uc($kwstring)) {
print "keyword name '$kwname' doesn't match keyword string '$kwstring'";
error "keyword name '$kwname' doesn't match keyword string '$kwstring'";
}
# Check that the keyword is present in the grammar
%kwhash = %{$kwhashes{$kwcat_id}};
if (!(%kwhash)) {
#print "Unknown kwcat_id: $kwcat_id";
#error "Unknown kwcat_id: $kwcat_id";
} else {
if (!($kwhash{$kwname})) {
print "'$kwname' not present in $kwcat_id section of gram.y";
error "'$kwname' not present in $kwcat_id section of gram.y";
} else {
# Remove it from the hash, so that we can complain at the end
# if there's keywords left that were not found in kwlist.h
@ -185,6 +192,8 @@ while ( my ($kwcat, $kwcat_id) = each(%keyword_categories) ) {
%kwhash = %{$kwhashes{$kwcat_id}};
for my $kw ( keys %kwhash ) {
print "'$kw' found in gram.y $kwcat category, but not in kwlist.h"
error "'$kw' found in gram.y $kwcat category, but not in kwlist.h"
}
}
exit $errors;