Bug 6679 - [SIGNED-OFF] fix 4 perlcritic violations in C4/Creators/PDF.pm
authorMason James <mtj@kohaaloha.com>
Tue, 26 Jun 2012 14:28:26 +0000 (02:28 +1200)
committerPaul Poulain <paul.poulain@biblibre.com>
Thu, 20 Sep 2012 10:17:07 +0000 (12:17 +0200)
- "return" statement with explicit "undef" at line 171, column 8.  See page 199 of PBP.  (Severity: 5)

- "return" statement with explicit "undef" at line 201, column 8.  See page 199 of PBP.  (Severity: 5)

- Bareword file handle opened at line 212, column 11.  See pages 202,204 of PBP.  (Severity: 5)

- Two-argument "open" used at line 212, column 11.  See page 207 of PBP.  (Severity: 5)

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
C4/Creators/PDF.pm

index 41ff548..871e32b 100644 (file)
@@ -168,7 +168,7 @@ sub prAltJpeg
 {  my ($iData, $iWidth, $iHeight, $iFormat,$aiData, $aiWidth, $aiHeight, $aiFormat) = @_;
    my ($namnet, $utrad);
    if (! $PDF::Reuse::pos)                    # If no output is active, it is no use to continue
-   {   return undef;
+   {   return;
    }
    prJpegBlob($aiData, $aiWidth, $aiHeight, $aiFormat);
    my $altObjNr = $PDF::Reuse::objNr;
@@ -198,7 +198,7 @@ sub prJpegBlob
 {  my ($iData, $iWidth, $iHeight, $iFormat, $altArrayObjNr) = @_;
    my ($iLangd, $namnet, $utrad);
    if (! $PDF::Reuse::pos)                    # If no output is active, it is no use to continue
-   {   return undef;
+   {   return;
    }
    my $checkidOld = $PDF::Reuse::checkId;
    if (!$iFormat)
@@ -209,16 +209,16 @@ sub prJpegBlob
           $namnet = 'Ig' . $PDF::Reuse::imageNr;
           $PDF::Reuse::objNr++;
           $PDF::Reuse::objekt[$PDF::Reuse::objNr] = $PDF::Reuse::pos;
-          open (BILDFIL, "<$iFile") || errLog("Couldn't open $iFile, $!, aborts");
-          binmode BILDFIL;
+          open (my $fh, '<', "$iFile") || errLog("Couldn't open $iFile, $!, aborts");
+          binmode $fh;
           my $iStream;
-          sysread BILDFIL, $iStream, $iLangd;
+          sysread $fh, $iStream, $iLangd;
           $utrad = "$PDF::Reuse::objNr 0 obj\n<</Type/XObject/Subtype/Image/Name/$namnet" .
                     "/Width $iWidth /Height $iHeight /BitsPerComponent 8 " .
                     ($altArrayObjNr ? "/Alternates $altArrayObjNr 0 R " : "") .
                     "/Filter/DCTDecode/ColorSpace/DeviceRGB"
                     . "/Length $iLangd >>stream\n$iStream\nendstream\nendobj\n";
-          close BILDFIL;
+          close $fh;
           $PDF::Reuse::pos += syswrite $PDF::Reuse::UTFIL, $utrad;
           if ($PDF::Reuse::runfil)
           {  $PDF::Reuse::log .= "Cid~$PDF::Reuse::checkId\n";