Branch Coverage

blib/lib/Image/ExifTool/WritePDF.pl
Criterion Covered Total %
branch 170 308 55.1


line true false branch
47 0 100 if (not $format) { }
69 31 elsif ($format eq 'string') { }
31 0 elsif ($format eq 'date') { }
0 0 elsif ($format eq 'integer') { }
0 0 elsif ($format eq 'real') { }
0 0 elsif ($format eq 'boolean') { }
0 0 elsif ($format eq 'name') { }
53 0 31 unless $$valPtr =~ /^\d{4}/
55 0 0 unless &Image::ExifTool::IsInt($$valPtr)
57 0 0 unless $$valPtr =~ /^[+-]?(?=\d|\.\d)\d*(\.\d*)?$/
59 0 0 $$valPtr && !($$valPtr =~ /^f/i) ? :
61 0 0 if $$valPtr =~ /\0/
76 0 13 if (not $format) { }
11 2 elsif ($format eq 'string') { }
2 0 elsif ($format eq 'date') { }
0 0 elsif ($format =~ /^(integer|real|boolean)$/) { }
0 0 elsif ($format eq 'name') { }
80 0 11 if $val =~ /[\x80-\xff]/
91 0 0 if $val =~ /\0/
92 0 0 if ($pdfVer >= 1.2) { }
95 0 0 if $val =~ m([\t\n\f\r ()<>[\]{}/%])
111 0 13 if (ref $$strPt eq "ARRAY")
120 0 13 if ($$strPt =~ /[\x00-\x08\x0a-\x1f\x7f\xff]/) { }
126 0 0 unless my $n = $len - $i
127 0 0 if $n > 40
128 0 0 if $i
147 0 0 if (not ref $obj) { }
0 0 elsif (ref $obj eq 'HASH') { }
0 0 elsif (ref $obj eq 'ARRAY') { }
149 0 0 if ($obj =~ /^[(<]/)
159 0 0 if $myDictTags{$tag}
165 0 0 if ($needCrypt)
166 0 0 defined $needCrypt->{$tag} ? :
0 0 unless defined $needCrypt->{$tag} ? $needCrypt->{$tag} : $needCrypt->{'*'}
190 0 0 if (ref $w eq "ARRAY" and join($", @$w) eq "1 4 2")
202 0 0 if $pos + $size > $len
205 0 0 if $t[0] == 0
221 43 165 if (ref $obj eq 'SCALAR') { }
12 153 elsif (ref $obj eq 'ARRAY') { }
47 106 elsif (ref $obj eq 'HASH') { }
222 0 43 unless &Write($outfile, " ", $$obj)
225 0 12 @$obj > 10 ? :
0 12 unless &Write($outfile, @$obj > 10 ? $/ : " ", "[")
228 0 22 unless &WriteObject($outfile, $item)
230 0 12 unless &Write($outfile, " ]")
234 0 47 unless &Write($outfile, $/, "<<")
236 9 38 if ($obj->{'_stream'})
238 9 0 if $obj->{'_decrypted'}
252 200 139 if $wrote{$tag} or not defined $obj->{$tag}
253 0 139 unless &Write($outfile, $/, "/$tag")
254 0 139 unless &WriteObject($outfile, $obj->{$tag})
257 0 47 unless &Write($outfile, $/, ">>")
258 9 38 if ($obj->{'_stream'})
261 0 9 unless &Write($outfile, $/, "stream\r\n")
262 0 9 unless &Write($outfile, $obj->{'_stream'}, $/, "endstream")
287 0 19 unless $raf->Read($buff, 1024) >= 8
288 0 19 unless $buff =~ /^(\s*)%PDF-(\d+\.\d+)/
304 0 19 unless $pdfVer
306 0 19 if ($pdfVer > "1.7")
311 0 19 if ($capture{'Error'} or $info->{'Error'})
317 57 0 if $capture{$obj}
319 0 0 if $info->{'Warning'}
327 0 19 unless $raf->Seek(-64, 2) and $raf->Read($buff, 64) and $raf->Seek(0, 0)
331 16 3 if ($buff =~ /$endComment(\d+)\s+(startxref\s+\d+\s+%%EOF\s+)?$/s) { }
0 3 elsif ($et->{'DEL_GROUP'}{'PDF-update'}) { }
334 0 16 unless &Image::ExifTool::CopyBlock($raf, $outfile, $prevUpdate + $et->{'PDFBase'})
336 0 16 unless ($raf->Read($buff, length $beginComment) and $buff eq $beginComment)
340 0 16 unless $raf->Seek($prevUpdate + $et->{'PDFBase'}, 0)
341 2 14 if ($et->{'DEL_GROUP'}{'PDF-update'})
352 0 3 unless &Write($outfile, $buff)
355 0 17 if $et->Options("Verbose")
367 14 3 if ($prevUpdate) { }
368 0 14 unless ($capture{'Prev'})
377 5 4 if $metaRef and $$metaRef =~ /^(\d+)/ and $1 >= $nextObject
385 4 1 if ($et->{'DEL_GROUP'}{'PDF'} and $capture{'Info'})
388 0 4 if $out
393 10 7 unless $capture{'Info'}
398 0 17 unless (ref $infoRef eq "SCALAR")
405 0 17 if $infoDict->{'_needCrypt'}
420 9 2 unless (defined $val)
423 5 4 if $tagKey
425 7 4 if (defined $val) { }
0 4 elsif ($nvHash->{'EditOnly'}) { }
427 3 4 if (ref $val eq "ARRAY")
432 5 6 if ($et->IsOverwriting($nvHash, $val) > 0) { }
439 7 4 unless @oldVals
443 3 4 unless @vals
449 0 6 unless $deleted or $tagInfo->{'List'} or not exists $infoDict->{$tagID}
453 9 2 if (@newVals)
456 0 9 if ($out)
462 0 11 unless (@vals)
469 5 6 if (not $tagInfo->{'List'}) { }
3 3 elsif ($tagInfo->{'List'} eq 'array') { }
474 0 5 unless defined $val
476 3 0 @vals ? :
480 11 0 if (defined $val) { }
487 10 7 if ($infoChanged) { }
6 1 elsif ($prevUpdate) { }
492 4 2 if $oldPos and $oldPos > $prevUpdate
496 14 3 if ($infoChanged)
498 10 4 if (scalar keys %{$capture{'Info'};} > 1) { }
501 3 7 unless $prevInfoRef
506 2 2 if $prevInfoRef
518 4 2 $info->{'XMP'} ? :
6 11 unless defined $newXMP
522 3 5 unless ($newXMP or $info->{'XMP'})
528 10 7 if ($et->{'CHANGED'} != $oldChanged and defined $newXMP) { }
4 3 elsif ($prevUpdate and $capture{'Root'}{'Metadata'}) { }
533 4 0 if $oldPos and $oldPos > $prevUpdate
535 14 3 if ($metaChanged)
536 9 5 if ($newXMP) { }
5 0 elsif ($capture{'Root'}{'Metadata'}) { }
537 5 4 unless ($metaRef)
562 0 17 unless ($rootRef)
566 6 11 if (not $rootChanged and $prevUpdate)
569 3 3 if $oldPos and $oldPos > $prevUpdate
571 13 4 if $rootChanged
575 16 1 if ($et->{'CHANGED'}) { }
1 0 elsif ($prevUpdate) { }
578 0 16 unless &Write($outfile, $beginComment)
582 0 38 unless $objRef =~ /^(\d+) (\d+)/
584 7 31 unless ($newObj{$objRef})
585 7 0 if $gen < 65535
593 0 31 unless &Write($outfile, $/, $keyExt)
594 0 31 unless &WriteObject($outfile, $newObj{$objRef})
595 0 31 unless &Write($outfile, $/, "endobj")
599 3 13 unless $prevUpdate
605 13 3 if ($prevUpdate)
608 0 13 if ($mainDict->{'Type'} and $mainDict->{'Type'} eq '/XRef') { }
615 5 14 unless $newXRef{$id}
622 31 28 unless $newXRef{$id}[2] eq "f"
625 3 25 if ($id >= $nextObject)
636 6 10 if (ref $mainDict->{'ID'} eq "ARRAY" and @{$mainDict->{'ID'};} > 1)
639 6 0 if ($id =~ /^<([0-9a-f]{2})/i) { }
0 0 elsif ($id =~ /^\((.)/s and $1 ne '\\' and $1 ne ')' and $1 ne '(') { }
645 0 0 if $ch =~ /[()\\\x00-\x08\x0a-\x1f\x7f\xff]/
655 0 16 if ($mainDict->{'Type'} and $mainDict->{'Type'} eq '/XRef') { }
670 0 0 if ($pos > 4294967295)
674 0 0 $type eq 'f' ? :
675 0 0 if not @ids or $ids[0] != $id + 1
682 0 0 unless &Write($outfile, $/, $keyExt)
683 0 0 unless &WriteObject($outfile, $mainDict)
684 0 0 unless &Write($outfile, $/, "endobj")
689 0 16 unless &Write($outfile, $/, "xref", $/)
691 16 0 length $/ == 1 ? :
699 34 22 if not @ids or $ids[0] != $id + 1
702 0 34 unless &Write($outfile, $startID, " ", $id - $startID + 1, $/, $buff)
706 0 16 unless &Write($outfile, "trailer")
707 0 16 unless &WriteObject($outfile, $mainDict)
710 0 16 unless &Write($outfile, $/, $endComment, $oldEOF, $/)
713 0 16 unless &Write($outfile, "startxref", $/, $startxref, $/, "%%EOF", $/)
718 0 1 unless $raf->Seek($prevUpdate + $et->{'PDFBase'}, 0)
720 0 1 unless &Write($outfile, $buff)
723 6 10 if ($rtn > 0 and $et->{'CHANGED'} and $et->{'DEL_GROUP'}{'PDF'} || $et->{'DEL_GROUP'}{'XMP'})