diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 54cbfddbc..b6c2b00de 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -116,28 +116,43 @@ string findSerpent() bytes compileSerpent(string const& _code) { - static const string exec = findSerpent(); - if (exec.empty()) + static const string serpent = findSerpent(); + if (serpent.empty()) return bytes(); +#ifdef _WIN32 + vector args = vector({"python", serpent, "-b", "compile"}); + string exec = ""; +#else vector args = vector({"serpent_cli.py", "-b", "compile"}); + string exec = serpent; +#endif + context ctx; ctx.environment = self::get_environment(); ctx.stdin_behavior = capture_stream(); ctx.stdout_behavior = capture_stream(); - child c = launch(exec, args, ctx); - postream& os = c.get_stdin(); - pistream& is = c.get_stdout(); + try + { + child c = launch(exec, args, ctx); + postream& os = c.get_stdin(); + pistream& is = c.get_stdout(); - os << _code << "\n"; - os.close(); + os << _code << "\n"; + os.close(); - string hex; - int i; - while ((i = is.get()) != -1 && i != '\n') - hex.push_back(i); + string hex; + int i; + while ((i = is.get()) != -1 && i != '\r' && i != '\n') + hex.push_back(i); - return fromHex(hex); + return fromHex(hex); + } + catch (boost::system::system_error&) + { + cwarn << "Serpent compiler failed to launch."; + return bytes(); + } } Main::Main(QWidget *parent) : diff --git a/boost/process/detail/win32_ops.hpp b/boost/process/detail/win32_ops.hpp index ed81d7c3e..d84de9b71 100644 --- a/boost/process/detail/win32_ops.hpp +++ b/boost/process/detail/win32_ops.hpp @@ -342,7 +342,7 @@ inline PROCESS_INFORMATION win32_start(const Executable &exe, const Arguments &a boost::shared_array envstrs = environment_to_win32_strings(env); - if (!::CreateProcessA(executable.get(), cmdline.get(), NULL, NULL, TRUE, 0, envstrs.get(), workdir.get(), si.get(), &pi)) + if (!::CreateProcessA(executable.get()[0] ? executable.get() : NULL, cmdline.get(), NULL, NULL, TRUE, CREATE_NO_WINDOW, envstrs.get(), workdir.get(), si.get(), &pi)) boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::detail::win32_start: CreateProcess failed")); return pi;