checkOptionDocs.pl.in 1.7 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, "@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/tor.1.txt") or die;
  37. while (<F>) {
  38. if (m!^(?:\[\[([A-za-z0-9_]+)\]\] *)?\*\*([A-Za-z0-9_]+)\*\*!) {
  39. $manPageOptions{$2} = 1;
  40. print "Missing an anchor: $2\n" unless (defined $1 or $2 eq 'tor');
  41. }
  42. }
  43. close F;
  44. # Now, display differences:
  45. sub subtractHashes {
  46. my ($s, $a, $b) = @_;
  47. my @lst = ();
  48. for my $k (keys %$a) {
  49. push @lst, $k unless (exists $b->{$k});
  50. }
  51. print "$s: ", join(' ', sort @lst), "\n\n";
  52. 0;
  53. }
  54. # subtractHashes("No online docs", \%options, \%descOptions);
  55. # subtractHashes("Orphaned online docs", \%descOptions, \%options);
  56. subtractHashes("Orphaned in torrc.sample.in", \%torrcSampleOptions, \%options);
  57. subtractHashes("Not in man page", \%options, \%manPageOptions);
  58. subtractHashes("Orphaned in man page", \%manPageOptions, \%options);