diff options
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-x | Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl b/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl index 495cbfeb1e1..99d7af267a0 100755 --- a/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl +++ b/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl @@ -22,8 +22,8 @@ $^W=1; # turn warning on # my $file = "pdfcrop.pl"; my $program = uc($&) if $file =~ /^\w+/; -my $version = "1.10"; -my $date = "2008/07/16"; +my $version = "1.11"; +my $date = "2008/07/22"; my $author = "Heiko Oberdiek"; my $copyright = "Copyright (c) 2002-2008 by $author."; # @@ -44,6 +44,7 @@ my $copyright = "Copyright (c) 2002-2008 by $author."; # 2008/04/05 v1.9: Options --resolution and --bbox added. # 2008/07/16 v1.10: Support for XeTeX added with new options # --pdftex, --xetex, and --xetexcmd. +# 2008/07/22 v1.11: Workaround for open("-|"). ### program identification my $title = "$program $version, $date - $copyright\n"; @@ -345,8 +346,26 @@ if ($::opt_bbox) { @bbox = ($1, $2, $3, $4); } my $page = 0; -my $pid = open(KID_TO_READ, "-|"); -if ($pid) { # parent +# simulate open(FOO, "-|") +# code from http://perldoc.perl.org/perlfork.html +sub pipe_from_fork ($) { + my $parent = shift; + pipe $parent, my $child or die "!!! Error: Cannot open pi;e!\n"; + my $pid = fork(); + die "!!! Error: fork() failed: $!" unless defined $pid; + if ($pid) { + close $child; + } + else { + close $parent; + open(STDOUT, ">&=" . fileno($child)) + or die "!!! Error: Redirecting STDOUT failed!\n"; + } + $pid; +} +# my $pid = open(KID_TO_READ, "-|"); +# if ($pid) { # parent +if (pipe_from_fork(*KID_TO_READ)) { while (<KID_TO_READ>) { my $bb = ($::opt_hires) ? "%%HiResBoundingBox" : "%%BoundingBox"; next unless |