mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user