checkOptionDocs.pl 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. } elsif (m!^ !) {
  17. $descOptions{$mostRecentOption} = 1;
  18. if (m!\{DEPRECATED\}!) {
  19. delete $descOptions{$mostRecentOption};
  20. delete $options{$mostRecentOption};
  21. }
  22. } else {
  23. print "Unrecognized output> ";
  24. print;
  25. }
  26. }
  27. close F;
  28. # Load the contents of torrc.sample and torrc.complete
  29. sub loadTorrc {
  30. my ($fname, $options) = @_;
  31. local *F;
  32. open(F, "$fname") or die;
  33. while (<F>) {
  34. next if (m!##+!);
  35. if (m!#([A-Za-z0-9_]+)!) {
  36. $options->{lc $1} = 1;
  37. }
  38. }
  39. close F;
  40. 0;
  41. }
  42. loadTorrc("./src/config/torrc.sample.in", \%torrcSampleOptions);
  43. loadTorrc("./src/config/torrc.complete.in", \%torrcCompleteOptions);
  44. # Try to figure out what's in the man page.
  45. my $considerNextLine = 0;
  46. open(F, "./doc/tor.1.in") or die;
  47. while (<F>) {
  48. if ($considerNextLine and
  49. m!^\\fB([A-Za-z0-9_]+)!) {
  50. $manPageOptions{lc $1} = 1;
  51. next;
  52. }
  53. if (m!^\.(?:SH|TP|PP)!) {
  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);