From 38b49bc2124f5a7d5a064c3242867213d6b6d57e Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 29 Apr 2024 20:32:23 +0000 Subject: epstopdf (29apr24) git-svn-id: svn://tug.org/texlive/trunk@71134 c570f23f-e606-0410-a88d-b1316a301751 --- .../texlive/linked_scripts/epstopdf/epstopdf.pl | 193 +++++++++++++++------ Master/texmf-dist/doc/man/man1/epstopdf.1 | 22 +-- Master/texmf-dist/doc/man/man1/epstopdf.man1.pdf | Bin 28960 -> 29695 bytes Master/texmf-dist/doc/man/man1/repstopdf.man1.pdf | Bin 28960 -> 29695 bytes Master/texmf-dist/doc/support/epstopdf/README | 8 +- Master/texmf-dist/scripts/epstopdf/epstopdf.pl | 193 +++++++++++++++------ 6 files changed, 302 insertions(+), 114 deletions(-) diff --git a/Build/source/texk/texlive/linked_scripts/epstopdf/epstopdf.pl b/Build/source/texk/texlive/linked_scripts/epstopdf/epstopdf.pl index 6409ea2398d..df768ef815b 100755 --- a/Build/source/texk/texlive/linked_scripts/epstopdf/epstopdf.pl +++ b/Build/source/texk/texlive/linked_scripts/epstopdf/epstopdf.pl @@ -1,5 +1,6 @@ #!/usr/bin/env perl -# $Id: epstopdf.pl 68289 2023-09-15 22:17:54Z karl $ +use warnings; +# $Id: epstopdf.pl 71121 2024-04-29 17:27:25Z karl $ # (Copyright lines below.) # # Redistribution and use in source and binary forms, with or without @@ -35,7 +36,29 @@ # # emacs-page # -my $ver = "2.33"; +my $ver = "2.34"; +# 2024/04/29 2.34 (Karl Berry) +# * if --debug is first argument, give more output. +# * do not check for kpsewhich in PATH unless restricted. +# * minor wording and doc changes. +# 2024/04/14 (John Collins) +# * use warnings. +# * Msys PATH separator is :. +# * Do immediate decomposition of path to array on startup, and use array +# instead of separate uses of split. +# * On Windows, Msys and Cygwin, normalize directory separator to /. +# * Detect invocation via Windows TL (and epstopdf.exe wrapper script) by +# presence of TL's private gs in PATH: a directory ending in /tlgs/bin. +# In this case, change behavior under Cygwin to be like that of Windows +# instead of Unix. +# * On Cygwin and Msys, put temporary file in current directory instead of +# default, which is normally /tmp. That's so that the pathname to the +# temporary file remains valid no matter which kind of gs it's passed to: +# native Windows, Msys or Cygwin. +# * Prettyprint PATH, one directory per line, in error about program +# not in PATH. +# Original report from Pablo Gonzalez L, +# https://tug.org/pipermail/tex-k/2024-April/004036.html # 2023/09/15 2.33 (Karl Berry) # * Cygwin PATH separator is :. Report from Alois Steindl, # https://tug.org/pipermail/tex-live/2023-September/049474.html @@ -203,9 +226,9 @@ my $ver = "2.33"; ### emacs-page ### program identification my $program = "epstopdf"; -my $ident = '($Id: epstopdf.pl 68289 2023-09-15 22:17:54Z karl $)' . " $ver"; +my $ident = '($Id: epstopdf.pl 71121 2024-04-29 17:27:25Z karl $)' . " $ver"; my $copyright = < @@ -214,18 +237,98 @@ There is NO WARRANTY, to the extent permitted by law. END_COPYRIGHT my $title = "$program $ident\n"; -my $on_windows = $^O =~ /^(MSWin|msys$)/; -my $on_windows_or_cygwin = $on_windows || $^O eq "cygwin"; +### message functions. +sub debug { print STDERR "* @_\n" if $::opt_debug; } +sub warning { print STDERR "==> Warning: @_\n"; } +sub error { die "$title!!! Error: @_\n"; } +sub errorUsage { die "$program: Error: @_ (try --help for more information)\n"; } +sub warnerr { $restricted ? error(@_) : warning(@_); } + +# Check specially for --debug or -d (exactly) as first argument, so we can +# generate debugging output during initialization. +$::opt_debug = 1 if @ARGV && ($ARGV[0] eq "--debug" || $ARGV[0] eq "-d"); + +# Different Windows cases. +my $on_cygwin = ($^O eq 'cygwin'); +my $on_msys = ($^O eq 'msys'); +my $on_windows = ($^O =~ /^MSWin/) || $on_msys; +my $on_windows_or_cygwin = $on_windows || $on_cygwin; +debug "on_windows=$on_windows, on_windows_or_cygwin=$on_windows_or_cygwin"; +debug " on_cygwin=$on_cygwin, on_msys=$on_msys"; + +# Split PATH and use / as directory separator. +# +my $path_sep = ( ($^O =~ /^MSWin/) ? ';' : ':' ); # not msys +my @pdirs = split($path_sep, $ENV{"PATH"}); +# Normalize directory separators to /. Always valid on Windows. +if ($on_windows_or_cygwin) { + foreach (@pdirs) { s !\\!/!g; } +} +debug "Normalized PATH to: @pdirs"; -### ghostscript command name -my $GS = "gs"; -if ($on_windows) { +# Default values for commands. +# Ghostscript, which is always needed. +my $GS = 'gs'; +# Kpsewhich, only used in restricted mode. +my $kpsewhich = 'kpsewhich'; + +# Determine if we were invoked from a standard Windows TL installation via the +# wrapper script epstopdf.exe: +my $TL_Windows_bin = undef; +my $TL_tlgs = undef; +if ($on_windows_or_cygwin) { + debug "Looking for symptoms of Windows TL gs and wrapper .exe:"; + for (@pdirs) { + if (m!^(.+)/tlpkg/tlgs/bin$!) { + debug "Found Windows tlgs item '$_' in PATH"; + # We were probably invoked via runscript by .exe file in native TL + # Windows, since then a tlgs/bin item is inserted in PATH, + # so that Windows TL's private installation of gs, with its executables + # gswin64c.exe and/or gswin32c.exe gets used. + # Anything else giving the same symptom is surely a deliberate + # configuration to imitate that the TL Windows behavior. + my $TL_root = $1; + $TL_tlgs = $_; + $TL_Windows_bin = "$TL_root/bin/windows"; + last; + } + } + if ($TL_tlgs) { + # Confirm by existence of expected directories and files. + # If those do not exist, we don't have a standard native + # Windows TL installation. + if (-x "$TL_Windows_bin/kpsewhich.exe" + && (-x "$TL_tlgs/gswin64c.exe" || -x "$TL_tlgs/gswin32c.exe") + ) { + # The needed files exist. + # The runscript wrapper ensures that the tlgs and the binary directory + # of its own installation are in PATH ahead of any directories that + # may contain other versions. + } + else { + warning(<test.pdf @@ -433,8 +538,8 @@ Example for using HiResBoundingBox instead of BoundingBox: Example for producing epstopdf's attempt at corrected PostScript: \$ $program --nogs test.ps >testcorr.ps -In all cases, you can add --debug (-d) to see more about what epstopdf -is doing. +In all cases, you can use --debug to see more about what epstopdf +is doing. For maximum output, use --debug as the first option. More about the options for Ghostscript: Additional options to be used with gs can be specified @@ -456,7 +561,7 @@ When reporting bugs, please include an input file and all command line options so the problem can be reproduced. Report bugs to: tex-k\@tug.org -epstopdf home page: +epstopdf home page: END_OF_USAGE ### process options @@ -491,30 +596,9 @@ $::opt_quiet = 0 if $::opt_debug; ### restricted option $restricted = 1 if $::opt_restricted; -### help functions -sub debug { print STDERR "* @_\n" if $::opt_debug; } -sub warning { print STDERR "==> Warning: @_\n"; } -sub error { die "$title!!! Error: @_\n"; } -sub errorUsage { die "$program: Error: @_ (try --help for more information)\n"; } -sub warnerr { $restricted ? error(@_) : warning(@_); } - ### debug messages -debug "on_windows=$on_windows, on_windows_or_cygwin=$on_windows_or_cygwin"; debug "Restricted mode activated" if $restricted; -### safer external commands for Windows in restricted mode -my $kpsewhich = 'kpsewhich'; -if ($restricted && $on_windows) { - use File::Basename; - my $mydirname = dirname $0; - # $mydirname is the location of the Perl script - $kpsewhich = "$mydirname/../../../bin/windows/$kpsewhich"; - debug "Restricted Windows kpsewhich: $kpsewhich"; - $GS = "$mydirname/../../../tlpkg/tlgs/bin/$GS"; - debug "Restricted Windows gs: $GS"; -} -debug "kpsewhich command: $kpsewhich"; - ### check that PROG is in PATH and executable, abort if not. It'd be # better to actually try running the program, but then we'd have to # either replicate Perl's logic for finding the command interpreter @@ -528,11 +612,10 @@ sub check_prog_exists { my ($prog) = @_; my @w_ext = ("exe", "com", "bat"); debug " Checking if $prog is in PATH"; - # absolute unix if (! $on_windows_or_cygwin && $prog =~ m,^((\.(\.)?)?/),) { return 1 if -x $prog; # absolute or explicitly relative - error "Required program $prog not found, given explicit directory"; + error "Required program $prog not found, given with explicit directory"; # absolute windows: optional drive letter, then . or .., then \ or /. } elsif ($on_windows_or_cygwin @@ -545,9 +628,9 @@ sub check_prog_exists { } # not absolute, check path - for my $dir (split ($on_windows ? ";" : ":", $ENV{"PATH"})) { + for my $dir (@pdirs) { $dir = "." if $dir eq ""; # empty path element - debug " Checking dir $dir"; + debug " Checking dir $dir"; if (-x "$dir/$prog") { return 1; } elsif ($on_windows_or_cygwin) { @@ -558,12 +641,15 @@ sub check_prog_exists { } # if made it through the whole loop, not found, so quit. - error "Required program $prog not found in PATH ($ENV{PATH})"; + my @path_pretty = (); + for (@pdirs) { push @path_pretty, " '$_'\n"; } + error "Required program $prog not found in PATH, which contains:\n", + @path_pretty; } -check_prog_exists ($kpsewhich); +check_prog_exists ($kpsewhich) if $restricted; # only needed if restricted ### check if a name is "safe" according to kpse's open(in|out)_any -# return true if name is ok, false otherwise +# return true if name is ok, false if not. sub safe_name { my ($mode, $name) = @_; my $option = ""; @@ -806,8 +892,15 @@ if ($::opt_gs) { debug "Ghostscript pipe: @GS"; open($OUT, '|-', @GS) or error "Cannot open Ghostscript for piped input: @GS"; - } else { # use a temporary file on Windows/Cygwin. - ($OUT, $tmp_filename) = tempfile(UNLINK => 1); + } else { + # use a temporary file on Windows/msys/Cygwin. + if ($on_cygwin || $on_msys) { + # Use current directory for temporary file, to avoid problems of + # translation of directory name if native Windows gs gets invoked. + ($OUT, $tmp_filename) = tempfile(UNLINK => 1, DIR => '.'); + } else { + ($OUT, $tmp_filename) = tempfile(UNLINK => 1); + } debug "Using temporary file '$tmp_filename'"; } $outname = $GS; diff --git a/Master/texmf-dist/doc/man/man1/epstopdf.1 b/Master/texmf-dist/doc/man/man1/epstopdf.1 index 0062932c582..cf993d3133e 100644 --- a/Master/texmf-dist/doc/man/man1/epstopdf.1 +++ b/Master/texmf-dist/doc/man/man1/epstopdf.1 @@ -1,5 +1,5 @@ -.TH EPSTOPDF 1 "15 September 2023" -.\" $Id: epstopdf.1 68289 2023-09-15 22:17:54Z karl $ +.TH EPSTOPDF 1 "29 April 2024" +.\" $Id: epstopdf.1 71121 2024-04-29 17:27:25Z karl $ .SH NAME epstopdf, repstopdf \- convert an EPS file to PDF .SH SYNOPSIS @@ -30,7 +30,7 @@ produced by default.) PJL commands at the start of a file are removed. DOS EPS binary files (TN 5002) are supported. Seeking from a pipe is not supported. .PP -If the bounding box in the input is incorrect, of course there will +If the bounding box in the input is incorrect, inevitably there will be resulting problems. .SH OPTIONS Options may start with either "\fB-\fP" or "\fB--\fP", and may be @@ -48,7 +48,8 @@ write result to \fIfile\fP. If this option is not given, and otherwise, the default is to construct the output file name by replacing any extension in the input file with `.pdf'. .IP "\fB--\fP[\fBno\fP]\fBdebug\fP" -write debugging info (default: false). +write debugging info (default: false). For maximum output, use \fB--debug\fP +as the first option. .IP "\fB--\fP[\fBno\fP]\fBexact\fP" scan ExactBoundingBox (default: false). .IP "\fB--\fP[\fBno\fP]\fBfilter\fP" @@ -70,8 +71,8 @@ gs, installed under \fB.../tlpkg/tlgs/bin/\fP. .PP Options for Ghostscript (more info below): .IP "\fB--gscmd\fP=\fIval\fP" -pipe output to \fIval\fP (default: [\fBgswin64c\fP on 64-bit Windows, -\fBgswin32c\fP on 32-bit Windows, else \fBgs\fP]) +pipe output to \fIval\fP (default: [\fBgswin64c.exe\fP on 64-bit Windows, +\fBgswin32c.exe\fP on 32-bit Windows, else \fBgs\fP]) .IP "\fB--gsopt\fP=\fIval\fP" include \fIval\fP as one argument in the gs command (can be repeated). .IP "\fB--gsopts\fP=\fIval\fP" @@ -112,7 +113,7 @@ individually. .PP \fB--gsopt\fP adds its argument as a single option to the gs command line. It can be used multiple times to specify options separately. -This must be used if a gs option or its value contains whitespace. +This form must be used if a gs option or its value contains whitespace. .PP In restricted mode, options are limited to those with names and values known to be safe. Some options taking booleans, integers or fixed @@ -141,8 +142,9 @@ Example for \fBepstopdf\fP's attempt at correcting PostScript: epstopdf --nogs test.ps >testcorr.ps .fi .PP -In all cases, you can add \fB--debug\fP (\fB-d\fP) to see more about -what \fBepstopdf\fP is doing. +In all cases, you can add \fB--debug\fP to see more about +what \fBepstopdf\fP is doing. Use \fB--debug\fP as the first option for +maximum output. .SH BUGS The case of "%%BoundingBox: (atend)" when input is not seekable (e.g., from a pipe) is not supported. @@ -171,4 +173,4 @@ epstopdf home page: https://tug.org/epstopdf. You may freely use, modify and/or distribute this man page. The epstopdf script is released under the modified BSD license. .PP -$Id: epstopdf.1 68289 2023-09-15 22:17:54Z karl $ +$Id: epstopdf.1 71121 2024-04-29 17:27:25Z karl $ diff --git a/Master/texmf-dist/doc/man/man1/epstopdf.man1.pdf b/Master/texmf-dist/doc/man/man1/epstopdf.man1.pdf index fc58b8aae76..e64c46318ab 100644 Binary files a/Master/texmf-dist/doc/man/man1/epstopdf.man1.pdf and b/Master/texmf-dist/doc/man/man1/epstopdf.man1.pdf differ diff --git a/Master/texmf-dist/doc/man/man1/repstopdf.man1.pdf b/Master/texmf-dist/doc/man/man1/repstopdf.man1.pdf index fad57446b12..f5176ac06e9 100644 Binary files a/Master/texmf-dist/doc/man/man1/repstopdf.man1.pdf and b/Master/texmf-dist/doc/man/man1/repstopdf.man1.pdf differ diff --git a/Master/texmf-dist/doc/support/epstopdf/README b/Master/texmf-dist/doc/support/epstopdf/README index 619667865cf..56f02d32a14 100644 --- a/Master/texmf-dist/doc/support/epstopdf/README +++ b/Master/texmf-dist/doc/support/epstopdf/README @@ -1,12 +1,12 @@ -$Id: README 48727 2018-09-21 22:18:21Z karl $ +$Id: README 71121 2024-04-29 17:27:25Z karl $ This file is public domain. (Originally written by Karl Berry, 2009.) This is the README for the epstopdf script distribution. -Primary distribution point: http://ctan.org/pkg/epstopdf - (list of mirrors at: http://ctan.org/mirrors) +Primary distribution point: https://ctan.org/pkg/epstopdf + (list of mirrors at: https://ctan.org/mirrors) -Home page: http://tug.org/epstopdf/ +Home page: https://tug.org/epstopdf/ Run epstopdf --help for the usual list of options, examples, etc. diff --git a/Master/texmf-dist/scripts/epstopdf/epstopdf.pl b/Master/texmf-dist/scripts/epstopdf/epstopdf.pl index 6409ea2398d..df768ef815b 100755 --- a/Master/texmf-dist/scripts/epstopdf/epstopdf.pl +++ b/Master/texmf-dist/scripts/epstopdf/epstopdf.pl @@ -1,5 +1,6 @@ #!/usr/bin/env perl -# $Id: epstopdf.pl 68289 2023-09-15 22:17:54Z karl $ +use warnings; +# $Id: epstopdf.pl 71121 2024-04-29 17:27:25Z karl $ # (Copyright lines below.) # # Redistribution and use in source and binary forms, with or without @@ -35,7 +36,29 @@ # # emacs-page # -my $ver = "2.33"; +my $ver = "2.34"; +# 2024/04/29 2.34 (Karl Berry) +# * if --debug is first argument, give more output. +# * do not check for kpsewhich in PATH unless restricted. +# * minor wording and doc changes. +# 2024/04/14 (John Collins) +# * use warnings. +# * Msys PATH separator is :. +# * Do immediate decomposition of path to array on startup, and use array +# instead of separate uses of split. +# * On Windows, Msys and Cygwin, normalize directory separator to /. +# * Detect invocation via Windows TL (and epstopdf.exe wrapper script) by +# presence of TL's private gs in PATH: a directory ending in /tlgs/bin. +# In this case, change behavior under Cygwin to be like that of Windows +# instead of Unix. +# * On Cygwin and Msys, put temporary file in current directory instead of +# default, which is normally /tmp. That's so that the pathname to the +# temporary file remains valid no matter which kind of gs it's passed to: +# native Windows, Msys or Cygwin. +# * Prettyprint PATH, one directory per line, in error about program +# not in PATH. +# Original report from Pablo Gonzalez L, +# https://tug.org/pipermail/tex-k/2024-April/004036.html # 2023/09/15 2.33 (Karl Berry) # * Cygwin PATH separator is :. Report from Alois Steindl, # https://tug.org/pipermail/tex-live/2023-September/049474.html @@ -203,9 +226,9 @@ my $ver = "2.33"; ### emacs-page ### program identification my $program = "epstopdf"; -my $ident = '($Id: epstopdf.pl 68289 2023-09-15 22:17:54Z karl $)' . " $ver"; +my $ident = '($Id: epstopdf.pl 71121 2024-04-29 17:27:25Z karl $)' . " $ver"; my $copyright = < @@ -214,18 +237,98 @@ There is NO WARRANTY, to the extent permitted by law. END_COPYRIGHT my $title = "$program $ident\n"; -my $on_windows = $^O =~ /^(MSWin|msys$)/; -my $on_windows_or_cygwin = $on_windows || $^O eq "cygwin"; +### message functions. +sub debug { print STDERR "* @_\n" if $::opt_debug; } +sub warning { print STDERR "==> Warning: @_\n"; } +sub error { die "$title!!! Error: @_\n"; } +sub errorUsage { die "$program: Error: @_ (try --help for more information)\n"; } +sub warnerr { $restricted ? error(@_) : warning(@_); } + +# Check specially for --debug or -d (exactly) as first argument, so we can +# generate debugging output during initialization. +$::opt_debug = 1 if @ARGV && ($ARGV[0] eq "--debug" || $ARGV[0] eq "-d"); + +# Different Windows cases. +my $on_cygwin = ($^O eq 'cygwin'); +my $on_msys = ($^O eq 'msys'); +my $on_windows = ($^O =~ /^MSWin/) || $on_msys; +my $on_windows_or_cygwin = $on_windows || $on_cygwin; +debug "on_windows=$on_windows, on_windows_or_cygwin=$on_windows_or_cygwin"; +debug " on_cygwin=$on_cygwin, on_msys=$on_msys"; + +# Split PATH and use / as directory separator. +# +my $path_sep = ( ($^O =~ /^MSWin/) ? ';' : ':' ); # not msys +my @pdirs = split($path_sep, $ENV{"PATH"}); +# Normalize directory separators to /. Always valid on Windows. +if ($on_windows_or_cygwin) { + foreach (@pdirs) { s !\\!/!g; } +} +debug "Normalized PATH to: @pdirs"; -### ghostscript command name -my $GS = "gs"; -if ($on_windows) { +# Default values for commands. +# Ghostscript, which is always needed. +my $GS = 'gs'; +# Kpsewhich, only used in restricted mode. +my $kpsewhich = 'kpsewhich'; + +# Determine if we were invoked from a standard Windows TL installation via the +# wrapper script epstopdf.exe: +my $TL_Windows_bin = undef; +my $TL_tlgs = undef; +if ($on_windows_or_cygwin) { + debug "Looking for symptoms of Windows TL gs and wrapper .exe:"; + for (@pdirs) { + if (m!^(.+)/tlpkg/tlgs/bin$!) { + debug "Found Windows tlgs item '$_' in PATH"; + # We were probably invoked via runscript by .exe file in native TL + # Windows, since then a tlgs/bin item is inserted in PATH, + # so that Windows TL's private installation of gs, with its executables + # gswin64c.exe and/or gswin32c.exe gets used. + # Anything else giving the same symptom is surely a deliberate + # configuration to imitate that the TL Windows behavior. + my $TL_root = $1; + $TL_tlgs = $_; + $TL_Windows_bin = "$TL_root/bin/windows"; + last; + } + } + if ($TL_tlgs) { + # Confirm by existence of expected directories and files. + # If those do not exist, we don't have a standard native + # Windows TL installation. + if (-x "$TL_Windows_bin/kpsewhich.exe" + && (-x "$TL_tlgs/gswin64c.exe" || -x "$TL_tlgs/gswin32c.exe") + ) { + # The needed files exist. + # The runscript wrapper ensures that the tlgs and the binary directory + # of its own installation are in PATH ahead of any directories that + # may contain other versions. + } + else { + warning(<test.pdf @@ -433,8 +538,8 @@ Example for using HiResBoundingBox instead of BoundingBox: Example for producing epstopdf's attempt at corrected PostScript: \$ $program --nogs test.ps >testcorr.ps -In all cases, you can add --debug (-d) to see more about what epstopdf -is doing. +In all cases, you can use --debug to see more about what epstopdf +is doing. For maximum output, use --debug as the first option. More about the options for Ghostscript: Additional options to be used with gs can be specified @@ -456,7 +561,7 @@ When reporting bugs, please include an input file and all command line options so the problem can be reproduced. Report bugs to: tex-k\@tug.org -epstopdf home page: +epstopdf home page: END_OF_USAGE ### process options @@ -491,30 +596,9 @@ $::opt_quiet = 0 if $::opt_debug; ### restricted option $restricted = 1 if $::opt_restricted; -### help functions -sub debug { print STDERR "* @_\n" if $::opt_debug; } -sub warning { print STDERR "==> Warning: @_\n"; } -sub error { die "$title!!! Error: @_\n"; } -sub errorUsage { die "$program: Error: @_ (try --help for more information)\n"; } -sub warnerr { $restricted ? error(@_) : warning(@_); } - ### debug messages -debug "on_windows=$on_windows, on_windows_or_cygwin=$on_windows_or_cygwin"; debug "Restricted mode activated" if $restricted; -### safer external commands for Windows in restricted mode -my $kpsewhich = 'kpsewhich'; -if ($restricted && $on_windows) { - use File::Basename; - my $mydirname = dirname $0; - # $mydirname is the location of the Perl script - $kpsewhich = "$mydirname/../../../bin/windows/$kpsewhich"; - debug "Restricted Windows kpsewhich: $kpsewhich"; - $GS = "$mydirname/../../../tlpkg/tlgs/bin/$GS"; - debug "Restricted Windows gs: $GS"; -} -debug "kpsewhich command: $kpsewhich"; - ### check that PROG is in PATH and executable, abort if not. It'd be # better to actually try running the program, but then we'd have to # either replicate Perl's logic for finding the command interpreter @@ -528,11 +612,10 @@ sub check_prog_exists { my ($prog) = @_; my @w_ext = ("exe", "com", "bat"); debug " Checking if $prog is in PATH"; - # absolute unix if (! $on_windows_or_cygwin && $prog =~ m,^((\.(\.)?)?/),) { return 1 if -x $prog; # absolute or explicitly relative - error "Required program $prog not found, given explicit directory"; + error "Required program $prog not found, given with explicit directory"; # absolute windows: optional drive letter, then . or .., then \ or /. } elsif ($on_windows_or_cygwin @@ -545,9 +628,9 @@ sub check_prog_exists { } # not absolute, check path - for my $dir (split ($on_windows ? ";" : ":", $ENV{"PATH"})) { + for my $dir (@pdirs) { $dir = "." if $dir eq ""; # empty path element - debug " Checking dir $dir"; + debug " Checking dir $dir"; if (-x "$dir/$prog") { return 1; } elsif ($on_windows_or_cygwin) { @@ -558,12 +641,15 @@ sub check_prog_exists { } # if made it through the whole loop, not found, so quit. - error "Required program $prog not found in PATH ($ENV{PATH})"; + my @path_pretty = (); + for (@pdirs) { push @path_pretty, " '$_'\n"; } + error "Required program $prog not found in PATH, which contains:\n", + @path_pretty; } -check_prog_exists ($kpsewhich); +check_prog_exists ($kpsewhich) if $restricted; # only needed if restricted ### check if a name is "safe" according to kpse's open(in|out)_any -# return true if name is ok, false otherwise +# return true if name is ok, false if not. sub safe_name { my ($mode, $name) = @_; my $option = ""; @@ -806,8 +892,15 @@ if ($::opt_gs) { debug "Ghostscript pipe: @GS"; open($OUT, '|-', @GS) or error "Cannot open Ghostscript for piped input: @GS"; - } else { # use a temporary file on Windows/Cygwin. - ($OUT, $tmp_filename) = tempfile(UNLINK => 1); + } else { + # use a temporary file on Windows/msys/Cygwin. + if ($on_cygwin || $on_msys) { + # Use current directory for temporary file, to avoid problems of + # translation of directory name if native Windows gs gets invoked. + ($OUT, $tmp_filename) = tempfile(UNLINK => 1, DIR => '.'); + } else { + ($OUT, $tmp_filename) = tempfile(UNLINK => 1); + } debug "Using temporary file '$tmp_filename'"; } $outname = $GS; -- cgit v1.2.3