X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2FSystemcall.cpp;h=bc7790adb17cdd8f8dbd4f123836e6bb5610a09d;hb=f8cc30a1f20de97425d17fc1779041d0f963f74a;hp=5713294055d9a9fe0a56977e12c8c98137ac7c3f;hpb=826298831ddc8c4dd094065b9c09802694724220;p=lyx.git diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp index 5713294055..bc7790adb1 100644 --- a/src/support/Systemcall.cpp +++ b/src/support/Systemcall.cpp @@ -14,6 +14,7 @@ #include #include "support/debug.h" +#include "support/filetools.h" #include "support/lstrings.h" #include "support/qstring_helpers.h" #include "support/Systemcall.h" @@ -21,6 +22,7 @@ #include "support/os.h" #include "support/ProgressInterface.h" +#include "LyXRC.h" #include #include @@ -96,9 +98,15 @@ ProgressInterface* ProgressInterface::instance() // Reuse of instance #ifndef USE_QPROCESS int Systemcall::startscript(Starttype how, string const & what, - bool /*process_events*/) + std::string const & path, bool /*process_events*/) { - string command = what; + 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()) { @@ -109,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()); } @@ -158,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; + + if (prefixIs(inputcmd, python_call)) { + cmd = os::python(); + start = python_call.length(); + } - for (size_t i = 0; i < inputcmd.length(); ++i) { + for (size_t i = start; i < inputcmd.length(); ++i) { char c = inputcmd[i]; if (c == '\'') { if (in_double_quote || escaped) { @@ -204,15 +220,16 @@ string const parsecmd(string const & inputcmd, string & outfile) -int Systemcall::startscript(Starttype how, string const & what, bool process_events) +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); - d.startProcess(cmd); + d.startProcess(cmd, path); if (!d.waitWhile(SystemcallPrivate::Starting, process_events, -1)) { LYXERR0("Systemcall: '" << cmd << "' did not start!"); LYXERR0("error " << d.errorMessage()); @@ -225,8 +242,8 @@ int Systemcall::startscript(Starttype how, string const & what, bool process_eve return 0; } - int timeout_min = 30; - if (!d.waitWhile(SystemcallPrivate::Running, process_events, timeout_min * 60 * 1000)) { + if (!d.waitWhile(SystemcallPrivate::Running, process_events, + os::timeout_min() * 60 * 1000)) { LYXERR0("Systemcall: '" << cmd << "' did not finish!"); LYXERR0("error " << d.errorMessage()); LYXERR0("status " << d.exitStatusMessage()); @@ -252,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())); @@ -263,13 +280,12 @@ SystemcallPrivate::SystemcallPrivate(const std::string& of) : } - -void SystemcallPrivate::startProcess(const QString& cmd) +void SystemcallPrivate::startProcess(QString const & cmd, string const & path) { cmd_ = cmd; if (process_) { state = SystemcallPrivate::Starting; - process_->start(cmd_); + process_->start(toqstr(latexEnvCmdPrefix(path)) + cmd_); } }