diff --git a/boost_1_61_0/boost/iostreams/detail/system_failure.hpp b/boost_1_61_0/boost/iostreams/detail/system_failure.hpp index 7d86eaf..e658016 100644 --- a/boost_1_61_0/boost/iostreams/detail/system_failure.hpp +++ b/boost_1_61_0/boost/iostreams/detail/system_failure.hpp @@ -21,6 +21,7 @@ #include #include #include // failure. +#include #if defined(BOOST_NO_STDC_NAMESPACE) && !defined(__LIBCOMO__) namespace std { using ::strlen; } @@ -39,34 +40,18 @@ inline BOOST_IOSTREAMS_FAILURE system_failure(const char* msg) { std::string result; + result += msg; #ifdef BOOST_IOSTREAMS_WINDOWS DWORD err; - LPVOID lpMsgBuf; - if ( (err = ::GetLastError()) != NO_ERROR && - ::FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPSTR) &lpMsgBuf, - 0, - NULL ) != 0 ) - { - result.reserve(std::strlen(msg) + 2 + std::strlen((LPSTR)lpMsgBuf)); - result.append(msg); - result.append(": "); - result.append((LPSTR) lpMsgBuf); - ::LocalFree(lpMsgBuf); - } else { - result += msg; - } + if ( (err = ::GetLastError()) != NO_ERROR ) #else - const char* system_msg = errno ? strerror(errno) : ""; - result.reserve(std::strlen(msg) + 2 + std::strlen(system_msg)); - result.append(msg); - result.append(": "); - result.append(system_msg); -#endif + int err = errno; + if ( err ) +#endif + { + result.append(": "); + result.append(boost::system::get_system_category().message(err)); + } return BOOST_IOSTREAMS_FAILURE(result); } diff --git a/boost_1_61_0/boost/system/detail/error_code.ipp b/boost_1_61_0/boost/system/detail/error_code.ipp index 71c60f6..64b4451 100644 --- a/boost_1_61_0/boost/system/detail/error_code.ipp +++ b/boost_1_61_0/boost/system/detail/error_code.ipp @@ -368,7 +368,7 @@ std::string system_error_category::message( int ev ) const { -#if defined(UNDER_CE) || BOOST_PLAT_WINDOWS_RUNTIME || defined(BOOST_NO_ANSI_APIS) +#if defined(UNDER_CE) || BOOST_PLAT_WINDOWS_RUNTIME || defined(BOOST_NO_ANSI_APIS) || defined(BOOST_WINDOWS_ERRORS_IN_UTF8) std::wstring buf(128, wchar_t()); for (;;) { @@ -398,9 +398,14 @@ } } +# ifdef BOOST_WINDOWS_ERRORS_IN_UTF8 + UINT cp = CP_UTF8; +# else + UINT cp = CP_ACP; +# endif int num_chars = (buf.size() + 1) * 2; LPSTR narrow_buffer = (LPSTR)_alloca( num_chars ); - if (::WideCharToMultiByte(CP_ACP, 0, buf.c_str(), -1, narrow_buffer, num_chars, NULL, NULL) == 0) + if (::WideCharToMultiByte(cp, 0, buf.c_str(), -1, narrow_buffer, num_chars, NULL, NULL) == 0) { return std::string("Unknown error"); }