--- /Users/sprout/.cpan/build/PDF-Reuse-0.39-tvZelW/lib/PDF/Reuse.pm 2016-09-27 08:48:32.000000000 -0700 +++ /Users/sprout/Perl/dist/PDF-Tiny/lib/PDF/Reuse.pm 2017-02-28 19:48:12.000000000 -0800 @@ -176,6 +176,8 @@ 'S' => 'Symbol', 'Z' => 'ZapfDingbats'); +our $ws = '\s';#'(?:[ \0\n\r\t\f]|%[^\r\n]*[\r\n])'; + our $genLowerX = 0; our $genLowerY = 0; our $genUpperX = 595, @@ -4306,14 +4310,14 @@ if ($buf =~ m'Encrypt'o) { errLog("The file $infil is encrypted, cannot be used, aborts"); } - if ($buf =~ m'\bstartxref\s+(\d+)'o) + if ($buf =~ m/\bstartxref$ws+(\d+)/) { $xref = $1; if ($xref <= $bytes) { while ($xref) { $res = sysseek INFIL, $xref, 0; $res = sysread INFIL, $buf, 200; - if ($buf =~ m '^\d+\s\d+\sobj'os) + if ($buf =~ m /^\d+$ws+\d+$ws+obj/os) { ($xref, $tempRoot, $nr) = crossrefObj($nr, $xref); } else @@ -4365,7 +4369,7 @@ sysseek INFIL, $xref, 0; sysread INFIL, $buf, 400; my $str; - if ($buf =~ m'^(.+>>\s*)stream'os) + if ($buf =~ m/^(.+>>$ws*)stream/os) { $str = $1; $from = length($str) + 7; if (substr($buf, $from, 1) eq "\n") @@ -4382,7 +4386,7 @@ if (!exists $param{'Index'}) { $param{'Index'} = "[0 $param{'Size'}]"; } - if ((exists $param{'Root'}) && ($param{'Root'} =~ m'^\s*(\d+)'o)) + if ((exists $param{'Root'}) && ($param{'Root'} =~ m/^$ws*(\d+)/o)) { $tempRoot = $1; } my @keys = ($param{'W'} =~ m'(\d+)'og); @@ -4540,13 +4552,13 @@ if ($buf =~ m'Encrypt'o) { errLog("The file $infil is encrypted, cannot be used, aborts"); } - if ((! $root) && ($buf =~ m'\/Root\s+(\d+)\s{1,2}\d+\s{1,2}R'so)) + if ((! $root) && ($buf =~ m|\/Root$ws+(\d+)$ws+\d+$ws+R|so)) { $root = $1; if ($xref) { last; } } - if ((! $xref) && ($buf =~ m'\/Prev\s+(\d+)\D'so)) + if ((! $xref) && ($buf =~ m|\/Prev$ws+(\d+)\D|so)) { $xref = $1; if ($root) { last; } @@ -4570,7 +4582,7 @@ { sysseek INFIL, $offs, 0; sysread INFIL, $buf, $siz; if (($noId) && ($noEnd)) - { if ($buf =~ m'^\d+ \d+ obj\s*(.*)endobj'os) + { if ($buf =~ m/^\d+$ws+\d+$ws+obj$ws*(.*)endobj/os) { if (wantarray) { return ($1, $offs, $siz, $embedded); } @@ -4580,7 +4592,7 @@ } } elsif ($noId) - { if ($buf =~ m'^\d+ \d+ obj\s*(.*)'os) + { if ($buf =~ m/^\d+$ws+\d+$ws+obj$ws*(.*)/os) { if (wantarray) { return ($1, $offs, $siz, $embedded); } @@ -4635,7 +4647,7 @@ if ($offs) { sysseek INFIL, $offs, 0; sysread INFIL, $buf, $siz; - if ($buf =~ m'^\d+ \d+ obj\s*(.*)'os) + if ($buf =~ m/^\d+$ws+\d+$ws+obj$ws*(.*)/os) { $del1 = $1; } } @@ -4664,7 +4676,7 @@ } my (%param, $stream, $str); - if ($buf =~ m'^(\d+ \d+ obj\s*<<[\w\d\/\s\[\]<>]+)stream\b'os) + if ($buf =~ m~^(\d+$ws+\d+$ws+obj$ws*<<[\w\d\/\s\[\]<>]+)stream\b~os) { $str = $1; $offs = length($str) + 7; if (substr($buf, $offs, 1) eq "\n") @@ -4767,16 +4779,16 @@ my $objektet = getObject($root);; if ($sidnr == 1) - { if ($objektet =~ m'/AcroForm(\s+\d+\s{1,2}\d+\s{1,2}R)'so) + { if ($objektet =~ m|/AcroForm($ws+\d+$ws+\d+$ws+R)|so) { $AcroForm = $1; } - if ($objektet =~ m'/Names\s+(\d+)\s{1,2}\d+\s{1,2}R'so) + if ($objektet =~ m|/Names$ws+(\d+)$ws+\d+$ws+R|so) { $Names = $1; } ################################################# # Finns ett dictionary för Additional Actions ? ################################################# - if ($objektet =~ m'/AA\s*\<\<\s*[^\>]+[^\>]+'so) # AA är ett dictionary + if ($objektet =~ m|/AA$ws*\<\<$ws*[^\>]+[^\>]+|so) # AA är ett dictionary { my $k; my ($dummy, $obj) = split /\/AA/, $objektet; $obj =~ s/\<\]+[^\>]+'so) # AA är ett dictionary. Hela kopieras + if ($objektet =~ m|/AA$ws*\<\<$ws*[^\>]+[^\>]+|so) # AA är ett dictionary. Hela kopieras { my $k; my ($dummy, $obj) = split /\/AA/, $objektet; $obj =~ s/\<\>\s*stream)'so) + if ($objektet =~ m/^(\d+$ws+\d+$ws+obj$ws*<<)(.+)(>>$ws*stream)/so) { $del1 = $2; $strPos = length($1) + length($2) + length($3); $$$robj[oPOS] = length($1); @@ -4945,7 +4957,7 @@ } $referens = $objNr; - $res = ($nyDel1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs); + $res = ($nyDel1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs); if ($res) { $$$robj[oKIDS] = 1; } if ($action eq 'print') @@ -4957,11 +4969,11 @@ $form{$fSource}[fVALID] = $validStream; } else # Endast resurserna kan behandlas - { $formRes =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + { $formRes =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } } else # Endast resurserna kan behandlas - { $formRes =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + { $formRes =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } my $preLength; @@ -4975,24 +4987,24 @@ ($objektet, $offs, $siz, $embedded) = getObject($gammal); $robj = \$$$rform[fOBJ]->{$gammal}; @{$$$robj[oNR]} = ($offs, $siz, $embedded); - if ($objektet =~ m'^(\d+ \d+ obj\s*<<)(.+)(>>\s*stream)'os) + if($objektet =~ m/^(\d+$ws+\d+$ws+obj$ws*<<)(.+)(>>$ws*stream)/os) { $del1 = $2; $strPos = length ($1) + length($2) + length($3); $$$robj[oPOS] = length($1); $$$robj[oSTREAMP] = $strPos; ######## En bild ######## - if ($del1 =~ m'/Subtype\s*/Image'so) + if ($del1 =~ m|/Subtype$ws*/Image|so) { $imSeq++; $$$robj[oIMAGENR] = $imSeq; push @{$$$rform[fIMAGES]}, $gammal; - if ($del1 =~ m'/Width\s+(\d+)'os) + if ($del1 =~ m|/Width$ws+(\d+)|os) { $$$robj[oWIDTH] = $1; } - if ($del1 =~ m'/Height\s+(\d+)'os) + if ($del1 =~ m|/Height$ws+(\d+)|os) { $$$robj[oHEIGHT] = $1; } } - $res = ($del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs); + $res = ($del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs); if ($res) { $$$robj[oKIDS] = 1; } if ($action eq 'print') @@ -5003,7 +5015,7 @@ } } else - { if ($objektet =~ m'^(\d+ \d+ obj\s*)'os) + { if ($objektet =~ m|^(\d+$ws+\d+$ws+obj$ws*)|os) { $preLength = length($1); $$$robj[oPOS] = $preLength; $objektet = substr($objektet, $preLength); @@ -5011,23 +5023,23 @@ else { $$$robj[oPOS] = 0; } - $res = ($objektet =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs); + $res = ($objektet =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs); if ($res) { $$$robj[oKIDS] = 1; } - if ($objektet =~ m'/Subtype\s*/Image'so) + if ($objektet =~ m|/Subtype$ws*/Image|so) { $imSeq++; $$$robj[oIMAGENR] = $imSeq; push @{$$$rform[fIMAGES]}, $gammal; ################################### # Sparar dimensionerna för bilden ################################### - if ($del1 =~ m'/Width\s+(\d+)'os) + if ($del1 =~ m|/Width$ws+(\d+)|os) { $$$robj[oWIDTH] = $1; } - if ($del1 =~ m'/Height\s+(\d+)'os) + if ($del1 =~ m|/Height$ws+(\d+)|os) { $$$robj[oHEIGHT] = $1; } } - elsif ($objektet =~ m'/BaseFont\s*/([^\s\/]+)'os) + elsif ($objektet =~ m|/BaseFont$ws*/([^\s\/]+)|os) { $Font = $1; $$$robj[oTYPE] = 'Font'; $$$robj[oNAME] = $Font; @@ -5038,7 +5050,7 @@ $font{$Font}[foORIGINALNR] = $gammal; $fontSource{$Font}[foSOURCE] = $fSource; $fontSource{$Font}[foORIGINALNR] = $gammal; - if ($objektet =~ m'/Subtype\s*/Type0'os) + if ($objektet =~ m|/Subtype$ws*/Type0|os) { $font{$Font}[foTYP] = 1; } if ($action eq 'print') @@ -5106,30 +5118,30 @@ } if (defined $AcroForm) { @$$ref[iACROFORM] = $AcroForm; - $AcroForm =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $AcroForm =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } if (defined $AARoot) { @$$ref[iAAROOT] = $AARoot; - $AARoot =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $AARoot =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } if (defined $AAPage) { @$$ref[iAAPAGE] = $AAPage; - $AAPage =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $AAPage =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } if (defined $Annots) { my @array; if ($Annots =~ m'\[([^\[\]]*)\]'os) { $Annots = $1; - @array = ($Annots =~ m'\b(\d+)\s{1,2}\d+\s{1,2}R\b'ogs); + @array = ($Annots =~ m/\b(\d+)$ws+\d+$ws+R\b/ogs); } else - { if ($Annots =~ m'\b(\d+)\s{1,2}\d+\s{1,2}R\b'os) + { if ($Annots =~ m/\b(\d+)$ws+\d+$ws+R\b/os) { $Annots = getObject($1); - @array = ($Annots =~ m'\b(\d+)\s{1,2}\d+\s{1,2}R\b'ogs); + @array = ($Annots =~ m/\b(\d+)$ws+\d+$ws+R\b/ogs); } } @$$ref[iANNOTS] = \@array; - $Annots =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $Annots =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } while (scalar @skapa) @@ -5141,22 +5153,23 @@ ($objektet, $offs, $siz, $embedded) = getObject($gammal); $robj = \$$$ref[fOBJ]->{$gammal}; @{$$$robj[oNR]} = ($offs, $siz, $embedded); - if ($objektet =~ m'^(\d+ \d+ obj\s*<<)(.+)(>>\s*stream)'os) + if ($objektet + =~ m/^(\d+$ws+\d+$ws+obj$ws*<<)(.+)(>>$ws*stream)/os) { $del1 = $2; $$$robj[oPOS] = length($1); $$$robj[oSTREAMP] = length($1) + length($2) + length($3); - $res = ($del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs); + $res = ($del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs); if ($res) { $$$robj[oKIDS] = 1; } } else - { if ($objektet =~ m'^(\d+ \d+ obj)'os) + { if ($objektet =~ m/^(\d+$ws+\d+$ws+obj)/os) { my $preLength = length($1); $$$robj[oPOS] = $preLength; $objektet = substr($objektet, $preLength); - $res = ($objektet =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs); + $res = ($objektet =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs); if ($res) { $$$robj[oKIDS] = 1; } } @@ -5200,17 +5213,17 @@ my $resources = shift; my $valid; - if ($obj =~ m'MediaBox\s*\[\s*([\-\.\d]+)\s+([\-\.\d]+)\s+([\-\.\d]+)\s+([\-\.\d]+)'os) + if ($obj =~ m/MediaBox$ws*\[$ws*([\-\.\d]+)$ws+([\-\.\d]+)$ws+([\-\.\d]+)$ws+([\-\.\d]+)/os) { $formBox[0] = $1; $formBox[1] = $2; $formBox[2] = $3; $formBox[3] = $4; } - if ($obj =~ m'/Contents\s+(\d+)'so) + if ($obj =~ m|/Contents$ws+(\d+)|so) { $formCont = $1; my $cObj = getObject($formCont, 1, 1); - if ($cObj =~ m'^\s*\[[^\]]+\]\s*$'os) + if ($cObj =~ m/^$ws*\[[^\]]+\]$ws*$/os) { $valid = 0; undef $formCont; } @@ -5218,13 +5231,13 @@ { $valid = 1; } } - elsif ($obj =~ m'/Contents\s*\[\s*(\d+)\s{1,2}\d+\s{1,2}R\s*\]'so) + elsif ($obj =~ m|/Contents$ws*\[$ws*(\d+)$ws+\d+$ws+R$ws*\]|so) { $formCont = $1; $valid = 1; } if ($obj =~ m'^(.+/Resources)'so) - { if ($obj =~ m'Resources(\s+\d+\s{1,2}\d+\s{1,2}R)'os) # Hänvisning + { if ($obj =~ m/Resources($ws+\d+$ws+\d+$ws+R)/os) # Hänvisning { $resources = $1; } else # Resurserna är ett dictionary. Hela kopieras { my $dummy; @@ -5347,7 +5360,7 @@ ($del1, $del2, $kids, $typ) = getKnown(\$form{$fSource},$key); - $$del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/translate() . ' 0 R'/oegs; + $$del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/translate() . ' 0 R'/oegs; if (defined $$del2) { $utrad = "$nr 0 obj\n<<" . $$del1 . $$del2; @@ -5400,7 +5413,7 @@ $form{$fSource}->[fBBOX]->[3] . ' ]' . # "\]/Matrix \[ $sX 0 0 $sX $tX $tY \]" . $$del1; - $nyDel1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/translate() . ' 0 R'/oegs; + $nyDel1 =~ s/\b(\d+)$ws+\d+$ws+R\b/translate() . ' 0 R'/oegs; $utrad = "$nr 0 obj" . $nyDel1 . $$del2; @@ -5460,7 +5473,7 @@ ($del1, $del2) = getKnown(\$form{$fSource}, $key); - $$del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $$del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; if (defined $$del2) { $utrad = "$nr 0 obj\n<<" . $$del1 . $$del2; } @@ -5480,7 +5493,7 @@ ($del1, $del2) = getKnown(\$form{$fSource}, $gammal); - $$del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $$del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; if (defined $$del2) { $utrad = "$ny 0 obj\n<<" . $$del1 . $$del2; } @@ -5543,16 +5556,16 @@ if (defined $intAct{$fSource}[iACROFORM]) { $AcroForm = $intAct{$fSource}[iACROFORM]; - $AcroForm =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $AcroForm =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } if (defined $intAct{$fSource}[iAAROOT]) { $AARoot = $intAct{$fSource}[iAAROOT]; - $AARoot =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $AARoot =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } if (defined $intAct{$fSource}[iAAPAGE]) { $AAPage = $intAct{$fSource}[iAAPAGE]; - $AAPage =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $AAPage =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } if (defined $intAct{$fSource}[iANNOTS]) { for (@{$intAct{$fSource}[iANNOTS]}) @@ -5577,7 +5590,7 @@ { $res = sysseek INFIL, ($objData[0] + $$oD[oPOS]), 0; $corr = sysread INFIL, $del1, ($$oD[oSTREAMP] - $$oD[oPOS]) ; if (defined $$oD[oKIDS]) - { $del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + { $del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } $res = sysread INFIL, $del2, ($objData[1] - $corr); $utrad = "$ny 0 obj\n<<" . $del1 . $del2; @@ -5586,7 +5599,7 @@ { $del1 = getObject($gammal); $del1 = substr($del1, $$oD[oPOS]); if (defined $$oD[oKIDS]) - { $del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + { $del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } $utrad = "$ny 0 obj " . $del1; } @@ -5652,7 +5665,7 @@ $formRes = $form{$fSource}->[fRESOURCE]; if ($formRes !~ m'<<.*>>'os) # If not a directory, get it - { if ($formRes =~ m'\b(\d+)\s{1,2}\d+\s{1,2}R'o) + { if ($formRes =~ m/\b(\d+)$ws+\d+$ws+R/o) { $key = $1; $formRes = getKnown(\$form{$fSource}, $key); } @@ -5661,27 +5674,27 @@ } } undef $key; - while ($formRes =~ m'\/(\w+)\s*\<\<([^>]+)\>\>'osg) + while ($formRes =~ m|\/(\w+)$ws*\<\<([^>]+)\>\>|osg) { $resType = $1; my $str = $2; - if ($str =~ m|$namn\s+(\d+)\s{1,2}\d+\s{1,2}R|s) + if ($str =~ m|$namn$ws+(\d+)$ws+\d+$ws+R|s) { $key = $1; last; } } if (! defined $key) # Try to expand the references { my ($str, $del1, $del2); - while ($formRes =~ m'(\/\w+)\s+(\d+)\s{1,2}\d+\s{1,2}R'ogs) + while ($formRes =~ m|(\/\w+)$ws+(\d+)$ws+\d+$ws+R|ogs) { $str .= $1 . ' '; ($del1, $del2) = getKnown(\$form{$fSource}, $2); my $string = $$del1; $str .= $string . ' '; } $formRes = $str; - while ($formRes =~ m'\/(\w+)\s*\<\<([^>]+)\>\>'osg) + while ($formRes =~ m|\/(\w+)$ws*\<\<([^>]+)\>\>|osg) { $resType = $1; my $str = $2; - if ($str =~ m|$namn (\d+)\s{1,2}\d+\s{1,2}R|s) + if ($str =~ m|$namn$ws+(\d+)$ws+\d+$ws+R|s) { $key = $1; last; } @@ -5700,14 +5713,14 @@ if ($resType eq 'Font') { my ($Font, $extNamn); - if ($$del1 =~ m'/BaseFont\s*/([^\s\/]+)'os) + if ($$del1 =~ m|/BaseFont$ws*/([^\s\/]+)|os) { $extNamn = $1; if (! exists $font{$extNamn}) { $fontNr++; $Font = 'Ft' . $fontNr; $font{$extNamn}[foINTNAMN] = $Font; $font{$extNamn}[foORIGINALNR] = $nr; - if ($del1 =~ m'/Subtype\s*/Type0'os) + if ($del1 =~ m|/Subtype$ws*/Type0|os) { $font{$extNamn}[foTYP] = 1; } $fontSource{$Font}[foSOURCE] = $fSource; @@ -5754,7 +5767,7 @@ $objRef{$namn} = $nr; } - $$del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $$del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; if (defined $$del2) { $utrad = "$nr 0 obj\n<<" . $$del1 . $$del2; @@ -5778,7 +5791,7 @@ ($del1, $del2, $kids) = getKnown(\$form{$fSource}, $gammal); - $$del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs + $$del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs unless (! defined $kids); if (defined $$del2) { $utrad = "$ny 0 obj\n<<" . $$del1 . $$del2; @@ -5858,13 +5871,13 @@ if ($typ eq 'Font') { my ($Font, $extNamn); - if ($$del1 =~ m'/BaseFont\s*/([^\s\/]+)'os) + if ($$del1 =~ m|/BaseFont$ws*/([^\s\/]+)|os) { $extNamn = $1; $fontNr++; $Font = 'Ft' . $fontNr; $font{$extNamn}[foINTNAMN] = $Font; $font{$extNamn}[foORIGINALNR] = $key; - if ($del1 =~ m'/Subtype\s*/Type0'os) + if ($del1 =~ m|/Subtype$ws*/Type0|os) { $font{$extNamn}[foTYP] = 1; } if ( ! defined $fontSource{$extNamn}[foSOURCE]) @@ -5912,7 +5925,7 @@ $objRef{$namn} = $nr; } - $$del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs + $$del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs unless (! defined $kids); if (defined $$del2) { $utrad = "$nr 0 obj\n<<" . $$del1 . $$del2; @@ -5937,7 +5950,7 @@ ($del1, $del2, $kids) = getKnown(\$form{$fSource}, $gammal); - $$del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs + $$del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs unless (! defined $kids); if (defined $$del2) @@ -6011,10 +6024,10 @@ my $objektet = getObject($root); if ((! $interActive) && ( ! $to) && ($from == 1)) - { if ($objektet =~ m'/AcroForm(\s+\d+\s{1,2}\d+\s{1,2}R)'so) + { if ($objektet =~ m|/AcroForm($ws+\d+$ws+\d+$ws+R)|so) { $AcroForm = $1; } - if ($objektet =~ m'/Names\s+(\d+)\s{1,2}\d+\s{1,2}R'so) + if ($objektet =~ m|/Names$ws+(\d+)$ws+\d+$ws+R|so) { $Names = $1; } if ((scalar %fields) || (scalar @jsfiler) || (scalar @inits)) @@ -6027,9 +6040,9 @@ ################################################# # Finns ett dictionary för Additional Actions ? ################################################# - if ($objektet =~ m'/AA(\s+\d+\s{1,2}\d+\s{1,2}R)'os) # Hänvisning + if ($objektet =~ m|/AA($ws+\d+$ws+\d+$ws+R)|os) # Hänvisning { $AARoot = $1; } - elsif ($objektet =~ m'/AA\s*\<\<\s*[^\>]+[^\>]+'so) # AA är ett dictionary + elsif ($objektet =~ m|/AA$ws*\<\<$ws*[^\>]+[^\>]+|so) # AA är ett dictionary { my $k; my ($dummy, $obj) = split /\/AA/, $objektet; $obj =~ s/\<\{sidor} = $sidor; } @@ -6068,9 +6081,9 @@ my @levels; my %kids; my $li = -1; - if ($objektet =~ m'/Kids\s*\[([^\]]+)'os) + if ($objektet =~ m|/Kids$ws*\[([^\]]+)|os) { $vektor = $1; - while ($vektor =~ m'(\d+)\s{1,2}\d+\s{1,2}R'go) + while ($vektor =~ m|(\d+)$ws+\d+$ws+R|go) { push @sidObj, $1; } $li++; @@ -6081,11 +6094,11 @@ { if (scalar @{$levels[$li]}) { my $j = shift @{$levels[$li]}; $objektet = getObject($j); - if ($objektet =~ m'/Kids\s*\[([^\]]+)'os) + if ($objektet =~ m|/Kids$ws*\[([^\]]+)|os) { $resources = checkResources($objektet, $resources); $vektor = $1; my @sObj; - while ($vektor =~ m'(\d+)\s{1,2}\d+\s{1,2}R'go) + while ($vektor =~ m/(\d+)$ws+\d+$ws+R/go) { push @sObj, $1 if !$kids{$1}; $kids{$1}=1; } if(@sObj) @@ -6120,10 +6133,10 @@ } if (defined $AcroForm) - { $AcroForm =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + { $AcroForm =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } if (defined $AARoot) - { $AARoot =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + { $AARoot =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; } while (scalar @skapa) @@ -6134,10 +6147,10 @@ my $ny = $$_[1]; $objektet = getObject($gammal); - if ($objektet =~ m'^(\d+ \d+ obj\s*<<)(.+)(>>\s*stream)'os) + if($objektet =~ m/^(\d+$ws+\d+$ws+obj$ws*<<)(.+)(>>$ws*stream)/os) { $del1 = $2; $strPos = length($2) + length($3) + length($1); - $del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; $objekt[$ny] = $pos; $utrad = "$ny 0 obj<<" . "$del1" . '>>stream'; $del2 = substr($objektet, $strPos); @@ -6146,11 +6159,11 @@ $pos += syswrite UTFIL, $utrad; } else - { if ($objektet =~ m'^(\d+ \d+ obj)'os) + { if ($objektet =~ m/^(\d+$ws+\d+$ws+obj)/os) { my $preLength = length($1); $objektet = substr($objektet, $preLength); } - $objektet =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $objektet =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; $objekt[$ny] = $pos; $utrad = "$ny 0 obj$objektet"; $pos += syswrite UTFIL, $utrad; @@ -6215,10 +6228,10 @@ # contains an array of content streams. Replace the ref with the array ######################################################################## - if ($obj =~ m'/Contents\s+(\d+)\s{1,2}\d+\s{1,2}R'os) + if ($obj =~ m|/Contents$ws+(\d+)$ws+\d+$ws+R|os) { my $cObj = getObject($1, 1, 1); - if ($cObj =~ m'^\s*\[[^\]]+\]\s*$'os) - { $obj =~ s|/Contents\s+\d+\s{1,2}\d+\s{1,2}R|'/Contents ' . $cObj|oes; + if ($cObj =~ m/^$ws*\[[^\]]+\]$ws*$/os) + { $obj =~ s|/Contents$ws+\d+$ws+\d+$ws+R|'/Contents ' . $cObj|oes; } } @@ -6236,14 +6249,14 @@ my $i = 0; while (($resources !~ m'\/'os) && ($i < 10)) { $i++; - if ($resources =~ m'\s+(\d+)\s{1,2}\d+\s{1,2}R'os) + if ($resources =~ m/$ws+(\d+)$ws+\d+$ws+R/os) { $resources = getObject($1, 1, 1); } } if ($i > 7) { errLog("Couldn't find resources to merge"); } - if ($resources =~ m'\s*\<\<(.*)\>\>'os) + if ($resources =~ m/$ws*\<\<(.*)\>\>/os) { $resources = $1; } @@ -6257,44 +6270,44 @@ ############################################################### if (scalar %sidFont) - { if ($resources =~ m'/Font\s+(\d+)\s{1,2}\d+\s{1,2}R'os) + { if ($resources =~ m|/Font$ws+(\d+)$ws+\d+$ws+R|os) { my $dict = getObject($1, 1, 1); - $resources =~ s"/Font\s+\d+\s{1,2}\d+\s{1,2}R"'/Font' . $dict"ose; + $resources =~ s"/Font$ws+\d+$ws+\d+$ws+R"'/Font' . $dict"ose; } } if (scalar %sidXObject) - { if ($resources =~ m'/XObject\s+(\d+)\s{1,2}\d+\s{1,2}R'os) + { if ($resources =~ m|/XObject$ws+(\d+)$ws+\d+$ws+R|os) { my $dict = getObject($1, 1, 1); - $resources =~ s"/XObject\s+\d+\s{1,2}\d+\s{1,2}R"'/XObject' . $dict"ose; + $resources =~ s"/XObject$ws+\d+$ws+\d+$ws+R"'/XObject' . $dict"ose; } } if (scalar %sidExtGState) - { if ($resources =~ m'/ExtGState\s+(\d+)\s{1,2}\d+\s{1,2}R'os) + { if ($resources =~ m|/ExtGState$ws+(\d+)$ws+\d+$ws+R|os) { my $dict = getObject($1, 1, 1); - $resources =~ s"/ExtGState\s+\d+\s{1,2}\d+\s{1,2}R"'/ExtGState' . $dict"ose; + $resources =~ s"/ExtGState$ws+\d+$ws+\d+$ws+R"'/ExtGState' . $dict"ose; } } if (scalar %sidPattern) - { if ($resources =~ m'/Pattern\s+(\d+)\s{1,2}\d+\s{1,2}R'os) + { if ($resources =~ m|/Pattern$ws+(\d+)$ws+\d+$ws+R|os) { my $dict = getObject($1, 1, 1); - $resources =~ s"/Pattern\s+\d+\s{1,2}\d+\s{1,2}R"'/Pattern' . $dict"ose; + $resources =~ s"/Pattern$ws+\d+$ws+\d+$ws+R"'/Pattern' . $dict"ose; } } if (scalar %sidShading) - { if ($resources =~ m'/Shading\s+(\d+)\s{1,2}\d+\s{1,2}R'os) + { if ($resources =~ m|/Shading$ws+(\d+)$ws+\d+$ws+R|os) { my $dict = getObject($1, 1, 1); - $resources =~ s"/Shading\s+\d+\s{1,2}\d+\s{1,2}R"'/Shading' . $dict"ose; + $resources =~ s"/Shading$ws+\d+$ws+\d+$ws+R"'/Shading' . $dict"ose; } } if (scalar %sidColorSpace) - { if ($resources =~ m'/ColorSpace\s+(\d+)\s{1,2}\d+\s{1,2}R'os) + { if ($resources =~ m|/ColorSpace$ws+(\d+)$ws+\d+$ws+R|os) { my $dict = getObject($1, 1, 1); - $resources =~ s"/ColorSpace\s+\d+\s{1,2}\d+\s{1,2}R"'/ColorSpace' . $dict"ose; + $resources =~ s"/ColorSpace$ws+\d+$ws+\d+$ws+R"'/ColorSpace' . $dict"ose; } } #################################################### @@ -6302,7 +6315,7 @@ # värden. Spara värden för "översättning" #################################################### - $resources =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $resources =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; ############################### # Komplettera med nya resurser @@ -6317,7 +6330,7 @@ { $resources = "/Font << $str >> " . $resources; } else - { $resources =~ s"/Font\s*<<"'/Font<<' . $str"oges; + { $resources =~ s"/Font$ws*<<"'/Font<<' . $str"oges; } } @@ -6330,7 +6343,7 @@ { $resources = "/XObject << $str >> " . $resources; } else - { $resources =~ s"/XObject\s*<<"'/XObject<<' . $str"oges; + { $resources =~ s"/XObject$ws*<<"'/XObject<<' . $str"oges; } } @@ -6343,7 +6356,7 @@ { $resources = "/ExtGState << $str >> " . $resources; } else - { $resources =~ s"/ExtGState\s*<<"'/ExtGState<<' . $str"oges; + { $resources =~ s"/ExtGState$ws*<<"'/ExtGState<<' . $str"oges; } } @@ -6356,7 +6369,7 @@ { $resources = "/Pattern << $str >> " . $resources; } else - { $resources =~ s"/Pattern\s*<<"'/Pattern<<' . $str"oges; + { $resources =~ s"/Pattern$ws*<<"'/Pattern<<' . $str"oges; } } @@ -6369,7 +6382,7 @@ { $resources = "/Shading << $str >> " . $resources; } else - { $resources =~ s"/Shading\s*<<"'/Shading<<' . $str"oges; + { $resources =~ s"/Shading$ws*<<"'/Shading<<' . $str"oges; } } @@ -6382,7 +6395,7 @@ { $resources = "/ColorSpace << $str >> " . $resources; } else - { $resources =~ s"/ColorSpace\s*<<"'/ColorSpace<<' . $str"oges; + { $resources =~ s"/ColorSpace$ws*<<"'/ColorSpace<<'.$str"oges; } } @@ -6427,53 +6440,53 @@ $old{$oNr} = $ny; - if ($obj =~ m'/Parent\s+(\d+)\s{1,2}\d+\s{1,2}R\b'os) + if ($obj =~ m|/Parent$ws+(\d+)$ws+\d+$ws+R\b|os) { $old{$1} = $parent; } - if ($obj =~ m'^\d+ \d+ obj\s*<<(.+)>>\s*endobj'os) + if ($obj =~ m/^\d+$ws+\d+$ws+obj$ws*<<(.+)>>$ws*endobj/os) { $del1 = $1; } if (%links) { my $tSida = $sida + 1; if ((%links && @{$links{'-1'}}) || (%links && @{$links{$tSida}})) - { if ($del1 =~ m'/Annots\s*([^\/\<\>]+)'os) + { if ($del1 =~ m|/Annots$ws*([^\/\<\>]+)|os) { $Annots = $1; @annots = (); if ($Annots =~ m'\[([^\[\]]*)\]'os) { ; } else - { if ($Annots =~ m'\b(\d+)\s{1,2}\d+\s{1,2}R\b'os) + { if ($Annots =~ m/\b(\d+)$ws+\d+$ws+R\b/os) { $Annots = getObject($1); } } - while ($Annots =~ m'\b(\d+)\s{1,2}\d+\s{1,2}R\b'ogs) + while ($Annots =~ m/\b(\d+)$ws+\d+$ws+R\b/ogs) { push @annots, xform(); } - $del1 =~ s?/Annots\s*([^\/\<\>]+)??os; + $del1 =~ s?/Annots$ws*([^\/\<\>]+)??os; } $Annots = '/Annots ' . mergeLinks() . ' 0 R'; } } if (! $taInterAkt) - { $del1 =~ s?\s*/AA\s*<<[^>]*>>??os; + { $del1 =~ s?$ws*/AA$ws*<<[^>]*>>??os; } - $del1 =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $del1 =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; if ($del1 !~ m'/Resources'o) { $del1 .= "/Resources $resources"; } if (defined $streamObjekt) # En ny ström ska läggas till - { if ($del1 =~ m'/Contents\s+(\d+)\s{1,2}\d+\s{1,2}R'os) + { if ($del1 =~ m|/Contents$ws+(\d+)$ws+\d+$ws+R|os) { my $oldCont = $1; - $del1 =~ s|/Contents\s+(\d+)\s{1,2}\d+\s{1,2}R|'/Contents [' . "$oldCont 0 R $streamObjekt" . ']'|oes; + $del1 =~ s|/Contents$ws+(\d+)$ws+\d+$ws+R|'/Contents [' . "$oldCont 0 R $streamObjekt" . ']'|oes; } - elsif ($del1 =~ m'/Contents\s*\['os) - { $del1 =~ s|/Contents\s*\[([^\]]+)|'/Contents [' . $1 ." $streamObjekt"|oes; + elsif ($del1 =~ m|/Contents$ws*\[|os) + { $del1 =~ s|/Contents$ws*\[([^\]]+)|'/Contents [' . $1 ." $streamObjekt"|oes; } else { $del1 .= "/Contents $streamObjekt\n"; @@ -6512,7 +6525,7 @@ if ( $p < 0) { ; } - elsif ($pObj =~ m'/Resources(\s+\d+\s{1,2}\d+\s{1,2}R)'os) + elsif ($pObj =~ m|/Resources($ws+\d+$ws+\d+$ws+R)|os) { $reStr = $1; $to = $p + 10 + length($reStr); } @@ -6577,7 +6590,7 @@ if ($objektet =~ m'<<(.+)>>'ogs) { $objektet = $1; } - if ($objektet =~ s'/JavaScript\s+(\d+)\s{1,2}\d+\s{1,2}R''os) + if ($objektet =~ s|/JavaScript$ws+(\d+)$ws+\d+$ws+R||os) { my $byt = $1; push @kid, $1; while (scalar @kid) @@ -6585,17 +6598,17 @@ @kid = (); for my $sObj (@soek) { $obj = getObject($sObj, 1); - if ($obj =~ m'/Kids\s*\[([^]]+)'ogs) + if ($obj =~ m|/Kids$ws*\[([^]]+)|ogs) { $vektor = $1; } - while ($vektor =~ m'\b(\d+)\s{1,2}\d+\s{1,2}R\b'ogs) + while ($vektor =~ m/\b(\d+)$ws+\d+$ws+R\b/ogs) { push @kid, $1; } $vektor = ''; - if ($obj =~ m'/Names\s*\[([^]]+)'ogs) + if ($obj =~ m|/Names$ws*\[([^]]+)|ogs) { $vektor = $1; } - while ($vektor =~ m'\(([^\)]+)\)\s*(\d+) \d R'gos) + while ($vektor=~m|\(([^\)]+)\)$ws*(\d+)$ws+\d$ws+R|gos) { $script{$1} = $2; } } @@ -6606,7 +6619,7 @@ { $objektet = getObject($namnObj); if ($objektet =~ m'<<(.+)>>'ogs) { $objektet = $1; } - if ($objektet =~ s'/JavaScript\s+(\d+)\s{1,2}\d+\s{1,2}R''os) + if ($objektet =~ s|/JavaScript$ws+(\d+)$ws+\d+$ws+R||os) { my $byt = $1; push @kid, $1; while (scalar @kid) @@ -6614,17 +6627,17 @@ @kid = (); for my $sObj (@soek) { $obj = getObject($sObj); - if ($obj =~ m'/Kids\s*\[([^]]+)'ogs) + if ($obj =~ m|/Kids$ws*\[([^]]+)|ogs) { $vektor = $1; } - while ($vektor =~ m'\b(\d+)\s{1,2}\d+\s{1,2}R\b'ogs) + while ($vektor =~ m|\b(\d+)$ws+\d+$ws+R\b|ogs) { push @kid, $1; } undef $vektor; - if ($obj =~ m'/Names\s*\[([^]]+)'ogs) + if ($obj =~ m|/Names$ws*\[([^]]+)|ogs) { $vektor = $1; } - while ($vektor =~ m'\(([^\)]+)\)\s*(\d+) \d R'gos) + while($vektor =~ m/\(([^\)]+)\)$ws*(\d+)$ws+\d\$ws+R/gos) { $script{$1} = $2; } } @@ -6758,8 +6771,8 @@ $ny = $objNr; - $objektet =~ s|\s*/JavaScript\s*\d+\s{1,2}\d+\s{1,2}R||os; - $objektet =~ s/\b(\d+)\s{1,2}\d+\s{1,2}R\b/xform() . ' 0 R'/oegs; + $objektet =~ s|$ws*/JavaScript$ws*\d+$ws+\d+$ws+R||os; + $objektet =~ s/\b(\d+)$ws+\d+$ws+R\b/xform() . ' 0 R'/oegs; if (scalar %script) { $objektet .= "\n/JavaScript $ny 0 R\n"; }