interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / lint-delimited-sections.perl

48 lines · 878 bytes Raw Blame History
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6my $exit_code = 0;
7sub report {
8 my ($msg) = @_;
9 print STDERR "$ARGV:$.: $msg\n";
10 $exit_code = 1;
11}
12
13my $line_length = 0;
14my $in_section = 0;
15my $section_header = "";
16
17
18while (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
44if ($in_section) {
45 report("section not finished");
46}
47
48exit $exit_code;