checkOptionDocs.pl 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/perl -w
  2. use strict;
  3. my %options = ();
  4. my %descOptions = ();
  5. my %torrcSampleOptions = ();
  6. my %torrcCompleteOptions = ();
  7. my %manPageOptions = ();
  8. # Load the canonical list as actually accepted by Tor.
  9. my $mostRecentOption;
  10. open(F, "./src/or/tor --list-torrc-options |") or die;
  11. while (<F>) {
  12. next if m!\[notice\] Tor v0\.!;
  13. if (m!^([A-Za-z0-9_]+)!) {
  14. $mostRecentOption = lc $1;
  15. $options{$mostRecentOption} = 1;
  16. } else {
  17. print "Unrecognized output> ";
  18. print;
  19. }
  20. }
  21. close F;
  22. # Load the contents of torrc.sample and torrc.complete
  23. sub loadTorrc {
  24. my ($fname, $options) = @_;
  25. local *F;
  26. open(F, "$fname") or die;
  27. while (<F>) {
  28. next if (m!##+!);
  29. if (m!#([A-Za-z0-9_]+)!) {
  30. $options->{lc $1} = 1;
  31. }
  32. }
  33. close F;
  34. 0;
  35. }
  36. loadTorrc("./src/config/torrc.sample.in", \%torrcSampleOptions);
  37. loadTorrc("./src/config/torrc.complete.in", \%torrcCompleteOptions);
  38. # Try to figure out what's in the man page.
  39. my $considerNextLine = 0;
  40. open(F, "./doc/tor.1.txt") or die;
  41. while (<F>) {
  42. if (m!^\*\*([A-Za-z0-9_]+)\*\*!) {
  43. $manPageOptions{lc $1} = 1;
  44. }
  45. }
  46. close F;
  47. # Now, display differences:
  48. sub subtractHashes {
  49. my ($s, $a, $b) = @_;
  50. my @lst = ();
  51. for my $k (keys %$a) {
  52. push @lst, $k unless (exists $b->{$k});
  53. }
  54. print "$s: ", join(' ', sort @lst), "\n\n";
  55. 0;
  56. }
  57. # subtractHashes("No online docs", \%options, \%descOptions);
  58. # subtractHashes("Orphaned online docs", \%descOptions, \%options);
  59. subtractHashes("Not in torrc.complete.in", \%options, \%torrcCompleteOptions);
  60. subtractHashes("Orphaned in torrc.complete.in", \%torrcCompleteOptions, \%options);
  61. subtractHashes("Orphaned in torrc.sample.in", \%torrcSampleOptions, \%options);
  62. subtractHashes("Not in man page", \%options, \%manPageOptions);
  63. subtractHashes("Orphaned in man page", \%manPageOptions, \%options);