source: trunk/dports/perl/p5-cam-pdf/files/patch-lib-CAM-PDF.pm @ 52872

Last change on this file since 52872 was 52872, checked in by ricci@…, 11 years ago

replace files/patch-lib-CAM-PDF.pm with new patchfile (old one was effectively

incorporated upstream and was no longer use) - new patchfile fixes problems
if there are objects in the PDF with xref of 0.

bump revision

File size: 1.9 KB
Line 
1--- lib/CAM/PDF.pm      2008-10-02 21:31:43.000000000 -0700
2+++ lib/CAM/PDF.pm      2009-06-24 16:59:11.000000000 -0700
3@@ -1019,7 +1019,7 @@
4 
5    if (${$c} !~ m/ \G(\d+)\s+(\d+)\s+obj\s* /cgxms) ##no critic(ProhibitUnusedCapture)
6    {
7-      die "Expected object open tag\n" . $self->trimstr(${$c});
8+      die "Expected object open tag, got:  \"" . $self->trimstr(${$c} . "\"");
9    }
10    # need to implement like this with explicit capture vars for 5.6.1
11    # compatibility
12@@ -1699,8 +1699,9 @@
13       #print "Filling cache for obj \#$key...\n";
14 
15       my $pos = $self->{xref}->{$key};
16+      my $posAsInt = int($pos);
17 
18-      if (!$pos)
19+      if (!$posAsInt)
20       {
21          warn "Bad request for object $key at position 0 in the file\n";
22          return;
23@@ -4834,9 +4835,20 @@
24 
25    # Turn off Linearization, if set
26    my $first;
27+   my $firstObjPos = undef;
28    if (exists $self->{order})
29    {
30-      $first = $self->{order}->[0];
31+      my $iterator = 0;
32+      my $iteratorMAX = $#{$self->{order}};
33+      ## find the first object at a non-zero position:
34+      do {
35+         $first = $self->{order}->[$iterator];
36+         $firstObjPos = int($self->{xref}->{$first});
37+         $iterator++;
38+      } while (!$firstObjPos && $iterator < $iteratorMAX);
39+      if (!$firstObjPos) {
40+         die "ERROR: Failed to find first object with non-zero position";
41+      }
42    }
43    else
44    {
45@@ -4844,6 +4856,7 @@
46       ($first) = sort {$x->{$a} <=> $x->{$b}} grep {!ref $x->{$_}} keys %{$x};
47    }
48 
49+
50    my $objnode = $self->dereference($first);
51    if ($objnode->{value}->{type} eq 'dictionary')
52    {
53@@ -5159,6 +5172,12 @@
54 {
55    my $self = shift;
56    my $objnum = shift;
57+   my $objref = $self->dereference($objnum);
58+
59+   if ((!defined($objref)) || (!ref $objref)) {
60+      warn "WARN:  Failed to get object reference for object number $objnum, not writing it out...\n";
61+      return "";
62+   }
63 
64    return "$objnum 0 " . $self->writeAny($self->dereference($objnum));
65 }
Note: See TracBrowser for help on using the repository browser.