diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-03-04 06:10:59 -0800 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-03-04 06:11:24 -0800 |
| commit | 4806aaf460465b972ad1b6203ca744431b296ade (patch) | |
| tree | df37ae1893d3bd40b1680d9bf831c170a08e212b /toolsrc/src | |
| parent | c055def45369d89c3b3fca3e57b57a9547d3b6a6 (diff) | |
| download | vcpkg-4806aaf460465b972ad1b6203ca744431b296ade.tar.gz vcpkg-4806aaf460465b972ad1b6203ca744431b296ade.zip | |
[vcpkg] Remove more uses of iostreams. Force 'C' locale -- localization is TODO.
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/vcpkg.cpp | 32 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Strings.cpp | 14 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_System.cpp | 8 |
3 files changed, 31 insertions, 23 deletions
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index f40126ecf..a263be8bc 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -180,9 +180,6 @@ int wmain(const int argc, const wchar_t* const* const argv) if (argc == 0) std::abort(); - std::cout.sync_with_stdio(false); - std::cout.imbue(std::locale::classic()); - g_timer.start(); atexit([]() { @@ -231,17 +228,22 @@ int wmain(const int argc, const wchar_t* const* const argv) exc_msg = "unknown error(...)"; } TrackProperty("error", exc_msg); - std::cerr - << "vcpkg.exe has crashed.\n" - << "Please send an email to:\n" - << " " << Commands::Contact::email() << "\n" - << "containing a brief summary of what you were trying to do and the following data blob:\n" - << "\n" - << "Version=" << Commands::Version::version() << "\n" - << "EXCEPTION='" << exc_msg << "'\n" - << "CMD=\n"; + + fflush(stdout); + System::print( + "vcpkg.exe has crashed.\n" + "Please send an email to:\n" + " %s\n" + "containing a brief summary of what you were trying to do and the following data blob:\n" + "\n" + "Version=%s\n" + "EXCEPTION='%s'\n" + "CMD=\n", + Commands::Contact::email(), + Commands::Version::version(), + exc_msg); + fflush(stdout); for (int x = 0; x < argc; ++x) - std::cerr << Strings::utf16_to_utf8(argv[x]) << "|\n"; - std::cerr - << "\n"; + System::println("%s|", Strings::utf16_to_utf8(argv[x])); + fflush(stdout); } diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp index 35ebcc90f..a7805f211 100644 --- a/toolsrc/src/vcpkg_Strings.cpp +++ b/toolsrc/src/vcpkg_Strings.cpp @@ -15,14 +15,20 @@ namespace vcpkg::Strings::details return static_cast<char>(std::tolower(c)); } + static _locale_t& c_locale() + { + static _locale_t c_locale_impl = _create_locale(LC_ALL, "C"); + return c_locale_impl; + } + std::string format_internal(const char* fmtstr, ...) { va_list lst; va_start(lst, fmtstr); - const int sz = _vscprintf(fmtstr, lst); + const int sz = _vscprintf_l(fmtstr, c_locale(), lst); std::string output(sz, '\0'); - _vsnprintf_s(&output[0], output.size() + 1, output.size() + 1, fmtstr, lst); + _vsnprintf_s_l(&output[0], output.size() + 1, output.size() + 1, fmtstr, c_locale(), lst); va_end(lst); return output; @@ -33,9 +39,9 @@ namespace vcpkg::Strings::details va_list lst; va_start(lst, fmtstr); - const int sz = _vscwprintf(fmtstr, lst); + const int sz = _vscwprintf_l(fmtstr, c_locale(), lst); std::wstring output(sz, '\0'); - _vsnwprintf_s(&output[0], output.size() + 1, output.size() + 1, fmtstr, lst); + _vsnwprintf_s_l(&output[0], output.size() + 1, output.size() + 1, fmtstr, c_locale(), lst); va_end(lst); return output; diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index 2b37da685..9c849e8d8 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -14,8 +14,8 @@ namespace vcpkg::System int cmd_execute(const wchar_t* cmd_line) { - // Flush cout before launching external process - std::cout << std::flush; + // Flush stdout before launching external process + fflush(stdout); // Basically we are wrapping it in quotes const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line); @@ -25,8 +25,8 @@ namespace vcpkg::System exit_code_and_output cmd_execute_and_capture_output(const wchar_t* cmd_line) { - // Flush cout before launching external process - std::cout << std::flush; + // Flush stdout before launching external process + fflush(stdout); const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line); |
