]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmdline-opts/gen.pl: fix the linkifier
authorDaniel Stenberg <daniel@haxx.se>
Sun, 13 Nov 2022 22:58:47 +0000 (23:58 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 14 Nov 2022 09:04:31 +0000 (10:04 +0100)
Improved logic for finding existing --options in text and replacing with
the full version with nroff syntax. This also makes the web version link
options better.

Reported-by: xianghongai on github
Fixes #9899
Closes #9902

docs/cmdline-opts/gen.pl

index d34e9051394aa030c40d34baab51e5899cece723..55896ff752ad1ec8a0142b0300ae5668a7fdcb70 100755 (executable)
@@ -104,9 +104,15 @@ sub printdesc {
         }
         # skip lines starting with space (examples)
         if($d =~ /^[^ ]/ && $d =~ /--/) {
-            for my $k (keys %optlong) {
+            # scan for options in longest-names first order
+            for my $k (sort {length($b) <=> length($a)} keys %optlong) {
+                # --tlsv1 is complicated since --tlsv1.2 etc are also
+                # acceptable options!
+                if(($k eq "tlsv1") && ($d =~ /--tlsv1\.[0-9]\\f/)) {
+                    next;
+                }
                 my $l = manpageify($k);
-                $d =~ s/--\Q$k\E([^a-z0-9_-])([^a-zA-Z0-9_])/$l$1$2/;
+                $d =~ s/\-\-$k([^a-z0-9-])/$l$1/g;
             }
         }
         # quote "bare" minuses in the output
@@ -345,12 +351,13 @@ sub single {
     printdesc(@desc);
     undef @desc;
 
+    my @extra;
     if($multi eq "single") {
-        print "\nIf --$long is provided several times, the last set ".
+        push @extra, "\nIf --$long is provided several times, the last set ".
             "value will be used.\n";
     }
     elsif($multi eq "append") {
-        print "\n--$long can be used several times in a command line\n";
+        push @extra, "\n--$long can be used several times in a command line\n";
     }
     elsif($multi eq "boolean") {
         my $rev = "no-$long";
@@ -360,13 +367,17 @@ sub single {
             $rev = $long;
             $rev =~ s/^no-//;
         }
-        print "\nProviding --$long multiple times has no extra effect.\n".
+        push @extra,
+            "\nProviding --$long multiple times has no extra effect.\n".
             "Disable it again with --$rev.\n";
     }
     elsif($multi eq "mutex") {
-        print "\nProviding --$long multiple times has no extra effect.\n";
+        push @extra,
+            "\nProviding --$long multiple times has no extra effect.\n";
     }
 
+    printdesc(@extra);
+
     my @foot;
     if($seealso) {
         my @m=split(/ /, $seealso);