checkOptionDocs.pl 1.5 KB

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