X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2FSystemcall.cpp;h=bc7790adb17cdd8f8dbd4f123836e6bb5610a09d;hb=f8cc30a1f20de97425d17fc1779041d0f963f74a;hp=0753c590c8c0b5fe3b0454a6a5c2e1c9aa5a4f18;hpb=1717ef203cf08fd393e2b905a9ed7f9465c8f47d;p=lyx.git diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp index 0753c590c8..bc7790adb1 100644 --- a/src/support/Systemcall.cpp +++ b/src/support/Systemcall.cpp @@ -14,7 +14,6 @@ #include #include "support/debug.h" -#include "support/environment.h" #include "support/filetools.h" #include "support/lstrings.h" #include "support/qstring_helpers.h" @@ -101,24 +100,13 @@ ProgressInterface* ProgressInterface::instance() int Systemcall::startscript(Starttype how, string const & what, std::string const & path, bool /*process_events*/) { - string command; - string const texinputs = os::latex_path_list( - replaceCurdirPath(path, lyxrc.texinputs_prefix)); - string const sep = string(1, os::path_separator(os::TEXENGINE)); - string const env = getEnv("TEXINPUTS"); - - switch (os::shell()) { - case os::UNIX: - command = path.empty() || lyxrc.texinputs_prefix.empty() ? what - : "env TEXINPUTS='." + sep + texinputs - + sep + env + "' " + what; - break; - case os::CMD_EXE: - command = path.empty() || lyxrc.texinputs_prefix.empty() ? what - : "set TEXINPUTS=." + sep + texinputs - + sep + env + " & " + what; - break; - } + string const python_call = "python -tt"; + string command = to_filesystem8bit(from_utf8(latexEnvCmdPrefix(path))); + + if (prefixIs(what, python_call)) + command += os::python() + what.substr(python_call.length()); + else + command += what; if (how == DontWait) { switch (os::shell()) { @@ -129,7 +117,8 @@ int Systemcall::startscript(Starttype how, string const & what, command = "start /min " + command; break; } - } + } else if (os::shell() == os::CMD_EXE) + command = subst(command, "cmd /d /c ", ""); return ::system(command.c_str()); } @@ -178,9 +167,16 @@ string const parsecmd(string const & inputcmd, string & outfile) bool in_single_quote = false; bool in_double_quote = false; bool escaped = false; + string const python_call = "python -tt"; string cmd; + int start = 0; - for (size_t i = 0; i < inputcmd.length(); ++i) { + if (prefixIs(inputcmd, python_call)) { + cmd = os::python(); + start = python_call.length(); + } + + for (size_t i = start; i < inputcmd.length(); ++i) { char c = inputcmd[i]; if (c == '\'') { if (in_double_quote || escaped) { @@ -228,7 +224,7 @@ int Systemcall::startscript(Starttype how, string const & what, string const & path, bool process_events) { string outfile; - QString cmd = toqstr(parsecmd(what, outfile)); + QString cmd = QString::fromLocal8Bit(parsecmd(what, outfile).c_str()); SystemcallPrivate d(outfile); @@ -273,7 +269,7 @@ SystemcallPrivate::SystemcallPrivate(const std::string& of) : if (!out_file_.empty()) { // Check whether we have to simply throw away the output. if (out_file_ != os::nulldev()) - process_->setStandardOutputFile(toqstr(out_file_)); + process_->setStandardOutputFile(QString::fromLocal8Bit(out_file_.c_str())); } connect(process_, SIGNAL(readyReadStandardOutput()), SLOT(stdOut())); @@ -284,27 +280,12 @@ SystemcallPrivate::SystemcallPrivate(const std::string& of) : } - void SystemcallPrivate::startProcess(QString const & cmd, string const & path) { cmd_ = cmd; if (process_) { - if (!path.empty() && !lyxrc.texinputs_prefix.empty()) { - QString const texinputs = toqstr(os::latex_path_list( - replaceCurdirPath(path, lyxrc.texinputs_prefix))); - QChar const sep = os::path_separator(os::TEXENGINE); - QString const prefix = QLatin1String("TEXINPUTS=.") - + sep + texinputs + sep; - QStringList env = QProcess::systemEnvironment(); - if (env.filter("TEXINPUTS=").isEmpty()) - env << prefix; - else - env.replaceInStrings(QRegExp("^TEXINPUTS=(.*)"), - prefix + "\\1"); - process_->setEnvironment(env); - } state = SystemcallPrivate::Starting; - process_->start(cmd_); + process_->start(toqstr(latexEnvCmdPrefix(path)) + cmd_); } }