5 # MES coverage analyzer
6 # (c)2005 Stepan Roh (PUBLIC DOMAIN)
7 # usage: ./mescover.pl mes_spec_file sfd_files+
9 sub parse_mes_spec_file
($);
10 sub init_mes_glyphs
();
11 sub print_mes_glyphs
();
12 sub parse_sfd_file
($);
14 # map (MES glyph dec => 1)
16 $mes_collection = 'UNKNOWN';
18 sub parse_mes_spec_file
($) {
21 open (F
, $mes_file) || die "Unable to open $mes_file : $!\n";
24 if (/^Collection Name:\s+(.*?)\s*$/) {
26 } elsif (/^Plane\s+(\d+)\s*$/) {
28 } elsif (/^([A-F0-9]+)\s+(.*?)\s*$/) {
30 my @cells = split(/\s+/, $2);
31 foreach $cell (@cells) {
32 my @range = split(/-/, $cell);
34 my $hexenc = $plane.$row.$range[0];
35 my $decenc = hex($hexenc);
36 $mes_glyphs{$decenc} = 1;
38 my $hexenc_start = $plane.$row.$range[0];
39 my $decenc_start = hex($hexenc_start);
40 my $hexenc_end = $plane.$row.$range[1];
41 my $decenc_end = hex($hexenc_end);
42 for (my $decenc = $decenc_start; $decenc <= $decenc_end; $decenc++) {
43 $mes_glyphs{$decenc} = 1;
52 sub init_mes_glyphs
() {
53 foreach $decenc (keys %mes_glyphs) {
54 $mes_glyphs{$decenc} = 1;
58 sub print_mes_glyphs
() {
63 foreach $decenc (sort keys %mes_glyphs) {
64 if ($mes_glyphs{$decenc} != 0) {
65 if ($decenc == $lastenc + 1) {
70 printf("-U+%04x", $lastenc);
72 printf(" U+%04x", $decenc);
81 printf("-U+%04x", $lastenc);
83 print " [$missed/$cnt]";
86 sub parse_sfd_file
($) {
89 open (F
, $sfd_file) || die "Unable to open $sfd_file : $!\n";
94 if (/^StartChar:\s*(\S+)\s*$/) {
98 } elsif (/^Colour:/) {
99 # XXX this is quick'n'dirty hack to detect non-empty glyphs
101 } elsif (/^Encoding:\s*\d+\s*(\d+)\s*\d+\s*$/) {
103 } elsif ($curenc && !$empty && /^EndChar\s*/) {
104 if (defined $mes_glyphs{$curenc}) {
105 $mes_glyphs{$curenc} = 0;
113 print STDERR
"usage: mes_spec_file sfd_files+\n";
117 $mes_spec_file = shift @ARGV;
118 parse_mes_spec_file
($mes_spec_file);
119 print "Missing glyphs from collection $mes_collection\n\n";
121 $sfd_file = shift @ARGV;
122 print $sfd_file, ':';
124 parse_sfd_file
($sfd_file);