mirror of
https://github.com/curl/curl.git
synced 2025-01-30 14:22:33 +08:00
gen.pl: make the "manpageification" faster
The function that replaces occurances of "--longoption" with "-Z, --longoption" etc with the proper highlight applied, no longer loops over the options. Closes #13041
This commit is contained in:
parent
6f685f04fd
commit
eb9166dc66
@ -17,7 +17,7 @@ options *-O*, *-L* and *-v* at once as *-OLv*.
|
||||
In general, all boolean options are enabled with --**option** and yet again
|
||||
disabled with --**no-**option. That is, you use the same option name but
|
||||
prefix it with `no-`. However, in this list we mostly only list and show the
|
||||
*--option* version of them.
|
||||
--**option** version of them.
|
||||
|
||||
When --next is used, it resets the parser state and you start again with a
|
||||
clean option state, except for the options that are global. Global options
|
||||
|
@ -72,16 +72,23 @@ close(INC);
|
||||
sub manpageify {
|
||||
my ($k)=@_;
|
||||
my $l;
|
||||
my $trail;
|
||||
# the matching pattern might include a trailing dot that cannot be part of
|
||||
# the option name
|
||||
if($k =~ s/\.$//) {
|
||||
# cut off trailing dot
|
||||
$trail = ".";
|
||||
}
|
||||
my $klong = $k;
|
||||
# quote "bare" minuses in the long name
|
||||
$klong =~ s/-/\\-/g;
|
||||
if($optlong{$k} ne "") {
|
||||
if($optlong{$k}) {
|
||||
# both short + long
|
||||
$l = "\\fI-".$optlong{$k}.", \\-\\-$klong\\fP";
|
||||
$l = "\\fI-".$optlong{$k}.", \\-\\-$klong\\fP$trail";
|
||||
}
|
||||
else {
|
||||
# only long
|
||||
$l = "\\fI\\-\\-$klong\\fP";
|
||||
$l = "\\fI\\-\\-$klong\\fP$trail";
|
||||
}
|
||||
return $l;
|
||||
}
|
||||
@ -289,16 +296,7 @@ sub render {
|
||||
$d =~ s/\\/\\\\/g;
|
||||
|
||||
if(!$quote && $d =~ /--/) {
|
||||
# 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/--$k([^a-z0-9-])/$l$1/g;
|
||||
}
|
||||
$d =~ s/--([a-z0-9.-]+)/manpageify($1)/ge;
|
||||
}
|
||||
|
||||
# quote minuses in the output
|
||||
|
Loading…
Reference in New Issue
Block a user