checkOptionDocs.pl.in 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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, "@abs_top_builddir@/src/app/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("@abs_top_srcdir@/src/config/torrc.sample.in", \%torrcSampleOptions);
  34. # Try to figure out what's in the man page.
  35. my $considerNextLine = 0;
  36. open(F, "@abs_top_srcdir@/doc/man/tor.1.txt") or die;
  37. while (<F>) {
  38. if (m!^(?:\[\[([A-za-z0-9_]+)\]\] *)?\*\*([A-Za-z0-9_]+)\*\*! && $considerNextLine) {
  39. $manPageOptions{$2} = 1;
  40. print "Missing an anchor: $2\n" unless (defined $1 or $2 eq 'tor');
  41. $considerNextLine = 1;
  42. } elsif (m!^\s*$! or
  43. m!^\s*\+\s*$! or
  44. m!^\s*//!) {
  45. $considerNextLine = 1;
  46. } else {
  47. $considerNextLine = 0;
  48. }
  49. }
  50. close F;
  51. # Now, display differences:
  52. sub subtractHashes {
  53. my ($s, $a, $b) = @_;
  54. my @lst = ();
  55. for my $k (keys %$a) {
  56. push @lst, $k unless (exists $b->{$k});
  57. }
  58. print "$s: ", join(' ', sort @lst), "\n\n";
  59. 0;
  60. }
  61. # subtractHashes("No online docs", \%options, \%descOptions);
  62. # subtractHashes("Orphaned online docs", \%descOptions, \%options);
  63. subtractHashes("Orphaned in torrc.sample.in", \%torrcSampleOptions, \%options);
  64. subtractHashes("Not in man page", \%options, \%manPageOptions);
  65. subtractHashes("Orphaned in man page", \%manPageOptions, \%options);