Branch Coverage

blib/lib/PDF/Builder/Basic/PDF/File.pm
Criterion Covered Total %
branch 208 412 50.4


line true false branch
204 217 0 unless ($root)
249 0 18 if (defined $options{'-diags'} and not defined $options{'diags'})
251 18 0 unless defined $options{'diags'}
255 18 0 if (ref $filename) { }
257 18 0 if ($update)
263 0 0 unless -f $filename
266 0 0 if ($update)
275 0 18 unless ($buffer =~ /^\%PDF\-(\d+\.\d+)(.*?)$PDF::Builder::Basic::PDF::File::cr/mo)
280 0 18 if (defined $2 and length $2 > 0)
293 18 18 if $buffer =~ /startxref($PDF::Builder::Basic::PDF::File::cr|\s*)\d+($PDF::Builder::Basic::PDF::File::cr|\s*)\%\%eof.*?/i
295 0 18 unless ($buffer =~ /startxref[^\d]+([0-9]+)($PDF::Builder::Basic::PDF::File::cr|\s*)\%\%eof.*?/i)
296 0 0 if ($options{'diags'} == 1)
333 5 26 defined $trailer_version && $trailer_version > $header_version ? :
337 3 28 if (@_)
341 0 3 if (defined $opts{'-silent'} and not defined $opts{'silent'})
344 0 3 if ($version =~ /^\d+$/)
346 0 3 unless ($version =~ /^[12]\.[0-9]+$/)
347 0 0 unless defined $opts{'silent'}
351 0 3 if ($old_version > $version)
352 0 0 unless defined $opts{'silent'}
392 6 33 if (@_)
396 0 6 if (defined $opts{'-silent'} and not defined $opts{'silent'})
399 0 6 if ($version =~ /^\d+$/)
401 0 6 unless ($version =~ /^[12]\.[0-9]+$/)
402 0 0 unless defined $opts{'silent'}
406 0 6 if ($old_version > $version)
407 0 0 unless defined $opts{'silent'}
441 12 25 if ($self->{'Root'}{'Version'})
446 5 32 if (@_)
450 0 5 if (defined $opts{'-silent'} and not defined $opts{'silent'})
453 0 5 if ($version =~ /^\d+$/)
455 0 5 unless ($version =~ /^[12]\.[0-9]+$/)
456 0 0 unless defined $opts{'silent'}
460 0 5 if (defined $old_version and $old_version > $version)
461 0 0 unless defined $opts{'silent'}
483 1 2 if $current_version < $min_version
511 0 179 unless ref $self
525 2547 6250 if (&blessed($item) and $item->can('release')) { }
1862 4388 elsif (ref $item eq 'ARRAY') { }
1065 3323 elsif (ref $item eq 'HASH') { }
552 0 8 unless $self->{' update'}
570 0 8 if (defined $self->{' newroot'}) { }
578 0 25 unless defined $tdict->{$key}
620 171 0 if (ref $filename) { }
651 171 0 if defined $self->{'Info'}
652 0 171 defined $self->{' newroot'} && $self->{' newroot'} ne '' ? :
658 0 171 if $self->{' loc'}
659 0 171 if ($self->{' update'})
661 0 0 unless defined $tdict->{$key}
670 0 171 if ($^O eq "MacOS" and not ref $self->{' fname'})
694 10 1461 defined $opts{'update'} ? :
695 1461 10 if $update
700 162 1309 if ($str =~ /^<
166 1143 elsif ($str =~ /^([0-9]+)(?:$PDF::Builder::Basic::PDF::File::ws_char|$re_comment)+([0-9]+)(?:$PDF::Builder::Basic::PDF::File::ws_char|$re_comment)+R/s) { }
104 1039 elsif ($str =~ /^([0-9]+)(?:$PDF::Builder::Basic::PDF::File::ws_char|$re_comment)+([0-9]+)(?:$PDF::Builder::Basic::PDF::File::ws_char|$re_comment)+obj/s) { }
573 466 elsif ($str =~ m[^/($PDF::Builder::Basic::PDF::File::reg_char*)]s) { }
2 464 elsif ($str =~ /^\(/) { }
0 464 elsif ($str =~ /^
94 370 elsif ($str =~ /^\[/) { }
0 370 elsif ($str =~ /^(true|false)($PDF::Builder::Basic::PDF::File::irreg_char|$)/) { }
370 0 elsif ($str =~ /^([+-.0-9]+)($PDF::Builder::Basic::PDF::File::irreg_char|$)/) { }
0 0 elsif ($str =~ /^null($PDF::Builder::Basic::PDF::File::irreg_char|$)/) { }
703 160 2 if $update
710 453 0 if ($str =~ s[^/($PDF::Builder::Basic::PDF::File::reg_char+)][]) { }
0 0 elsif ($str =~ s[^/$PDF::Builder::Basic::PDF::File::ws_char+][]) { }
0 0 elsif ($str =~ s[^//][/]) { }
721 453 0 unless ref $value eq "PDF::Builder::Basic::PDF::Null"
734 451 2 if $update
738 160 2 if $update
742 11 151 if ($str =~ s/^stream(?:(?:\015\012)|\012|\015)// and $result->{'Length'}->val != 0)
747 11 0 unless ($opts{'nostreams'})
748 0 11 if ($length > length $str) { }
758 11 0 if $update
763 38 124 if (defined $result->{'Type'} and defined $PDF::Builder::Basic::PDF::File::types{$result->{'Type'}->val})
774 131 35 unless ($result = $self->test_obj($num, $value))
795 90 14 if ($result = $self->test_obj($num, $value)) { }
802 100 4 if $update
821 2 0 if ($str =~ /^([^\\()]+)(.*)/s)
827 0 2 if ($str =~ /^(\\[()])/) { }
0 2 elsif ($str =~ /^\(/) { }
2 0 elsif ($str =~ /^\)/) { }
0 0 elsif ($str =~ /^(\\[^()])/) { }
842 2 0 unless $nested_level
855 0 0 unless $fh->read($str, 255, length $str)
872 94 0 if $update
880 778 0 if $update
897 6 362 if ($update and $str =~ /^$re_whitespace*$/s || $str =~ /^$re_whitespace+[0-9]+$re_whitespace*$/s)
901 4 2 if ($str =~ /^$re_whitespace*([0-9]+)$re_whitespace+(?:R|obj)/s)
932 0 86 unless $objind eq $res
946 0 94 unless defined $num
947 0 94 unless defined $gen
948 0 94 unless $num =~ /^[0-9]+$/
949 0 94 unless $gen =~ /^[0-9]+$/
955 4 90 if (ref $object_location)
959 0 4 unless $object_stream
961 4 0 if $object_stream->{' nofilt'}
967 0 4 if ($object_stream->{' streamfile'}) { }
977 0 4 unless $map[$index] == $num
984 2 2 if ($last_object_in_stream == $num) { }
985 2 0 if ($object_stream->{' stream'}) { }
997 0 4 if ($object_stream->{' streamfile'}) { }
1029 0 1365 if (defined $self->{' free'} and scalar @{$self->{' free'};} > 0)
1031 0 0 if (defined $base) { }
1045 0 1366 defined $i ? :
1048 0 0 unless (defined $self->locate_obj($i, $ng))
1049 0 0 if (defined $base) { }
1064 1365 0 if (defined $base) { }
1089 1382 1609 unless (exists $self->{' outlist_cache'}{$obj})
1130 0 0 if $self->{' objcache'}{join $;, $objind->{' objnum'}, $objind->{' objgen'}} eq $objind
1151 0 184 unless defined $self->{' OUTFILE'}
1155 184 0 unless scalar @objects > 0
1157 0 1074 unless $objind->is_obj($self)
1160 1074 0 if ($self->{' outlist'}[$i] eq $objind)
1165 0 1074 if $j < 0
1168 0 1074 if grep {$_ eq $objind;} @{$$self{" free"};}
1170 0 1074 if $objind->{' comments'}
1179 1074 0 unless (exists $self->{' printed_cache'}{$objind})
1201 0 0 unless defined $outpdf->{$key}
1208 0 0 unless $nt eq "n"
1210 0 0 if ($nl < $minl or $mini == 0)
1215 0 0 unless ($obj = $self->test_obj($i, $ng))
1225 0 0 defined $filter ? :
1226 0 0 unless not $res or $res->is_obj($outpdf)
1233 0 0 if ($obj->isa("PDF::Builder::Basic::PDF::Dict") and $obj->{'Linearized'})
1262 94 9 if (ref $tdict->{' xref'}{$num})
1264 4 90 unless scalar @$ref == 3
1266 90 0 if ($ref->[1] == $gen)
1267 90 0 if $ref->[2] eq "n"
1288 0 3242 if $readDebug
1289 11 3231 if ($instream) { }
1294 0 0 if $readDebug
1300 0 128 if $readDebug
1305 0 1 if $readDebug
1364 0 78 if ($width == 3) { }
0 78 elsif ($width == 5) { }
0 78 elsif ($width == 6) { }
0 78 elsif ($width == 7) { }
1378 26 52 if $width == 1
1379 52 0 if $width == 2
1380 0 0 if $width == 4
1381 0 0 if ($width == 8)
1389 0 0 if (substr($data, 0, 4) eq "\000\000\000\000") { }
1408 0 21 if (defined $options{'-diags'} and not defined $options{'diags'})
1426 18 3 if ($buf =~ s/^xref$PDF::Builder::Basic::PDF::File::cr//i) { }
3 0 elsif ($buf =~ /^(\d+)\s+(\d+)\s+obj/i) { }
1443 0 23 unless ($old_buf =~ /^[0-9]+ [0-9]+$PDF::Builder::Basic::PDF::File::cr/)
1444 0 0 if ($options{'diags'} == 1)
1454 0 23 if ($xnum < 1)
1455 0 0 if ($options{'diags'} == 1)
1466 23 0 if ($buf =~ /^(.*?)$PDF::Builder::Basic::PDF::File::cr/)
1469 0 23 if ($entry_size != 20 and $options{'diags'} == 1)
1483 132 0 if ($buf =~ /^\d{10} \d{5} [nf]$PDF::Builder::Basic::PDF::File::cr/ or $entry_format_error) { }
1487 0 0 if ($options{'diags'} == 1)
1500 0 132 if (exists $xlist->{$xmin}) { }
1501 0 0 if ($options{'diags'} == 1)
1506 0 18 if ($xmin == 0 and $subsection_count > 1 and $options{'diags'} == 1)
1523 0 0 unless (exists $xlist->{'0'} or $xrefListEmpty)
1526 0 0 if ($subsection_count == 1 and exists $xlist->{'1'}) { }
1529 0 0 if ($xlist->{'1'}[0] == 0 and $xlist->{'1'}[1] == 65535 and $xlist->{'1'}[2] eq 'f') { }
1534 0 0 if ($options{'diags'} == 1)
1547 0 0 if ($options{'diags'} == 1)
1553 0 0 if ($options{'diags'} == 1)
1564 18 114 if ($xlist->{$_}[2] eq 'f') { }
114 0 elsif ($xlist->{$_}[2] eq 'n') { }
1565 0 18 if ($xlist->{$_}[1] <= 0 and $options{'diags'} == 1) { }
1571 0 114 if ($xlist->{$_}[0] <= 0 and $options{'diags'} == 1)
1574 0 114 if ($xlist->{$_}[1] < 0 and $options{'diags'} == 1)
1578 0 0 if ($options{'diags'} == 1)
1585 0 18 if ($xlist->{'0'}[1] != 65535 and $options{'diags'} == 1)
1589 0 18 if ($xlist->{$next_free}[2] ne 'f') { }
1590 0 0 if ($options{'diags'} == 1)
1600 0 18 if (scalar @free_list and $options{'diags'} == 1)
1605 0 18 if (not $buf =~ /^\s*trailer\b/i and $options{'diags'} == 1)
1619 0 3 unless ($tdict->{' stream'})
1620 0 0 if ($options{'diags'} == 1)
1633 1 2 if (defined $tdict->{'Index'}) { }
1652 78 0 if $w
1657 1 25 unless defined $cols[0]
1658 0 26 if ($cols[0] > 2 and $options{'diags'} == 1)
1662 0 26 if exists $xlist->{$xmin}
1664 1 0 $xmin ? :
25 1 defined $cols[2] ? :
1665 2 20 $cols[0] == 0 ? :
22 4 if $cols[0] < 2
1672 0 0 if ($options{'diags'} == 1)
1682 18 3 if $xmin + 1 > $self->{' maxobj'}
1684 3 18 if defined $tdict->{'Prev'} and $tdict->{'Prev'}->val != 0
1685 18 3 unless defined $tdict->{' prev'}
1715 3 176 unless $self->{' printed'}
3 176 unless $self->{' free'}
1718 171 8 unless ($update)
1736 3 176 unless $self->{' free'}
1740 191 1062 if ($i > $#xreflist or $self->{' objects'}{$xreflist[$i]->uid}[0] != $j + 1) { }
1742 179 12 $first == -1 ? :
1743 179 12 if ($first == -1)
1745 0 179 defined $freelist[$k] ? :
1750 0 1074 if (defined $freelist[$k] and defined $xref and "$freelist[$k]" eq "$xref") { }
1756 0 0 defined $freelist[$k] ? :
1766 12 179 if $i < scalar @xreflist
1776 0 179 if (exists $tdict->{'Type'} and $tdict->{'Type'}->val eq 'XRef') { }
1781 0 0 @a == 2 ? :
1790 0 0 $tloc > 65535 ? :
1791 0 0 $tloc > 65535 ? :
1798 0 0 if $_->[1] == 65535 and $_->[2] eq "f"
1801 0 0 if ($_->[1] > 255)
1805 0 0 $_->[2] eq 'n' ? :