checkOptionDocs.pl 2.2 KB

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