Expand documentation on use of dnslists in an IPv6 environment. Bug 1369
[exim.git] / doc / doc-scripts / faqchk
CommitLineData
495ae4b0 1#!/usr/bin/perl -w
495ae4b0
PH
2
3# Script to check the FAQ source and make sure I have all the numbers
4# in the right order without duplication. Also check the numbers of blank
5# lines. It gives up on any error (other than bad blank line counts).
6
7sub oops {
8print "\nLine $line: $_[0]\n";
9print;
10exit 1;
11}
12
13sub poops {
14print "\nLine $line: $_[0]\n";
15print;
16$precede_fail = 1;
17}
18
19
20$line = 0;
21$section = -1;
22$expect_answer = 0;
23$precede_fail = 0;
24
25while (<>)
26 {
27 $line++;
28 if (/^\s*$/)
29 {
30 $blankcount++;
31 next;
32 }
33 $preceded = $blankcount;
34 $blankcount = 0;
35
36 if (/^(\d+)\./)
37 {
38 &poops("$preceded empty lines precede (3 expected)") if $preceded != 3;
39 &oops(sprint("Answer %02d%02d is missing\n", $section, $question))
40 if $expect_answer;
41 $section = $1;
42 $question = ($section == 20)? 0 : 1;
43 $expected = 1;
44 if ($section == 99)
45 {
46 $c = 1;
47 $f = 1;
48 }
49 next;
50 }
51
52 if ($section != 99)
53 {
54 if (/^Q(\d\d)(\d\d):/)
55 {
56 &poops("$preceded empty lines precede ($expected expected)")
57 if $preceded != $expected;
58 $expected = 2;
59
60 &oops("Answer expected") if $expect_answer;
61 &oops("Q$1$2 is in the wrong section") if ($1 != $section);
62 &oops("Q$1$2 is out of order") if $2 != $question;
63
64 $expect_answer = 1;
65 next;
66 }
67
68 if (/^A(\d\d)(\d\d):/)
69 {
70 &poops("$preceded empty lines precede (1 expected)") if $preceded != 1;
71
72 &oops("Question expected") if !$expect_answer;
73 &oops("A$1$2 is in the wrong section") if $1 != $section;
74 &oops("A$1$2 is out of order") if $2 != $question++;
75
76 $expect_answer = 0;
77 next;
78 }
79 }
80
81 else
82 {
83 if (/^C(\d\d\d):/)
84 {
85 &oops("C$1 is mixed up in the Fs") if $f != 1;
86 # Some Cxxx configs are omitted (not translated from Exim 3) so can
87 # only check increasing number.
88 &oops("C$1 is out of order") if $1 < $c;
89 $c = $1;
90 }
91 elsif (/^F(\d\d\d):/)
92 {
93 &oops("F$1 is out of order") if $1 != $f++;
94 next;
95 }
96 }
97 }
98
99exit 1 if $precede_fail;
100
101# End