Branch Coverage

blib/lib/File/MMagic.pm
Criterion Covered Total %
branch 144 324 44.4


line true false branch
354 8 1 if (not @_) { }
357 7 1 if ref $fh ne 'FileHandle'
363 7 1 unless $$instance
372 1 0 if ($fh->open("< $filename")) { }
472 0 1 if ($entry =~ /^>/)
523 0 6 unless (-r $file)
529 0 6 if ($^O eq 'MSWin32') { }
532 0 6 if ($File::MMagic::followLinks) { }
534 0 6 if (not -f _ or -z _)
535 0 0 if ($^O ne 'MSWin32' and not $File::MMagic::followLinks and -l _) { }
0 0 elsif (-d _) { }
0 0 elsif (-p _) { }
0 0 elsif (-S _) { }
0 0 elsif (-b _) { }
0 0 elsif (-c _) { }
0 0 elsif (-z _) { }
553 0 6 unless $fh = 'FileHandle'->new("< $file")
558 0 6 if (-x $file and -T _)
564 0 0 if ($line1 =~ /^\#!\s*(\S+)/) { }
595 4 158 if (magicMatch($$self{'magic'}[$m], \$desc, $fh))
596 4 0 if (defined $desc and $desc ne '')
606 156 2 if ($m == $#{$$self{'magic'};} and not $$self{'MF'}[0]->eof)
613 2 4 unless ($matchFound)
620 1 5 unless defined $mtype
630 0 1 if length $data <= 0
633 0 1 unless $mtype eq ''
639 1 0 unless (defined $mtype)
643 1 0 unless defined $mtype
654 1 0 if $ret ne ''
665 0 1 if length $data <= 0
673 0 130 if (magicMatchStr($$self{'magic'}[$m], \$desc, $data))
674 0 0 if (defined $desc and $desc ne '')
683 129 1 if ($m == $#{$$self{'magic'};} and not $$self{'MF'}[0]->eof)
696 0 3 if length $data <= 0
710 3 81 if ($data =~ /$token/gm)
712 1 2 if (not defined $matched_pos or $matched_pos > $tmp)
717 1 11 if $matched_pos
720 1 2 if (%val)
727 0 3 if (not defined $mtype and check_binary($data))
742 0 0 if ($fname =~ /$regex/i)
743 0 0 if (defined $type and not $type =~ /;/ or not defined $type)
748 0 0 unless defined $type
755 2 0 if ($File::MMagic::allowEightbit) { }
757 0 2 if $len <= 0
758 0 2 if $count / $len > 0.1
761 0 0 if $len <= 0
762 0 0 if $count / $len > 0.3
789 162 0 if (@$item == 3)
791 0 162 unless defined $tmp
797 0 162 unless defined $item
802 0 162 unless defined $fh
814 0 162 if ($offtype == 1) { }
0 162 elsif ($offtype == 2) { }
816 0 0 unless $fh->seek($off1, 0)
817 0 0 if ($fh->read($data, $sz) != $sz)
819 0 0 unless $fh->seek($off2, 0)
823 0 0 unless $fh->seek($offset, 1)
827 0 162 unless $fh->seek($offset, 0)
830 140 22 if ($type =~ /^string/ or $type =~ /^regex/) { }
0 22 elsif ($type =~ m[^search/]) { }
834 140 0 if ($numbytes > 0) { }
835 8 132 if ($fh->read($data, $numbytes) != $numbytes)
846 132 0 if ($op eq '=') { }
0 0 elsif ($op eq '<') { }
0 0 elsif ($op eq '>') { }
0 0 elsif ($op eq 'match') { }
856 0 0 $data || '' ? :
861 0 132 if ($File::MMagic::checkMagic)
873 0 22 if ($fh->read($data, $numbytes) != $numbytes)
879 0 22 if (ref $template) { }
889 6 16 if (defined $mask)
894 21 1 if ($op eq '=') { }
0 1 elsif ($op eq 'x') { }
0 1 elsif ($op eq '!') { }
1 0 elsif ($op eq '&') { }
0 0 elsif ($op eq '^') { }
0 0 elsif ($op eq '<') { }
0 0 elsif ($op eq '>') { }
917 0 22 if ($File::MMagic::checkMagic)
923 4 150 if ($match)
927 0 4 if ($message =~ s/^\\b//) { }
932 4 0 if $message
953 130 0 if (@$item == 3)
958 0 130 unless defined $tmp
966 0 130 unless defined $str
967 0 130 if $str eq ''
971 0 130 unless defined $op
980 0 130 if ($offtype == 1) { }
0 130 elsif ($offtype == 2) { }
982 0 0 if length $str < $off1
985 0 0 if length $str < $off2
993 12 118 if $offset > length $str
997 97 21 if ($type =~ /^string/ or $type =~ /^regex/) { }
0 21 elsif ($type =~ m[^search/]) { }
1001 97 0 if ($numbytes > 0) { }
1010 97 0 if ($op eq '=') { }
0 0 elsif ($op eq '<') { }
0 0 elsif ($op eq '>') { }
0 0 elsif ($op eq 'match') { }
1025 0 97 if ($File::MMagic::checkMagic)
1037 0 21 if length $str < 4
1044 0 21 if (ref $template) { }
1054 6 15 if (defined $mask)
1059 20 1 if ($op eq '=') { }
0 1 elsif ($op eq 'x') { }
0 1 elsif ($op eq '!') { }
1 0 elsif ($op eq '&') { }
0 0 elsif ($op eq '^') { }
0 0 elsif ($op eq '<') { }
0 0 elsif ($op eq '>') { }
1082 0 21 if ($File::MMagic::checkMagic)
1088 0 118 if ($match)
1092 0 0 if ($message =~ s/^\\b//) { }
1097 0 0 if $message
1133 9 1653 unless defined $line
1134 897 765 if ($line =~ /^\#/ or $line =~ /^\s*$/)
1135 2 895 if $magicFH->eof
1142 613 152 unless defined $thisDepth
1143 294 471 unless defined $depth
1145 60 705 if (length $thisDepth > $depth) { }
28 677 elsif (length $thisDepth < $depth) { }
323 354 elsif ('ARRAY' eq ref $entry and @$entry) { }
1150 0 60 if ((readMagicEntry($$entry[2], $MF, $depth + 1) || 0) < $depth or $$MF[0]->eof)
1180 1 353 if $magicFH->eof
1210 292 0 if ($line =~ s/^>*([&\(]?[a-fA-Flsx\.\+\-\d]+\)?)\s+(\S+)\s+//) { }
1213 0 292 if ($offset =~ /^\(/) { }
0 292 elsif ($offset =~ /^&/o) { }
1220 0 0 if (($o1, $type, $o2) = $offset =~ /\((\d+)(\.[bsl])?([\+\-]?\d+)?\)/) { }
1222 0 0 if $o1 =~ /^0/o
1223 0 0 if $o2 =~ /^0/o
1226 0 0 if ($type eq '')
1243 0 0 if $offset =~ /^0/o
1250 256 36 if $offset =~ /^0/o
1259 12 280 if ($type =~ s/&(.*)//)
1263 12 0 if $mask =~ /^0/o
1267 0 0 unless (exists $File::MMagic::TEMPLATES{$type} or $type =~ /^string/ or $type =~ /^regex/ or $type =~ m[^search/])
1273 292 0 if ($line =~ s/([^\\])\s+(.*)/$1/) { }
1285 292 0 if (not $type =~ /regex/) { }
1287 2 290 if ($line =~ s/^([><&^=!])//o) { }
0 290 elsif ($line eq 'x') { }
1299 248 44 if ($type =~ /^string/ or $type =~ /^regex/) { }
0 44 elsif ($type =~ m[^search/]) { }
1310 136 0 unless $File::MMagic::ESC{$1}
1314 0 248 if ($operator =~ /[>x]/o) { }
248 0 elsif ($operator =~ /[=<]/o) { }
0 0 elsif ($operator eq '!') { }
0 0 elsif ($operator eq 'match') { }
1329 0 0 if $@
1337 0 0 if $File::MMagic::checkMagic
1347 44 0 if ($operator ne 'x')
1351 40 4 if ($line =~ /^0/o) { }
1361 32 12 if (ref $template)
1362 32 0 unless $operator eq '>' or $operator eq '<'
1375 0 0 unless defined $magic
1376 0 0 unless defined $depth
1381 0 0 if (@$entry == 3)
1383 0 0 unless $tmp
1387 0 0 unless defined $entry
1393 0 0 if ($offtype == 1) { }
0 0 elsif ($offtype == 2) { }
1405 0 0 if ($mask)
1408 0 0 if ($subtests)