doc/pspdf.pl: fix Ghostscript executable path construction on Windows

win32_gs_help() looks up Ghostscript's install directory (GS_LIB) from
the registry and then tries to locate gswin64c.exe/gswin32c.exe/gs.exe
in it, but used File::Spec->catpath($p, $exe) to build the candidate
path. catpath() takes three arguments (volume, directory, file); called
with only two, $exe is interpreted as the directory and the file
component is left undef, so the result is just $exe on its own --
never a path that actually exists -- meaning the registry-based lookup
silently always failed and pspdf.pl fell back to a bare 'gs' on PATH
(which choco's ghostscript package does not add). Use catfile($p, $exe)
instead, which is the correct call for joining a directory and a
filename. Confirmed via real MSVC CI that Ghostscript is now found
purely from the registry, matching doc/source.src's documented
requirement that Ghostscript need not be on PATH.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
H. Peter Anvin (Intel) 2026-07-07 15:09:13 -07:00
parent 8317d7ae2f
commit 6393f99455

View file

@ -78,7 +78,7 @@ sub win32_gs_help() {
foreach my $p (split(/\;/, $gs[0]->{'/GS_LIB'})) {
foreach my $exe ('gswin64c.exe', 'gswin32c.exe', 'gs.exe') {
last if (defined($gsp));
my $e = File::Spec->catpath($p, $exe);
my $e = File::Spec->catfile($p, $exe);
$gsp = $e if (-f $e && -x _);
}
}