-#!/usr/bin/perl
+#!/usr/bin/env perl
-# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
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 $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 $init_content = read_file($init_c_file);
-my $tex_content = read_file($tex_file);
+my $tex_content = read_file($tex_file);
my @args = ([
$main_content,
- qr/static \s+? struct \s+? cmdline_option \s+? option_data\[\] \s+? = \s+? \{ (.*?) \}\;/sx,
+ qr/static \s+? struct \s+? cmdline_option \s+? option_data\[\] \s+? = \s+? \{ (.+?) \}\;/sx,
[ qw(long_name short_name type data argtype) ],
], [
$init_content,
- qr/commands\[\] \s+? = \s+? \{ (.*?) \}\;/sx,
+ qr/commands\[\] \s+? = \s+? \{ (.+?) \}\;/sx,
[ qw(name place action) ],
]);
my (@entries, %index, $i);
foreach my $chunk (@$chunks) {
- my ($args) = $chunk =~ /\{ \s+? (.*?) \s+? \}/sx;
+ my ($args) = $chunk =~ /\{ \s+? (.+?) \s+? \}/sx;
next unless defined $args;
my @args = map {
tr/'"//d; $_
} map {
- /\((.*?)\)/ ? $1 : $_
+ /\((.+?)\)/ ? $1 : $_
} split /\,\s+/, $args;
my $entry = { map { $_ => shift @args } @$names };
- ($entry->{line}) = $chunk =~ /^ \s+? (\{.*)/mx;
+ ($entry->{line}) = $chunk =~ /^ \s+? (\{.+)/mx;
if ($chunk =~ /deprecated/i) {
$entries[-1]->{deprecated} = true;
}
push @entries, $entry;
}
- push @entries, \%index;
+ push @entries, { %index };
- return \@entries;
+ return [ @entries ];
}
sub output_results
sub find_documentation
{
- my ($push, $opt) = (shift, shift);
- my $info = [];
+ my ($options, $opt, $tex_items, $main_items) = @_;
+
+ my %found_in;
+ my %items = (
+ tex => $tex_items,
+ main => $main_items,
+ );
+ my $opt_name = $opt->{long_name};
- my $opt_name = $opt->{'long_name'};
- for my $doc (@_) {
- next if $opt->{'deprecated'};
+ foreach my $doc_type (qw(tex main)) {
+ my $doc = $items{$doc_type};
if ($doc->{$opt_name}
|| ($opt_name !~ /^no/ && $doc->{"no-$opt_name"})) {
- push @$info, 1;
- } else {
- push @$info, 0;
+ $found_in{$doc_type} = true;
+ }
+ 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
my ($tex, $main, $opts) = @_;
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;
}
- ($main) = $main =~ /(\nprint_help.*\n}\n)/s;
- while ($main =~ /--([-a-z0-9]+)/g) {
+ my ($help) = $main =~ /\n print_help .*? \{\n (.+) \n\} \n/sx;
+ while ($help =~ /--([-a-z0-9]+)/g) {
$main_items{$1} = true;
}
+
my @options;
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";
- print <<EOT;
+ my ($opt, $not_found_in);
+
+format STDOUT_TOP =
Undocumented options Not In:
==================== ==================
-EOT
- for my $opt (@options) {
- printf("%-29s ", $opt->[0]);
- print 'texinfo ' unless $opt->[1];
- print 'nor ' unless $opt->[1] or $opt->[2];
- print '--help ' unless $opt->[2];
- print "\n";
+.
+
+format STDOUT =
+@<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<
+$opt->{name}, $not_found_in
+.
+ foreach $opt (@options) {
+ $not_found_in = join ' ', (
+ ! $opt->{tex} ? 'texinfo' : (),
+ !($opt->{tex} || $opt->{main}) ? 'nor' : (),
+ ! $opt->{main} ? '--help' : (),
+ );
+ write;
}
}
my ($tex, $opts, $cmds, $index) = @_;
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;
$cmd =~ tr/_//d;
$items{$cmd} = true;