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