gen.pl: do not generate CURLHELP bitmask lines > 79 characters

If a command line option is in many help categories, there is a risk
that CURLHELP bitmask source lines generated for listhelp are longer
than 79 characters.

This change takes care of folding such long lines.

Cloes #9834
This commit is contained in:
Patrick Monnerat 2022-10-31 04:23:59 +01:00 committed by Daniel Stenberg
parent 65bdd6baec
commit 3b9af11c77
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -540,7 +540,7 @@ HEAD
my $long = $f; my $long = $f;
my $short = $optlong{$long}; my $short = $optlong{$long};
my @categories = split ' ', $catlong{$long}; my @categories = split ' ', $catlong{$long};
my $bitmask; my $bitmask = ' ';
my $opt; my $opt;
if(defined($short) && $long) { if(defined($short) && $long) {
@ -556,6 +556,7 @@ HEAD
$bitmask .= ' | '; $bitmask .= ' | ';
} }
} }
$bitmask =~ s/(?=.{76}).{1,76}\|/$&\n /g;
my $arg = $arglong{$long}; my $arg = $arglong{$long};
if($arg) { if($arg) {
$opt .= " $arg"; $opt .= " $arg";
@ -563,7 +564,7 @@ HEAD
my $desc = $helplong{$f}; my $desc = $helplong{$f};
$desc =~ s/\"/\\\"/g; # escape double quotes $desc =~ s/\"/\\\"/g; # escape double quotes
my $line = sprintf " {\"%s\",\n \"%s\",\n %s},\n", $opt, $desc, $bitmask; my $line = sprintf " {\"%s\",\n \"%s\",\n %s},\n", $opt, $desc, $bitmask;
if(length($opt) > 78) { if(length($opt) > 78) {
print STDERR "WARN: the --$long name is too long\n"; print STDERR "WARN: the --$long name is too long\n";