github的一些开源项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.7 KiB

  1. #! /usr/bin/perl
  2. # A script to scan PCRE2'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. $count = 0;
  15. $line++;
  16. if (/^\s*$/)
  17. {
  18. printf "Empty line $line of $file\n";
  19. $yield = 1;
  20. }
  21. elsif (/^\./)
  22. {
  23. if (!/^\.\s*$|
  24. ^\.B\s+\S|
  25. ^\.TH\s\S|
  26. ^\.SH\s\S|
  27. ^\.SS\s\S|
  28. ^\.TP(?:\s?\d+)?\s*$|
  29. ^\.SM\s*$|
  30. ^\.br\s*$|
  31. ^\.rs\s*$|
  32. ^\.sp\s*$|
  33. ^\.nf\s*$|
  34. ^\.fi\s*$|
  35. ^\.P\s*$|
  36. ^\.PP\s*$|
  37. ^\.\\"(?:\ HREF)?\s*$|
  38. ^\.\\"\sHTML\s<a\shref="[^"]+?">\s*$|
  39. ^\.\\"\sHTML\s<a\sname="[^"]+?"><\/a>\s*$|
  40. ^\.\\"\s<\/a>\s*$|
  41. ^\.\\"\sJOINSH\s*$|
  42. ^\.\\"\sJOIN\s*$/x
  43. )
  44. {
  45. printf "Bad control line $line of $file\n";
  46. $yield = 1;
  47. }
  48. }
  49. elsif (/\\[^ef]|\\f[^IBP]/)
  50. {
  51. printf "Bad backslash in line $line of $file\n";
  52. $yield = 1;
  53. }
  54. while (/\\f[BI]/g)
  55. {
  56. $count++;
  57. }
  58. while (/\\fP/g)
  59. {
  60. $count--;
  61. }
  62. if ($count != 0)
  63. {
  64. printf "Mismatching formatting in line $line of $file\n";
  65. $yield = 1;
  66. }
  67. }
  68. close(IN);
  69. }
  70. exit $yield;
  71. # End