check_texinfo.pl.in 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #! @PERL@
  2. #+##############################################################################
  3. #
  4. # check_texinfo.pl: Extract texinfo commands from files
  5. #
  6. # Copyright (C) 2002 Free Software Foundation, Inc.
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 3 of the License,
  11. # or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. # Code taken from the texi2html file in 2003.
  22. #
  23. #-##############################################################################
  24. # This requires perl version 5 or higher
  25. require 5.0;
  26. use strict;
  27. use Getopt::Long;
  28. my $verbose;
  29. if (!GetOptions ("verbose" => \$verbose))
  30. {
  31. die "usage: $0 [-v] file...\n";
  32. }
  33. die "Need file to check\n" unless @ARGV > 0;
  34. my (%seen, %context);
  35. while (<>)
  36. {
  37. if (/\@(\*|\.|\:|\@|\{|\})/)
  38. {
  39. $seen{$&}++;
  40. $context{$&} .= "> $_" if $verbose;
  41. $_ = "$`XX$'";
  42. redo;
  43. }
  44. if (/\@(\w+)/)
  45. {
  46. my ($before, $match, $after);
  47. ($before, $match, $after) = ($`, $&, $');
  48. if ($before =~ /\b[-\w]+$/ && $after =~ /^[-\w.]*\b/)
  49. { # e-mail address
  50. $seen{'e-mail address'}++;
  51. $context{'e-mail address'} .= "> $_" if $verbose;
  52. }
  53. else
  54. {
  55. $seen{$match}++;
  56. $context{$match} .= "> $_" if $verbose;
  57. }
  58. $match =~ s/^\@/X/;
  59. $_ = "$before$match$after";
  60. redo;
  61. }
  62. }
  63. foreach (sort(keys(%seen)))
  64. {
  65. if ($verbose)
  66. {
  67. print "$_\n";
  68. print $context{$_};
  69. }
  70. else
  71. {
  72. print "$_ ($seen{$_})\n";
  73. }
  74. }