Raw
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 my $exit_code = 0;
7 sub report {
8 my ($msg) = @_;
9 print STDERR "$ARGV:$.: $msg\n";
10 $exit_code = 1;
11 }
12
13 my $line_length = 0;
14 my $in_section = 0;
15 my $section_header = "";
16
17
18 while (my $line = <>) {
19 if (($line =~ /^\+?$/) ||
20 ($line =~ /^\[.*\]$/) ||
21 ($line =~ /^ifdef::/)) {
22 $line_length = 0;
23 } elsif ($line =~ /^[^-.]/) {
24 $line_length = length($line);
25 } elsif (($line =~ /^-{3,}$/) || ($line =~ /^\.{3,}$/)) {
26 if ($in_section) {
27 if ($line eq $section_header) {
28 $in_section = 0;
29 }
30 next;
31 }
32 if ($line_length == 0) {
33 $in_section = 1;
34 $section_header = $line;
35 next;
36 }
37 if (($line_length != 0) && (length($line) != $line_length)) {
38 report("section delimiter not preceded by an empty line");
39 }
40 $line_length = 0;
41 }
42 }
43
44 if ($in_section) {
45 report("section not finished");
46 }
47
48 exit $exit_code;