Call check_keywords.pl in maintainer-check
authorPeter Eisentraut
Mon, 27 Feb 2012 11:53:12 +0000 (13:53 +0200)
committerPeter Eisentraut
Mon, 27 Feb 2012 11:53:12 +0000 (13:53 +0200)
For that purpose, have check_keywords.pl print errors to stderr and
return a useful exit status.

src/backend/common.mk
src/backend/parser/Makefile
src/tools/check_keywords.pl

index 5d599dbd0ca2519436702a934e2fb666aa53aaf3..2e56151e2b48faa7a279cb9dbd8c10f59ed91126 100644 (file)
@@ -45,4 +45,4 @@ clean: clean-local
 clean-local:
    rm -f $(subsysfilename) $(OBJS)
 
-$(call recurse,coverage)
+$(call recurse,coverage maintainer-check)
index 0bdb3249a2e963aee87cdc4821a693225ff8b459..00e8e88e9c2e6b2c66bd445a0a8c33690d60f527 100644 (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)
index 178775484001d1b213047116e8ae628f4a1be698..33816c51332d694dd3ba866cca53c38549651578 100755 (executable)
@@ -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 () {
 
    # 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;