Skip to content

Commit

Permalink
Bug fix: xetex --output-driver (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
edocevoli committed Sep 8, 2017
1 parent 7458677 commit 2e88d52
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
28 changes: 14 additions & 14 deletions Programs/TeXAndFriends/xetex/source/XeTeX_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ const uint32_t byteMark = 0x00000080UL;
/* if the user specifies a paper size or output driver program */
const char *papersize;
#if defined(MIKTEX)
const char* outputdriver = MIKTEX_DVIPDFMX_EXE;
const std::vector<std::string> outputdriverargs = {
std::string dvipdfmxExecutable = MIKTEX_DVIPDFMX_EXE;
std::vector<std::string> dvipdfmxArgs = {
"-q",
"-E"
};
std::unique_ptr<MiKTeX::Core::Process> outputdriverprocess;
std::unique_ptr<MiKTeX::Core::Process> dvipdfmxProcess;
#else
const char *outputdriver = "xdvipdfmx -q -E"; /* default to portable xdvipdfmx driver */
#endif
Expand Down Expand Up @@ -2706,14 +2706,14 @@ boolean open_dvi_output(C4P::FileRoot& dviFile)
}
else
{
MiKTeX::Core::PathName xdvipdfmx;
if (!session->FindFile(outputdriver, MiKTeX::Core::FileType::EXE, xdvipdfmx))
MiKTeX::Core::PathName dvipdfmx;
if (!session->FindFile(dvipdfmxExecutable, MiKTeX::Core::FileType::EXE, dvipdfmx))
{
return 0;
}
MiKTeX::Core::ProcessStartInfo processStartInfo;
processStartInfo.FileName = xdvipdfmx.ToString();
processStartInfo.Arguments.push_back(outputdriver);
processStartInfo.FileName = dvipdfmx.ToString();
processStartInfo.Arguments.push_back(dvipdfmxExecutable);
switch (MiKTeX::App::Application::GetApplication()->GetEnableInstaller())
{
case MiKTeX::Core::TriState::False:
Expand All @@ -2723,7 +2723,7 @@ boolean open_dvi_output(C4P::FileRoot& dviFile)
processStartInfo.Arguments.push_back("--miktex-enable-installer");
break;
}
processStartInfo.Arguments.insert(processStartInfo.Arguments.end(), outputdriverargs.begin(), outputdriverargs.end());
processStartInfo.Arguments.insert(processStartInfo.Arguments.end(), dvipdfmxArgs.begin(), dvipdfmxArgs.end());
MiKTeX::Core::PathName outPath = MiKTeX::TeXAndFriends::WebAppInputLine::GetWebAppInputLine()->GetOutputDirectory() / MiKTeX::TeXAndFriends::WebAppInputLine::GetWebAppInputLine()->GetNameOfFile();
processStartInfo.Arguments.push_back("-o");
processStartInfo.Arguments.push_back(outPath.ToString());
Expand All @@ -2733,8 +2733,8 @@ boolean open_dvi_output(C4P::FileRoot& dviFile)
processStartInfo.Arguments.push_back(papersize);
}
processStartInfo.RedirectStandardInput = true;
outputdriverprocess = MiKTeX::Core::Process::Start(processStartInfo);
dviFile.Attach(outputdriverprocess->get_StandardInput(), true);
dvipdfmxProcess = MiKTeX::Core::Process::Start(processStartInfo);
dviFile.Attach(dvipdfmxProcess->get_StandardInput(), true);
MiKTeX::TeXAndFriends::WebAppInputLine::GetWebAppInputLine()->SetNameOfFile(outPath.GetData());
return 1;
}
Expand Down Expand Up @@ -2852,10 +2852,10 @@ int dviclose(C4P::FileRoot& dviFile)
{
fclose(dviFile);
dviFile.Attach(nullptr, true);
outputdriverprocess->WaitForExit();
int ret = outputdriverprocess->get_ExitCode();
outputdriverprocess->Close();
outputdriverprocess = nullptr;
dvipdfmxProcess->WaitForExit();
int ret = dvipdfmxProcess->get_ExitCode();
dvipdfmxProcess->Close();
dvipdfmxProcess = nullptr;
return ret;
}
}
Expand Down
5 changes: 5 additions & 0 deletions Programs/TeXAndFriends/xetex/source/XeTeX_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,12 @@ extern const uint32_t byteMask;
extern const uint32_t byteMark;

extern const char *papersize;
#if defined(MIKTEX)
extern std::string dvipdfmxExecutable;
extern std::vector<std::string> dvipdfmxArgs;
#else
extern const char *outputdriver;
#endif

/* gFreeTypeLibrary is defined in XeTeXFontInst_FT2.cpp,
* also used in XeTeXFontMgr_FC.cpp and XeTeX_ext.c. */
Expand Down
17 changes: 15 additions & 2 deletions Programs/TeXAndFriends/xetex/xetex-miktex.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,22 @@ class XETEXAPPCLASS :
XETEXPROG.nopdfoutput = true;
break;
case OPT_OUTPUT_DRIVER:
extern const char* outputdriver;
outputdriver = strdup(optArg.c_str());
{
extern std::string dvipdfmxExecutable;
extern std::vector<std::string> dvipdfmxArgs;
MiKTeX::Core::Argv argv(optArg);
if (argv.GetArgc() == 0)
{
MIKTEX_FATAL_ERROR("--output-driver requires a value");
}
dvipdfmxExecutable = argv[0];
dvipdfmxArgs.clear();
for (int idx = 1; idx < argv.GetArgc(); ++idx)
{
dvipdfmxArgs.push_back(argv[idx]);
}
break;
}
case OPT_PAPERSIZE:
extern const char* papersize;
papersize = strdup(optArg.c_str());
Expand Down
2 changes: 1 addition & 1 deletion Programs/TeXAndFriends/xetex/xetex-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "xetex_version.h"

#define MIKTEX_COMP_J2000_VERSION 6429
#define MIKTEX_COMP_J2000_VERSION 6460

#define MIKTEX_COMP_ORIG_VERSION_STR XETEX_VERSION

Expand Down

0 comments on commit 2e88d52

Please sign in to comment.