Merge branch 'ps/reflog-list' into HEAD
[alt-git.git] / Documentation / lint-fsck-msgids.perl
blob1233ffe81533b2702aafe04cf184f5d626449213
1 #!/usr/bin/perl
3 my ($fsck_h, $fsck_msgids_txt, $okfile) = @ARGV;
5 my (%in_fsck_h, $fh, $bad);
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;
20 $_;
22 split(/_/, $name));
23 $in_fsck_h{$name} = $severity;
26 close($fh);
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;
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;
52 $previous = $current;
53 $in_fsck_h{$current} = ""; # mark as seen.
54 undef $current;
57 close($fh);
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;
66 die if ($bad);
68 open($fh, ">", "$okfile");
69 print $fh "good\n";
70 close($fh);