mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Minor improvements for paramcheck.pl.
This commit is contained in:
parent
d6065c927e
commit
6871383fe6
@ -25,10 +25,11 @@ use File::Spec ();
|
|||||||
|
|
||||||
my $main_c_file = File::Spec->catfile($Bin, File::Spec->updir, 'src', 'main.c');
|
my $main_c_file = File::Spec->catfile($Bin, File::Spec->updir, 'src', 'main.c');
|
||||||
my $init_c_file = File::Spec->catfile($Bin, File::Spec->updir, 'src', 'init.c');
|
my $init_c_file = File::Spec->catfile($Bin, File::Spec->updir, 'src', 'init.c');
|
||||||
my $tex_file = File::Spec->catfile($Bin, File::Spec->updir, 'doc', 'wget.texi');
|
my $tex_file = File::Spec->catfile($Bin, File::Spec->updir, 'doc', 'wget.texi');
|
||||||
|
|
||||||
my $main_content = read_file($main_c_file);
|
my $main_content = read_file($main_c_file);
|
||||||
my $init_content = read_file($init_c_file);
|
my $init_content = read_file($init_c_file);
|
||||||
my $tex_content = read_file($tex_file);
|
my $tex_content = read_file($tex_file);
|
||||||
|
|
||||||
my @args = ([
|
my @args = ([
|
||||||
$main_content,
|
$main_content,
|
||||||
@ -244,20 +245,32 @@ EOT
|
|||||||
|
|
||||||
sub find_documentation
|
sub find_documentation
|
||||||
{
|
{
|
||||||
my ($push, $opt) = (shift, shift);
|
my ($options, $opt, $tex_items, $main_items) = @_;
|
||||||
my $info = [];
|
|
||||||
|
|
||||||
my $opt_name = $opt->{'long_name'};
|
my %found_in;
|
||||||
for my $doc (@_) {
|
my %items = (
|
||||||
next if $opt->{'deprecated'};
|
tex => $tex_items,
|
||||||
|
main => $main_items,
|
||||||
|
);
|
||||||
|
my $opt_name = $opt->{long_name};
|
||||||
|
|
||||||
|
foreach my $doc_type (qw(tex main)) {
|
||||||
|
my $doc = $items{$doc_type};
|
||||||
if ($doc->{$opt_name}
|
if ($doc->{$opt_name}
|
||||||
|| ($opt_name !~ /^no/ && $doc->{"no-$opt_name"})) {
|
|| ($opt_name !~ /^no/ && $doc->{"no-$opt_name"})) {
|
||||||
push @$info, 1;
|
$found_in{$doc_type} = true;
|
||||||
} else {
|
}
|
||||||
push @$info, 0;
|
else {
|
||||||
|
$found_in{$doc_type} = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (scalar grep { $_ == false } values %found_in) {
|
||||||
|
push @$options, {
|
||||||
|
name => $opt_name,
|
||||||
|
tex => $found_in{tex},
|
||||||
|
main => $found_in{main},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
push @$push, [$opt_name, @$info] if grep {$_ eq 0} @$info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub emit_undocumented_opts
|
sub emit_undocumented_opts
|
||||||
@ -265,29 +278,38 @@ sub emit_undocumented_opts
|
|||||||
my ($tex, $main, $opts) = @_;
|
my ($tex, $main, $opts) = @_;
|
||||||
|
|
||||||
my (%tex_items, %main_items);
|
my (%tex_items, %main_items);
|
||||||
while ($tex =~ /^\@item\w*? \s+? --([\w\-]+)/gmx) {
|
while ($tex =~ /^\@item\w*? \s+? --([-a-z0-9]+)/gmx) {
|
||||||
$tex_items{$1} = true;
|
$tex_items{$1} = true;
|
||||||
}
|
}
|
||||||
($main) = $main =~ /(\nprint_help.*\n}\n)/s;
|
my ($help) = $main =~ /\n print_help .*? \{\n (.*) \n\} \n/sx;
|
||||||
while ($main =~ /--([-a-z0-9]+)/g) {
|
while ($help =~ /--([-a-z0-9]+)/g) {
|
||||||
$main_items{$1} = true;
|
$main_items{$1} = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @options;
|
my @options;
|
||||||
foreach my $opt (@$opts) {
|
foreach my $opt (@$opts) {
|
||||||
find_documentation (\@options, $opt, \%tex_items, \%main_items);
|
next if $opt->{deprecated};
|
||||||
|
find_documentation(\@options, $opt, \%tex_items, \%main_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
local $" = "\n";
|
my ($opt, $not_found_in);
|
||||||
print <<EOT;
|
|
||||||
|
format STDOUT_TOP =
|
||||||
Undocumented options Not In:
|
Undocumented options Not In:
|
||||||
==================== ==================
|
==================== ==================
|
||||||
EOT
|
.
|
||||||
for my $opt (@options) {
|
|
||||||
printf("%-29s ", $opt->[0]);
|
format STDOUT =
|
||||||
print 'texinfo ' unless $opt->[1];
|
@<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<
|
||||||
print 'nor ' unless $opt->[1] or $opt->[2];
|
$opt->{name}, $not_found_in
|
||||||
print '--help ' unless $opt->[2];
|
.
|
||||||
print "\n";
|
foreach $opt (@options) {
|
||||||
|
$not_found_in = join ' ', (
|
||||||
|
! $opt->{tex} ? 'texinfo' : (),
|
||||||
|
!($opt->{tex} || $opt->{main}) ? 'nor' : (),
|
||||||
|
! $opt->{main} ? '--help' : (),
|
||||||
|
);
|
||||||
|
write;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +318,7 @@ sub emit_undocumented_cmds
|
|||||||
my ($tex, $opts, $cmds, $index) = @_;
|
my ($tex, $opts, $cmds, $index) = @_;
|
||||||
|
|
||||||
my %items;
|
my %items;
|
||||||
while ($tex =~ /^\@item\w*? \s+? ([\w\_]+) \s+? = \s+? \S+?/gmx) {
|
while ($tex =~ /^\@item\w*? \s+? ([_a-z0-9]+) \s+? = \s+? \S+?/gmx) {
|
||||||
my $cmd = $1;
|
my $cmd = $1;
|
||||||
$cmd =~ tr/_//d;
|
$cmd =~ tr/_//d;
|
||||||
$items{$cmd} = true;
|
$items{$cmd} = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user