2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-09 17:53:57 +00:00

Fix non-portable use of /dev/null

/dev/null is not portable, so use File::Spec instead, which provides
portable "paths" and especially "nul" on Windows. I changed all places
with hard coded /dev/null to be sure, while I think it only is a
problem in direct system calls, because the other executed commands go
to sh.exe from MSYS which itself should port /dev/null to NUL. The
test still pass, so shouldn't have made any harm...
This commit is contained in:
Thorsten Schöning 2015-11-23 10:50:10 +01:00 committed by Jay Berkenbilt
parent 951dbc3b7f
commit adbaa54ad4

View File

@ -2,10 +2,11 @@
require 5.008; require 5.008;
BEGIN { $^W = 1; } BEGIN { $^W = 1; }
use strict; use strict;
use File::Copy;
use File::Basename;
use Cwd; use Cwd;
use Digest::MD5; use Digest::MD5;
use File::Basename;
use File::Copy;
use File::Spec;
chdir("qpdf") or die "chdir testdir failed: $!\n"; chdir("qpdf") or die "chdir testdir failed: $!\n";
@ -13,6 +14,7 @@ require TestDriver;
cleanup(); cleanup();
my $devNull = File::Spec->devnull();
my $td = new TestDriver('qpdf'); my $td = new TestDriver('qpdf');
my $compare_images = 1; my $compare_images = 1;
@ -29,7 +31,7 @@ if ($compare_images)
{ {
# check for working acroread # check for working acroread
if (system("acroread -toPostScript -pairs good1.pdf a.ps" . if (system("acroread -toPostScript -pairs good1.pdf a.ps" .
" >/dev/null 2>&1") == 0) " >$devNull 2>&1") == 0)
{ {
$have_acroread = 1; $have_acroread = 1;
} }
@ -2247,7 +2249,7 @@ sub compare_pdfs
$td->runtest("convert original file to image", $td->runtest("convert original file to image",
{$td->COMMAND => {$td->COMMAND =>
"(cd tif1;" . "(cd tif1;" .
" gs 2>/dev/null -q -dNOPAUSE -sDEVICE=tiff24nc" . " gs 2>$devNull -q -dNOPAUSE -sDEVICE=tiff24nc" .
" -sOutputFile=a.tif - < ../$f1)"}, " -sOutputFile=a.tif - < ../$f1)"},
{$td->STRING => "", {$td->STRING => "",
$td->EXIT_STATUS => 0}); $td->EXIT_STATUS => 0});
@ -2266,7 +2268,7 @@ sub compare_pdfs
$td->runtest("convert new file to image", $td->runtest("convert new file to image",
{$td->COMMAND => {$td->COMMAND =>
"(cd tif2;" . "(cd tif2;" .
" gs 2>/dev/null -q -dNOPAUSE -sDEVICE=tiff24nc" . " gs 2>$devNull -q -dNOPAUSE -sDEVICE=tiff24nc" .
" -sOutputFile=a.tif - < ../$f2)"}, " -sOutputFile=a.tif - < ../$f2)"},
{$td->STRING => "", {$td->STRING => "",
$td->EXIT_STATUS => 0}); $td->EXIT_STATUS => 0});