Merge remote branch 'sebastian/remove-osx-expert-package' into maint-0.2.2
[tor/rransom.git] / contrib / checkOptionDocs.pl
blob26fb81d0493c3e820e7e023e6f652742118314fe
1 #!/usr/bin/perl -w
2 use strict;
4 my %options = ();
5 my %descOptions = ();
6 my %torrcSampleOptions = ();
7 my %torrcCompleteOptions = ();
8 my %manPageOptions = ();
10 # Load the canonical list as actually accepted by Tor.
11 my $mostRecentOption;
12 open(F, "./src/or/tor --list-torrc-options |") or die;
13 while (<F>) {
14 next if m!\[notice\] Tor v0\.!;
15 if (m!^([A-Za-z0-9_]+)!) {
16 $mostRecentOption = lc $1;
17 $options{$mostRecentOption} = 1;
18 } else {
19 print "Unrecognized output> ";
20 print;
23 close F;
25 # Load the contents of torrc.sample and torrc.complete
26 sub loadTorrc {
27 my ($fname, $options) = @_;
28 local *F;
29 open(F, "$fname") or die;
30 while (<F>) {
31 next if (m!##+!);
32 if (m!#([A-Za-z0-9_]+)!) {
33 $options->{lc $1} = 1;
36 close F;
40 loadTorrc("./src/config/torrc.sample.in", \%torrcSampleOptions);
41 loadTorrc("./src/config/torrc.complete.in", \%torrcCompleteOptions);
43 # Try to figure out what's in the man page.
45 my $considerNextLine = 0;
46 open(F, "./doc/tor.1.txt") or die;
47 while (<F>) {
48 if (m!^\*\*([A-Za-z0-9_]+)\*\*!) {
49 $manPageOptions{lc $1} = 1;
52 close F;
54 # Now, display differences:
56 sub subtractHashes {
57 my ($s, $a, $b) = @_;
58 my @lst = ();
59 for my $k (keys %$a) {
60 push @lst, $k unless (exists $b->{$k});
62 print "$s: ", join(' ', sort @lst), "\n\n";
66 # subtractHashes("No online docs", \%options, \%descOptions);
67 # subtractHashes("Orphaned online docs", \%descOptions, \%options);
69 subtractHashes("Not in torrc.complete.in", \%options, \%torrcCompleteOptions);
70 subtractHashes("Orphaned in torrc.complete.in", \%torrcCompleteOptions, \%options);
71 subtractHashes("Orphaned in torrc.sample.in", \%torrcSampleOptions, \%options);
73 subtractHashes("Not in man page", \%options, \%manPageOptions);
74 subtractHashes("Orphaned in man page", \%manPageOptions, \%options);