Merge branch 'utf-1702'

This commit is contained in:
Robert Schumacher 2017-08-29 18:58:01 -07:00
commit e0a9cae928
2 changed files with 15 additions and 8 deletions

View File

@ -264,7 +264,14 @@ namespace vcpkg
const std::wstring cmd = System::create_powershell_script_cmd(script);
System::ExitCodeAndOutput ec_data = System::cmd_execute_and_capture_output(cmd);
Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Could not run script to detect VS 2017 instances");
return Strings::split(ec_data.output, "\n");
return Util::fmap(Strings::split(ec_data.output, "\n"), [](const std::string& line) {
auto colon_pos = line.find(':');
if (colon_pos != std::string::npos && colon_pos > 0)
{
return line.substr(colon_pos - 1);
}
return line;
});
}
static Optional<fs::path> get_VS2015_installation_instance()

View File

@ -184,24 +184,24 @@ namespace vcpkg::System
const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s 2>&1")###", cmd_line);
Debug::println("_wpopen(%s)", Strings::to_utf8(actual_cmd_line));
std::string output;
char buf[1024];
std::wstring output;
wchar_t buf[1024];
auto pipe = _wpopen(actual_cmd_line.c_str(), L"r");
if (pipe == nullptr)
{
return {1, output};
return {1, Strings::to_utf8(output)};
}
while (fgets(buf, 1024, pipe))
while (fgetws(buf, 1024, pipe))
{
output.append(buf);
}
if (!feof(pipe))
{
return {1, output};
return {1, Strings::to_utf8(output)};
}
auto ec = _pclose(pipe);
Debug::println("_wpopen() returned %d", ec);
return {ec, output};
Debug::println("_pclose() returned %d", ec);
return {ec, Strings::to_utf8(output)};
}
std::wstring create_powershell_script_cmd(const fs::path& script_path, const CWStringView args)