CheckMan 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #! /usr/bin/perl
  2. # A script to scan PCRE's man pages to check for typos in the control
  3. # sequences. I use only a small set of the available repertoire, so it is
  4. # straightforward to check that nothing else has slipped in by mistake. This
  5. # script should be called in the doc directory.
  6. $yield = 0;
  7. while (scalar(@ARGV) > 0)
  8. {
  9. $line = 0;
  10. $file = shift @ARGV;
  11. open (IN, $file) || die "Failed to open $file\n";
  12. while (<IN>)
  13. {
  14. $line++;
  15. if (/^\s*$/)
  16. {
  17. printf "Empty line $line of $file\n";
  18. $yield = 1;
  19. }
  20. elsif (/^\./)
  21. {
  22. if (!/^\.\s*$|
  23. ^\.B\s+\S|
  24. ^\.TH\s\S|
  25. ^\.SH\s\S|
  26. ^\.SS\s\S|
  27. ^\.TP(?:\s?\d+)?\s*$|
  28. ^\.SM\s*$|
  29. ^\.br\s*$|
  30. ^\.rs\s*$|
  31. ^\.sp\s*$|
  32. ^\.nf\s*$|
  33. ^\.fi\s*$|
  34. ^\.P\s*$|
  35. ^\.PP\s*$|
  36. ^\.\\"(?:\ HREF)?\s*$|
  37. ^\.\\"\sHTML\s<a\shref="[^"]+?">\s*$|
  38. ^\.\\"\sHTML\s<a\sname="[^"]+?"><\/a>\s*$|
  39. ^\.\\"\s<\/a>\s*$|
  40. ^\.\\"\sJOINSH\s*$|
  41. ^\.\\"\sJOIN\s*$/x
  42. )
  43. {
  44. printf "Bad control line $line of $file\n";
  45. $yield = 1;
  46. }
  47. }
  48. else
  49. {
  50. if (/\\[^ef]|\\f[^IBP]/)
  51. {
  52. printf "Bad backslash in line $line of $file\n";
  53. $yield = 1;
  54. }
  55. }
  56. }
  57. close(IN);
  58. }
  59. exit $yield;
  60. # End