diff options
author | Karl Berry <karl@freefriends.org> | 2009-11-27 19:15:00 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-11-27 19:15:00 +0000 |
commit | 7d65e70f6a6a36aad5ebe7f24cd652f779dfc721 (patch) | |
tree | 6fbaad156160f3e86c2e30100655c3de96fe197d /Build/source/extra | |
parent | 3859d727ef66426ca730d7b4bbbc5fdf5645fd6d (diff) |
make --filter work again
git-svn-id: svn://tug.org/texlive/trunk@16206 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/extra')
-rw-r--r-- | Build/source/extra/epstopdf/Makefile | 6 | ||||
-rwxr-xr-x | Build/source/extra/epstopdf/epstopdf.pl | 79 |
2 files changed, 45 insertions, 40 deletions
diff --git a/Build/source/extra/epstopdf/Makefile b/Build/source/extra/epstopdf/Makefile index 152ae6ec1f7..1dfb8a6c800 100644 --- a/Build/source/extra/epstopdf/Makefile +++ b/Build/source/extra/epstopdf/Makefile @@ -1,7 +1,7 @@ # $Id$ # This file is public domain. (Originally written by Karl Berry, 2009.) -e2p = ./epstopdf.pl #--debug +e2p = ./epstopdf.pl --debug default: check @@ -18,6 +18,10 @@ check-help: check-version: $(e2p) --version +check-filter: + cat test-simple.eps | $(e2p) --filter >test-filter.pdf + pdfinfo test-filter.pdf | grep "Page size:" + check-write-error: -$(e2p) test-simple.eps --outfile=/dev/full diff --git a/Build/source/extra/epstopdf/epstopdf.pl b/Build/source/extra/epstopdf/epstopdf.pl index 9269d38eacf..846ca8423a4 100755 --- a/Build/source/extra/epstopdf/epstopdf.pl +++ b/Build/source/extra/epstopdf/epstopdf.pl @@ -47,14 +47,16 @@ use strict; # # emacs-page # History -# 2009/11/25 v2.14 (Manuel P\'egouri\'e-Gonnard) -# * Better exentension detection, suggested by A. Cherepanov. -# 2009/10/18 v2.13 (Manuel P\'egouri\'e-Gonnard) -# * Better argument validation, from Alexander Cherepanov. -# * Use the list form of pipe open() (resp. system()) to prevent injection. +# 2009/11/27 v2.12 (Karl Berry) +# * Make --filter work again +# 2009/11/25 (Manuel P\'egouri\'e-Gonnard) +# * Better extension detection, suggested by A. Cherepanov. +# 2009/10/18 (Manuel P\'egouri\'e-Gonnard) +# * Better argument validation (Alexander Cherepanov). +# * Use list form of pipe open() (resp. system()) to prevent injection. # Since Perl's fork() emulation doesn't work on Windows with Perl 5.8.8 from # TeX Live 2009, use a temporary file instead of a pipe on Windows. -# 2009/10/14 v2.12 (Manuel P\'egouri\'e-Gonnard) +# 2009/10/14 (Manuel P\'egouri\'e-Gonnard) # * Added restricted mode. # 2009/09/27 v2.11 (Karl Berry) # * Fixed two bugs in the (atend) handling code (Martin von Gagern) @@ -131,7 +133,7 @@ use strict; ### program identification my $program = "epstopdf"; -my $ident = '($Id$) 2.11'; +my $ident = '($Id$) 2.12'; my $copyright = <<END_COPYRIGHT ; Copyright 1998-2001 Sebastian Rahtz et al. Copyright 2002-2009 Gerben Wierda et al. @@ -260,10 +262,8 @@ my $InputFilename = ""; if ($::opt_filter) { @ARGV == 0 or die errorUsage "Input file cannot be used with filter option"; - $InputFilename = "-"; - debug "Input file: standard input"; -} -else { + debug "Filtering: will read standard input"; +} else { @ARGV > 0 or die errorUsage "Input filename missing"; @ARGV < 2 or die errorUsage "Unknown option or too many input files"; $InputFilename = $ARGV[0]; @@ -287,6 +287,28 @@ if ($::opt_gscmd) { my @GS = ($GS); push @GS, qw(-q -dNOPAUSE -dSAFER -sDEVICE=pdfwrite); +### option outfile +my $OutputFilename = $::opt_outfile; +if ($OutputFilename eq "") { + if ($::opt_gs) { + $OutputFilename = $InputFilename; + if (!$::opt_filter) { + my $ds = ($^O eq "MSWin32" || $^O eq "cygwin") ? '\\/' : '/'; + $OutputFilename =~ s/\.[^\.$ds]*$//; + $OutputFilename .= ".pdf"; + } + } else { + $OutputFilename = "-"; # no ghostscript, write to standard output + } +} +if ($::opt_filter) { + debug "Filtering: will write standard output"; + $OutputFilename = "-"; +} else { + debug "Output filename:", $OutputFilename; +} +push @GS, "-sOutputFile=$OutputFilename"; + ### options compress, embed, res, autorotate push @GS, ('-dPDFSETTINGS=/prepress', '-dMaxSubsetPct=100', '-dSubsetFonts=true', '-dEmbedAllFonts=true') if $::opt_embed; @@ -309,29 +331,6 @@ $BBName = "%%HiResBoundingBox:" if $::opt_hires; $BBName = "%%ExactBoundingBox:" if $::opt_exact; debug "BoundingBox comment:", $BBName; -### option outfile -my $OutputFilename = $::opt_outfile; -if ($OutputFilename eq "") { - if ($::opt_gs) { - $OutputFilename = $InputFilename; - if (!$::opt_filter) { - my $ds = ($^O eq "MSWin32" || $^O eq "cygwin") ? '\\/' : '/'; - $OutputFilename =~ s/\.[^\.$ds]*$//; - $OutputFilename .= ".pdf"; - } - } - else { - $OutputFilename = "-"; # standard output - } -} -if ($::opt_filter) { - debug "Output file: standard output"; -} -else { - debug "Output filename:", $OutputFilename; -} -push @GS, "-sOutputFile=$OutputFilename"; - ### validate output file name in restricted mode \label{openout_any} use File::Spec::Functions qw(splitpath file_name_is_absolute); if ($restricted) { @@ -370,8 +369,11 @@ if ($::opt_gs) { ### emacs-page ### open input file -open(IN, '<', $InputFilename) or error "Cannot open", - ($::opt_filter) ? "standard input" : "\"$InputFilename\": $!"; +if ($::opt_filter) { + open(IN, '<-') || error("Cannot open stdin: $!"); +} else { + open(IN, '<', $InputFilename) || error("Cannot open $InputFilename: $!"); +} binmode IN; ### open output file @@ -381,11 +383,10 @@ my $OUT; # filehandle for output (GS pipe or temporary file) use File::Temp 'tempfile'; if ($::opt_gs) { unless ($^O eq 'MSWin32' || $^O eq 'cygwin') { # list piped open works - push @GS, qw(- -c -quit); + push @GS, qw(-c quit); debug "Ghostscript pipe:", join(' ', @GS); open($OUT, '|-', @GS) or error "Cannot open Ghostscript for piped input"; - } - else { # use a temporary file + } else { # use a temporary file on Windows/Cygwin. ($OUT, $tmp_filename) = tempfile(UNLINK => 1); debug "Using temporary file '$tmp_filename'"; } |