From abb06c39927dee255284ee41af720b3f53d23dd6 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 18 Sep 2010 00:07:10 +0000 Subject: pdfcrop update (17sep10) git-svn-id: svn://tug.org/texlive/trunk@19781 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl | 59 +++++++++++++++++++++------- 1 file changed, 44 insertions(+), 15 deletions(-) (limited to 'Master/texmf-dist/scripts/pdfcrop') diff --git a/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl b/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl index 1fdd3ab3d8f..5e43ec024fd 100755 --- a/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl +++ b/Master/texmf-dist/scripts/pdfcrop/pdfcrop.pl @@ -21,8 +21,8 @@ $^W=1; # turn warning on # my $file = "pdfcrop.pl"; my $program = uc($&) if $file =~ /^\w+/; -my $version = "1.30"; -my $date = "2010/09/15"; +my $version = "1.31"; +my $date = "2010/09/17"; my $author = "Heiko Oberdiek"; my $copyright = "Copyright (c) 2002-2010 by $author."; # @@ -91,6 +91,10 @@ my $copyright = "Copyright (c) 2002-2010 by $author."; # 2010/09/15 v1.30: * Warning of pdfTeX because of \pdfobjcompresslevel # avoided when reducing \pdfminorversion. # * Fix for TeX syntax characters in input file names. +# 2010/09/17 v1.31: * Passing the input file name via hex string to TeX. +# * Again input file names restricted for Ghostscript +# command line, switch then to symbol link/copy +# method. ### program identification my $title = "$program $version, $date - $copyright\n"; @@ -602,9 +606,9 @@ $SIG{'__DIE__'} = \&clean; ### Calculation of BoundingBoxes # use safe file name for use within cmd line of gs (unknown shell: space, ...) -# and pdfTeX (hash, curly braces, ...) +# and XeTeX (hash, curly braces, ...) my $inputfilesafe = $inputfile; -if ($inputfile =~ /[\s\$~'"#{}]/) { +if (not $inputfile =~ /^[\w\d\.\-\:\/@]+$/) { # /[\s\$~'"#{}%]/ $inputfilesafe = "$tmp-img.pdf"; push @unlink_files, $inputfilesafe; my $symlink_exists = eval { symlink("", ""); 1 }; @@ -657,18 +661,51 @@ print TMP <<'END_TMP'; \catcode60 12 % less \catcode61 12 % equals \catcode62 12 % greater +\catcode64 12 % at \catcode91 12 % left square \catcode93 12 % right square \catcode96 12 % back tick \catcode123 1 % left curly brace \catcode125 2 % right curly brace +\catcode126 12 % tilde \catcode`\#=6 % \escapechar=92 % +\def\IfUndefined#1#2#3{% + \begingroup\expandafter\expandafter\expandafter\endgroup + \expandafter\ifx\csname#1\endcsname\relax + #2% + \else + #3% + \fi +} END_TMP -print TMP "\\def\\pdffile{$inputfilesafe}\n"; +my $pdffilehex = unpack 'H*', $inputfilesafe; +$pdffilehex = "\U$pdffilehex\E"; +print TMP "\\def\\pdffilehex{$pdffilehex}\n"; print TMP <<'END_TMP'; -\def\stripprefix#1>{} -\edef\pdffile{\expandafter\stripprefix\meaning\pdffile}% +\IfUndefined{pdfunescapehex}{% + \begingroup + \gdef\pdffile{}% + \def\do#1#2{% + \ifx\relax#2\relax + \ifx\relax#1\relax + \else + \errmessage{Invalid hex string, should not happen!}% + \fi + \else + \lccode`0="#1#2\relax + \lowercase{% + \xdef\pdffile{\pdffile0}% + }% + \expandafter\do + \fi + }% + \expandafter\do\pdffilehex\relax\relax + \endgroup +}{% + \edef\pdffile{\pdfunescapehex{\pdffilehex}}% +} +\immediate\write-1{Input file: \pdffile} END_TMP if ($::opt_tex eq 'luatex') { print TMP <<'END_TMP'; @@ -729,14 +766,6 @@ if ($::opt_tex eq 'pdftex' or $::opt_tex eq 'luatex') { \pdfoutput=1 % \pdfcompresslevel=9 % \csname pdfmapfile\endcsname{} -\def\IfUndefined#1#2#3{% - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname#1\endcsname\relax - #2% - \else - #3% - \fi -} \def\setpdfversion#1{% \IfUndefined{pdfobjcompresslevel}{% }{% -- cgit v1.2.3