From: Daniel Stenberg Date: Sun, 13 Nov 2022 22:58:47 +0000 (+0100) Subject: cmdline-opts/gen.pl: fix the linkifier X-Git-Tag: curl-7_87_0~161 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4154165e5e27ee5d9952d7d9c839a905ccc283ec;p=thirdparty%2Fcurl.git cmdline-opts/gen.pl: fix the linkifier 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 --- diff --git a/docs/cmdline-opts/gen.pl b/docs/cmdline-opts/gen.pl index d34e905139..55896ff752 100755 --- a/docs/cmdline-opts/gen.pl +++ b/docs/cmdline-opts/gen.pl @@ -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);