]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
test1173: check references to libcurl options
authorDaniel Stenberg <daniel@haxx.se>
Wed, 1 Sep 2021 10:57:06 +0000 (12:57 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 4 Sep 2021 09:27:56 +0000 (11:27 +0200)
... that they refer to actual existing libcurl options.

Reviewed-by: Daniel Gustafsson
Closes #7656

tests/data/test1173
tests/manpage-syntax.pl

index e23b0e8df3ab93cd235c68fd1a9eef7bcde8b309..f52afa6bbc5d951b5f9a028509532c32fb06cf67 100644 (file)
@@ -15,11 +15,11 @@ none
 </server>
 
  <name>
-Basic man page syntax check
+Man page syntax checks
  </name>
 
 <command type="perl">
-%SRCDIR/manpage-syntax.pl %SRCDIR/../docs/*.1  %SRCDIR/../docs/libcurl/*.3 %SRCDIR/../docs/libcurl/opts/*.3
+%SRCDIR/manpage-syntax.pl %SRCDIR/../docs/libcurl/symbols-in-versions %SRCDIR/../docs/*.1  %SRCDIR/../docs/libcurl/*.3 %SRCDIR/../docs/libcurl/opts/*.3
 </command>
 </client>
 
index 1609ba220f4b491d13669e8e9ddb5c5d86161b16..e8d183703f0175333954882038fd34c18e442d70 100644 (file)
@@ -28,6 +28,9 @@
 use strict;
 use warnings;
 
+# get the file name first
+my $symbolsinversions=shift @ARGV;
+
 # we may get the dir roots pointed out
 my @manpages=@ARGV;
 my $errors = 0;
@@ -46,6 +49,18 @@ my @order = (
     );
 my %shline; # section => line number
 
+my %symbol;
+sub allsymbols {
+    open(F, "<$symbolsinversions") ||
+        die "$symbolsinversions: $|";
+    while(<F>) {
+        if($_ =~ /^([^ ]*)/) {
+            $symbol{$1}=$1;
+        }
+    }
+    close(F);
+}
+
 sub scanmanpage {
     my ($file) = @_;
     my $reqex = 0;
@@ -54,24 +69,24 @@ sub scanmanpage {
     my $shc = 0;
     my @sh;
 
-    print "Check $file\n";
     open(M, "<$file") || die "no such file: $file";
-    if($file =~ /\/CURL[^\/]*.3/) {
+    if($file =~ /[\/\\]CURL[^\/\\]*.3/) {
         # This is the man page for an libcurl option. It requires an example!
         $reqex = 1;
     }
     my $line = 1;
     while(<M>) {
-        if($_ =~ /^.SH EXAMPLE/i) {
+        chomp;
+        if($_ =~ /^\.SH EXAMPLE/i) {
             $inex = 1;
         }
-        elsif($_ =~ /^.SH/i) {
+        elsif($_ =~ /^\.SH/i) {
             $inex = 0;
         }
         elsif($inex)  {
             $exsize++;
         }
-        if($_ =~ /^.SH (.*)/i) {
+        if($_ =~ /^\.SH ([^\r\n]*)/i) {
             my $n = $1;
             # remove enclosing quotes
             $n =~ s/\"(.*)\"\z/$1/;
@@ -94,6 +109,16 @@ sub scanmanpage {
             print STDERR "$file:$line trailing whitespace\n";
             $errors++;
         }
+        if($_ =~ /\\f([BI])([^\\]*)\\fP/) {
+            my $r = $2;
+            if($r =~ /^(CURL.*)\(3\)/) {
+                my $rr = $1;
+                if(!$symbol{$rr}) {
+                    print STDERR "$file:$line link to non-libcurl option $rr!\n";
+                    $errors++;
+                }
+            }
+        }
         $line++;
     }
     close(M);
@@ -101,45 +126,68 @@ sub scanmanpage {
     if($reqex) {
         # only for libcurl options man-pages
 
+        my $shcount = scalar(@sh); # before @sh gets shifted
         if($exsize < 2) {
             print STDERR "$file:$line missing EXAMPLE section\n";
             $errors++;
         }
 
-        my $got;
+        if($shcount < 3) {
+            print STDERR "$file:$line too few man page sections!\n";
+            $errors++;
+            return;
+        }
+
+        my $got = "start";
         my $i = 0;
         my $shused = 1;
-        do {
+        my @shorig = @sh;
+        while($got) {
+            my $finesh;
             $got = shift(@sh);
             if($got) {
-                $i = $blessed{$got};
+                if($blessed{$got}) {
+                    $i = $blessed{$got};
+                    $finesh = $got; # a mandatory one
+                }
             }
-            if($i && $got) {
+            if($i && defined($finesh)) {
                 # mandatory section
 
                 if($i != $shused) {
-                    printf STDERR "$file:%u Got $got, when %s was expected\n",
-                        $shline{$got},
+                    printf STDERR "$file:%u Got %s, when %s was expected\n",
+                        $shline{$finesh},
+                        $finesh,
                         $order[$shused-1];
                     $errors++;
                     return;
                 }
                 $shused++;
-                if($i == 9) {
+                if($i == scalar(@order)) {
                     # last mandatory one, exit
-                    $got="";
+                    last;
                 }
             }
-        } while($got);
+        }
 
-        if($i != 8) {
+        if($i != scalar(@order)) {
             printf STDERR "$file:$line missing mandatory section: %s\n",
                 $order[$i];
+            printf STDERR "$file:$line section found at index %u: '%s'\n",
+                $i, $shorig[$i];
+            printf STDERR " Found %u used sections\n", $shcount;
             $errors++;
         }
     }
 }
 
+allsymbols();
+
+if(!$symbol{'CURLALTSVC_H1'}) {
+    print STDERR "didn't get the symbols-in-version!\n";
+    exit;
+}
+
 my $ind = 1;
 for my $s (@order) {
     $blessed{$s} = $ind++