Commit adbaa54ad43ffb3fd436704d621fe0df9562987b

Authored by Thorsten Schöning
Committed by Jay Berkenbilt
1 parent 951dbc3b

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...
Showing 1 changed file with 7 additions and 5 deletions
qpdf/qtest/qpdf.test
@@ -2,10 +2,11 @@ @@ -2,10 +2,11 @@
2 require 5.008; 2 require 5.008;
3 BEGIN { $^W = 1; } 3 BEGIN { $^W = 1; }
4 use strict; 4 use strict;
5 -use File::Copy;  
6 -use File::Basename;  
7 use Cwd; 5 use Cwd;
8 use Digest::MD5; 6 use Digest::MD5;
  7 +use File::Basename;
  8 +use File::Copy;
  9 +use File::Spec;
9 10
10 chdir("qpdf") or die "chdir testdir failed: $!\n"; 11 chdir("qpdf") or die "chdir testdir failed: $!\n";
11 12
@@ -13,6 +14,7 @@ require TestDriver; @@ -13,6 +14,7 @@ require TestDriver;
13 14
14 cleanup(); 15 cleanup();
15 16
  17 +my $devNull = File::Spec->devnull();
16 my $td = new TestDriver('qpdf'); 18 my $td = new TestDriver('qpdf');
17 19
18 my $compare_images = 1; 20 my $compare_images = 1;
@@ -29,7 +31,7 @@ if ($compare_images) @@ -29,7 +31,7 @@ if ($compare_images)
29 { 31 {
30 # check for working acroread 32 # check for working acroread
31 if (system("acroread -toPostScript -pairs good1.pdf a.ps" . 33 if (system("acroread -toPostScript -pairs good1.pdf a.ps" .
32 - " >/dev/null 2>&1") == 0) 34 + " >$devNull 2>&1") == 0)
33 { 35 {
34 $have_acroread = 1; 36 $have_acroread = 1;
35 } 37 }
@@ -2247,7 +2249,7 @@ sub compare_pdfs @@ -2247,7 +2249,7 @@ sub compare_pdfs
2247 $td->runtest("convert original file to image", 2249 $td->runtest("convert original file to image",
2248 {$td->COMMAND => 2250 {$td->COMMAND =>
2249 "(cd tif1;" . 2251 "(cd tif1;" .
2250 - " gs 2>/dev/null -q -dNOPAUSE -sDEVICE=tiff24nc" . 2252 + " gs 2>$devNull -q -dNOPAUSE -sDEVICE=tiff24nc" .
2251 " -sOutputFile=a.tif - < ../$f1)"}, 2253 " -sOutputFile=a.tif - < ../$f1)"},
2252 {$td->STRING => "", 2254 {$td->STRING => "",
2253 $td->EXIT_STATUS => 0}); 2255 $td->EXIT_STATUS => 0});
@@ -2266,7 +2268,7 @@ sub compare_pdfs @@ -2266,7 +2268,7 @@ sub compare_pdfs
2266 $td->runtest("convert new file to image", 2268 $td->runtest("convert new file to image",
2267 {$td->COMMAND => 2269 {$td->COMMAND =>
2268 "(cd tif2;" . 2270 "(cd tif2;" .
2269 - " gs 2>/dev/null -q -dNOPAUSE -sDEVICE=tiff24nc" . 2271 + " gs 2>$devNull -q -dNOPAUSE -sDEVICE=tiff24nc" .
2270 " -sOutputFile=a.tif - < ../$f2)"}, 2272 " -sOutputFile=a.tif - < ../$f2)"},
2271 {$td->STRING => "", 2273 {$td->STRING => "",
2272 $td->EXIT_STATUS => 0}); 2274 $td->EXIT_STATUS => 0});