| File: | expect-collator.pl |
| Coverage: | 30.2% |
| line | stmt | bran | cond | sub | time | code |
|---|---|---|---|---|---|---|
| 1 | #!/usr/bin/env -S perl | |||||
| 2 | ||||||
| 3 | 1 1 1 | 1142 1 641 | use warnings; | |||
| 4 | ||||||
| 5 | 1 | 45256 | my ($collated, $notes) = @ARGV; | |||
| 6 | 1 | 1 | my @words; | |||
| 7 | 1 | 16 | open EXPECT, '<', $collated; | |||
| 8 | 1 | 6 | while (<EXPECT>) { | |||
| 9 | 0 | 0 | chomp; | |||
| 10 | 0 | 0 | next unless /(.*) \((.*)\)/; | |||
| 11 | 0 | 0 | my ($key, $list) = ($1, $2); | |||
| 12 | 0 | 0 | my @variants = split /, /, $list; | |||
| 13 | 0 0 | 0 0 | @variants = grep { $_ ne $key } @variants; | |||
| 14 | 0 | 0 | push @words, @variants; | |||
| 15 | } | |||||
| 16 | 1 | 7 | close EXPECT; | |||
| 17 | 1 0 | 4 0 | my $pattern = '\`(?:'.join('|', map { quotemeta($_) } @words).')`'; | |||
| 18 | 1 | 9 | open SOURCES, '<', $notes; | |||
| 19 | 1 | 9 | while (<SOURCES>) { | |||
| 20 | 0 | 0 | if ($_ =~ /$pattern/) { | |||
| 21 | 0 | 0 | my $print = 0; | |||
| 22 | 0 | 0 | $print = 1 if s/not a recognized word/ignored by check-spelling because another more general variant is also in expect/; | |||
| 23 | 0 | 0 | $print = 1 if s/unrecognized-spelling/ignored-expect-variant/; | |||
| 24 | 0 | 0 | next unless $print; | |||
| 25 | } else { | |||||
| 26 | 0 | 0 | next unless /\(((?:\w+-)+\w+)\)$/; | |||
| 27 | 0 | 0 | next if $1 eq 'unrecognized-spelling'; | |||
| 28 | } | |||||
| 29 | 0 | 0 | print; | |||
| 30 | } | |||||
| 31 | 1 | 0 | close SOURCES; | |||