Do not report a node as a "chosen exit" when it is not in fact an exit.
[tor/rransom.git] / contrib / checkOptionDocs.pl
blobca3fba55e3b676f670790c962b3ebff83c0c8610
1 #!/usr/bin/perl -w
2 # $Id
3 use strict;
5 my %options = ();
6 my %descOptions = ();
7 my %torrcSampleOptions = ();
8 my %torrcCompleteOptions = ();
9 my %manPageOptions = ();
11 # Load the canonical list as actually accepted by Tor.
12 my $mostRecentOption;
13 open(F, "./src/or/tor --list-torrc-options |") or die;
14 while (<F>) {
15 next if m!\[notice\] Tor v0\.!;
16 if (m!^([A-Za-z0-9_]+)!) {
17 $mostRecentOption = lc $1;
18 $options{$mostRecentOption} = 1;
19 } elsif (m!^ !) {
20 $descOptions{$mostRecentOption} = 1;
21 if (m!\{DEPRECATED\}!) {
22 delete $descOptions{$mostRecentOption};
23 delete $options{$mostRecentOption};
25 } else {
26 print "Unrecognized output> ";
27 print;
30 close F;
32 # Load the contents of torrc.sample and torrc.complete
33 sub loadTorrc {
34 my ($fname, $options) = @_;
35 local *F;
36 open(F, "$fname") or die;
37 while (<F>) {
38 next if (m!##+!);
39 if (m!#([A-Za-z0-9_]+)!) {
40 $options->{lc $1} = 1;
43 close F;
47 loadTorrc("./src/config/torrc.sample.in", \%torrcSampleOptions);
48 loadTorrc("./src/config/torrc.complete.in", \%torrcCompleteOptions);
50 # Try to figure out what's in the man page.
52 my $considerNextLine = 0;
53 open(F, "./doc/tor.1.in") or die;
54 while (<F>) {
55 if ($considerNextLine and
56 m!^\\fB([A-Za-z0-9_]+)!) {
57 $manPageOptions{lc $1} = 1;
58 next;
61 if (m!^\.(?:SH|TP|PP)!) {
62 $considerNextLine = 1; next;
63 } else {
64 $considerNextLine = 0;
67 close F;
69 # Now, display differences:
71 sub subtractHashes {
72 my ($s, $a, $b) = @_;
73 my @lst = ();
74 for my $k (keys %$a) {
75 push @lst, $k unless (exists $b->{$k});
77 print "$s: ", join(' ', sort @lst), "\n\n";
81 subtractHashes("No online docs", \%options, \%descOptions);
82 # subtractHashes("Orphaned online docs", \%descOptions, \%options);
84 subtractHashes("Not in torrc.complete.in", \%options, \%torrcCompleteOptions);
85 subtractHashes("Orphaned in torrc.complete.in", \%torrcCompleteOptions, \%options);
86 subtractHashes("Orphaned in torrc.sample.in", \%torrcSampleOptions, \%options);
88 subtractHashes("Not in man page", \%options, \%manPageOptions);
89 subtractHashes("Orphaned in man page", \%manPageOptions, \%options);