]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
manpage-syntax.pl: all libcurl option symbols should be \fI-tagged
authorDaniel Stenberg <daniel@haxx.se>
Thu, 22 Sep 2022 15:05:35 +0000 (17:05 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 22 Sep 2022 15:35:08 +0000 (17:35 +0200)
... as that makes them links to their corresponding man page.

This script is used for test 1173.

Closes #9574

tests/manpage-syntax.pl

index 49ab5b8e1865e9524ac9a3d029abca7d9b0571ee..bf69370ca4e6d6721b23bfd2a0b5018d3896d2a7 100644 (file)
@@ -62,12 +62,29 @@ my @funcorder = (
 my %shline; # section => line number
 
 my %symbol;
+
+# some CURLINFO_ symbols are not actual options for curl_easy_getinfo,
+# mark them as "deprecated" to hide them from link-warnings
+my %deprecated = (
+    CURLINFO_TEXT => 1,
+    CURLINFO_HEADER_IN => 1,
+    CURLINFO_HEADER_OUT => 1,
+    CURLINFO_DATA_IN => 1,
+    CURLINFO_DATA_OUT => 1,
+    CURLINFO_SSL_DATA_IN => 1,
+    CURLINFO_SSL_DATA_OUT => 1,
+    );
 sub allsymbols {
     open(F, "<$symbolsinversions") ||
         die "$symbolsinversions: $|";
     while(<F>) {
-        if($_ =~ /^([^ ]*)/) {
-            $symbol{$1}=$1;
+        if($_ =~ /^([^ ]*) +(.*)/) {
+            my ($name, $info) = ($1, $2);
+            $symbol{$name}=$name;
+
+            if($info =~ /([0-9.]+) +([0-9.]+)/) {
+                $deprecated{$name}=$info;
+            }
         }
     }
     close(F);
@@ -83,6 +100,7 @@ sub scanmanpage {
     my $shc = 0;
     my $optpage = 0; # option or function
     my @sh;
+    my $SH="";
 
     open(M, "<$file") || die "no such file: $file";
     if($file =~ /[\/\\](CURL|curl_)[^\/\\]*.3/) {
@@ -131,6 +149,7 @@ sub scanmanpage {
             $n =~ s/\"(.*)\"\z/$1/;
             push @sh, $n;
             $shline{$n} = $line;
+            $SH = $n;
         }
 
         if($_ =~ /^\'/) {
@@ -144,6 +163,19 @@ sub scanmanpage {
                 $errors++;
             }
         }
+        if($optpage && $SH && ($SH !~ /^(SYNOPSIS|EXAMPLE|NAME|SEE ALSO)/i) &&
+           ($_ =~ /(.*)(CURL(OPT_|MOPT_|INFO_)[A-Z0-9_]*)/)) {
+            # an option with its own man page, check that it is tagged
+            # for linking
+            my ($pref, $symbol) = ($1, $2);
+            if($deprecated{$symbol}) {
+                # let it be
+            }
+            elsif($pref !~ /\\fI\z/) {
+                print STDERR "$file:$line option $symbol missing \\fI tagging\n";
+                $errors++;
+            }
+        }
         if($_ =~ /[ \t]+$/) {
             print STDERR "$file:$line trailing whitespace\n";
             $errors++;