Add a test for the supported_versions extension
[openssl.git] / util / find-doc-nits.pl
index 59647f9294156268db1969f44d9fa24ef28b37fc..9d73c99c66e079e1630f400ac3c81410423a888c 100755 (executable)
@@ -26,10 +26,6 @@ my %mandatory_sections =
       3      => [ 'SYNOPSIS', 'RETURN\s+VALUES' ],
       5      => [ ],
       7      => [ ] );
-my %default_sections =
-    ( apps   => 1,
-      crypto => 3,
-      ssl    => 3 );
 
 # Cross-check functions in the NAME and SYNOPSIS section.
 sub name_synopsis()
@@ -38,10 +34,6 @@ sub name_synopsis()
     my $filename = shift;
     my $contents = shift;
 
-    # If it's a generic page (all lowercase), or apps, skip it.
-    return if $filename =~ /[a-z]+\.pod/;
-    return if $filename =~ m@/apps/@;
-
     # Get NAME section and all words in it.
     return unless $contents =~ /=head1 NAME(.*)=head1 SYNOPSIS/ms;
     my $tmp = $1;
@@ -71,12 +63,26 @@ sub name_synopsis()
     return unless $contents =~ /=head1 SYNOPSIS(.*)=head1 DESCRIPTION/ms;
     my $syn = $1;
     foreach my $line ( split /\n+/, $syn ) {
-        next if $line =~ /typedef/;
-        next if $line =~ /STACK_OF/;
-        next unless $line =~ /([A-Za-z0-9_]+)\(/;
-        print "$id $1 missing from NAME section\n"
-            unless defined $names{$1};
-        $names{$1} = 2;
+        my $sym;
+        $line =~ s/STACK_OF\([^)]+\)/int/g;
+        $line =~ s/__declspec\([^)]+\)//;
+        if ( $line =~ /typedef.* (\S+);/ ) {
+            $sym = $1;
+        } elsif ( $line =~ /#define ([A-Za-z0-9_]+)/ ) {
+            $sym = $1;
+        } elsif ( $line =~ /([A-Za-z0-9_]+)\(/ ) {
+            $sym = $1;
+        }
+        else {
+            next;
+        }
+        print "$id $sym missing from NAME section\n"
+            unless defined $names{$sym};
+        $names{$sym} = 2;
+
+        # Do some sanity checks on the prototype.
+        print "$id prototype missing spaces around commas: $line\n"
+            if ( $line =~ /[a-z0-9],[^ ]/ );
     }
 
     foreach my $n ( keys %names ) {
@@ -100,7 +106,9 @@ sub check()
 
     my $id = "${filename}:1:";
 
-    &name_synopsis($id, $filename, $contents);
+    &name_synopsis($id, $filename, $contents)
+        unless $contents =~ /=for comment generic/
+            or $filename =~ m@man[157]/@;
 
     print "$id doesn't start with =pod\n"
         if $contents !~ /^=pod/;
@@ -143,10 +151,8 @@ sub check()
 
     # Find what section this page is in.  If run from "." assume
     # section 3.
-    my $section = $default_sections{$dirname} || 3;
-    if ($contents =~ /^=for\s+comment\s+openssl_manual_section:\s*(\d+)\s*$/m) {
-        $section = $1;
-    }
+    my $section = 3;
+    $section = $1 if $dirname =~ /man([1-9])/;
 
     foreach ((@{$mandatory_sections{'*'}}, @{$mandatory_sections{$section}})) {
         print "$id doesn't have a head1 section matching $_\n"