]> git.ipfire.org Git - thirdparty/git.git/blob - Documentation/lint-fsck-msgids.perl
Merge branch 'js/update-urls-in-doc-and-comment'
[thirdparty/git.git] / Documentation / lint-fsck-msgids.perl
1 #!/usr/bin/perl
2
3 my ($fsck_h, $fsck_msgids_txt, $okfile) = @ARGV;
4
5 my (%in_fsck_h, $fh, $bad);
6
7 open($fh, "<", "$fsck_h") or die;
8 while (<$fh>) {
9 if (/^\s+FUNC\(([0-9A-Z_]+), ([A-Z]+)\)/) {
10 my ($name, $severity) = ($1, $2);
11 my ($first) = 1;
12 $name = join('',
13 map {
14 y/A-Z/a-z/;
15 if (!$first) {
16 s/^(.)/uc($1)/e;
17 } else {
18 $first = 0;
19 }
20 $_;
21 }
22 split(/_/, $name));
23 $in_fsck_h{$name} = $severity;
24 }
25 }
26 close($fh);
27
28 open($fh, "<", "$fsck_msgids_txt") or die;
29 my ($previous, $current);
30 while (<$fh>) {
31 if (!defined $current) {
32 if (/^\`([a-zA-Z0-9]*)\`::/) {
33 $current = $1;
34 if ((defined $previous) &&
35 ($current le $previous)) {
36 print STDERR "$previous >= $current in doc\n";
37 $bad = 1;
38 }
39 }
40 } elsif (/^\s+\(([A-Z]+)\) /) {
41 my ($level) = $1;
42 if (!exists $in_fsck_h{$current}) {
43 print STDERR "$current does not exist in fsck.h\n";
44 $bad = 1;
45 } elsif ($in_fsck_h{$current} eq "") {
46 print STDERR "$current defined twice\n";
47 $bad = 1;
48 } elsif ($in_fsck_h{$current} ne $level) {
49 print STDERR "$current severity $level != $in_fsck_h{$current}\n";
50 $bad = 1;
51 }
52 $previous = $current;
53 $in_fsck_h{$current} = ""; # mark as seen.
54 undef $current;
55 }
56 }
57 close($fh);
58
59 for my $key (keys %in_fsck_h) {
60 if ($in_fsck_h{$key} ne "") {
61 print STDERR "$key not explained in doc.\n";
62 $bad = 1;
63 }
64 }
65
66 die if ($bad);
67
68 open($fh, ">", "$okfile");
69 print $fh "good\n";
70 close($fh);