Skip to content

Commit

Permalink
Possibility to use gswin64c on Windows
Browse files Browse the repository at this point in the history
On windows the 32 bit executable is called gswin32c, but for the 64-bit systems also a gswin64c exists.
The path is checked for the existing of these executables (with a preference for the 32 bit version).
  • Loading branch information
albert-github committed Jan 7, 2020
1 parent f8c32f9 commit b96dc0f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doc/install.doc
Expand Up @@ -251,7 +251,7 @@ Ghostscript can be <a href="https://sourceforge.net/projects/ghostscript/">downl
from Sourceforge.

After installing \LaTeX and Ghostscript you'll need to make sure the tools
latex.exe, pdflatex.exe, and gswin32c.exe are present in the search path of a
latex.exe, pdflatex.exe, and gswin32c.exe (or gswin64c.exe) are present in the search path of a
command box. Follow <a href="https://www.computerhope.com/issues/ch000549.htm">these</a>
instructions if you are unsure and run the commands from a command box to verify it works.

Expand Down
3 changes: 2 additions & 1 deletion src/latexgen.cpp
Expand Up @@ -421,7 +421,8 @@ static void writeMakeBat()
t << mkidx_command << " refman.idx\n";
t << "%LATEX_CMD% refman.tex\n";
t << "dvips -o refman.ps refman.dvi\n";
t << "gswin32c -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "
t << Portable::ghostScriptCommand();
t << " -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "
"-sOutputFile=refman.pdf -c save pop -f refman.ps\n";
}
else // use pdflatex
Expand Down
51 changes: 50 additions & 1 deletion src/portable.cpp
Expand Up @@ -348,10 +348,59 @@ char Portable::pathListSeparator(void)
#endif
}

#if defined(_WIN32) && !defined(__CYGWIN__)
static const bool ExistsOnPath(const char *fileName)
{
QFileInfo fi1(fileName);
if (fi1.exists()) return true;

const char *p = Portable::getenv("PATH");
char listSep = Portable::pathListSeparator();
char pathSep = Portable::pathSeparator();
QCString paths(p);
int strt = 0;
int idx;
while ((idx = paths.find(listSep,strt)) != -1)
{
QCString locFile(paths.mid(strt,idx-strt));
locFile += pathSep;
locFile += fileName;
QFileInfo fi(locFile);
if (fi.exists()) return true;
strt = idx + 1;
}
// to be sure the last path component is checked as well
QCString locFile(paths.mid(strt));
if (!locFile.isEmpty())
{
locFile += pathSep;
locFile += fileName;
QFileInfo fi(locFile);
if (fi.exists()) return true;
}
return false;
}
#endif

const char *Portable::ghostScriptCommand(void)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
return "gswin32c.exe";
static char *gsexe = NULL;
if (!gsexe)
{
char *gsExec[] = {"gswin32c.exe","gswin64c.exe"};
for (int i = 0; i < sizeof(gsExec) / sizeof(*gsExec); i++)
{
if (ExistsOnPath(gsExec[i]))
{
gsexe = gsExec[i];
return gsexe;
}
}
gsexe = gsExec[0];
return gsexe;
}
return gsexe;
#else
return "gs";
#endif
Expand Down

0 comments on commit b96dc0f

Please sign in to comment.