pcre2/CheckMan

79 lines
1.7 KiB
Plaintext
Raw Normal View History

2014-09-23 13:35:51 +02:00
#! /usr/bin/perl
# A script to scan PCRE2's man pages to check for typos in the control
# sequences. I use only a small set of the available repertoire, so it is
# straightforward to check that nothing else has slipped in by mistake. This
# script should be called in the doc directory.
$yield = 0;
while (scalar(@ARGV) > 0)
{
$line = 0;
$file = shift @ARGV;
open (IN, $file) || die "Failed to open $file\n";
while (<IN>)
{
$count = 0;
2014-09-23 13:35:51 +02:00
$line++;
if (/^\s*$/)
{
printf "Empty line $line of $file\n";
$yield = 1;
}
elsif (/^\./)
{
if (!/^\.\s*$|
^\.B\s+\S|
^\.TH\s\S|
^\.SH\s\S|
^\.SS\s\S|
^\.TP(?:\s?\d+)?\s*$|
^\.SM\s*$|
^\.br\s*$|
^\.rs\s*$|
^\.sp\s*$|
^\.nf\s*$|
^\.fi\s*$|
^\.P\s*$|
^\.PP\s*$|
^\.\\"(?:\ HREF)?\s*$|
^\.\\"\sHTML\s<a\shref="[^"]+?">\s*$|
^\.\\"\sHTML\s<a\sname="[^"]+?"><\/a>\s*$|
^\.\\"\s<\/a>\s*$|
^\.\\"\sJOINSH\s*$|
^\.\\"\sJOIN\s*$/x
)
{
printf "Bad control line $line of $file\n";
$yield = 1;
}
}
elsif (/\\[^ef]|\\f[^IBP]/)
2014-09-23 13:35:51 +02:00
{
printf "Bad backslash in line $line of $file\n";
$yield = 1;
}
while (/\\f[BI]/g)
{
$count++;
}
while (/\\fP/g)
{
$count--;
}
if ($count != 0)
{
printf "Mismatching formatting in line $line of $file\n";
$yield = 1;
}
2014-09-23 13:35:51 +02:00
}
close(IN);
}
exit $yield;
# End