Compare commits

..

2 Commits

Author SHA1 Message Date
Peter Dimov
ef7c34fc30 Remove use of _alloca 2019-02-26 17:22:58 +02:00
Peter Dimov
f726c068c3 Add UTF-8 tests 2019-02-26 16:42:47 +02:00
2 changed files with 47 additions and 26 deletions

View File

@@ -81,37 +81,54 @@ inline char const * system_category_message_win32( int ev, char * buffer, std::s
return buffer;
}
#if defined(__GNUC__)
# define BOOST_SYSTEM_ALLOCA __builtin_alloca
#else
# define BOOST_SYSTEM_ALLOCA _alloca
boost::winapi::UINT_ const code_page = message_cp_win32();
int r = 0;
#if !defined(BOOST_NO_ANSI_APIS)
if( code_page == boost::winapi::CP_ACP_ )
{
using namespace boost::winapi;
DWORD_ retval = boost::winapi::FormatMessageA(
FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
NULL,
ev,
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
buffer,
static_cast<DWORD_>( len ),
NULL
);
r = static_cast<int>( retval );
}
else
#endif
wchar_t * wbuffer = static_cast<wchar_t*>( BOOST_SYSTEM_ALLOCA( len * sizeof( wchar_t ) ) );
#undef BOOST_SYSTEM_ALLOCA
using namespace boost::winapi;
DWORD_ retval = boost::winapi::FormatMessageW(
FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
NULL,
ev,
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
wbuffer,
static_cast<DWORD_>( len ),
NULL
);
if( retval == 0 )
{
return unknown_message_win32( ev, buffer, len );
using namespace boost::winapi;
wchar_t * lpMsgBuf = 0;
DWORD_ retval = boost::winapi::FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER_ | FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
NULL,
ev,
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
(LPWSTR_) &lpMsgBuf,
0,
NULL
);
if( retval != 0 )
{
r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, buffer, static_cast<int>( len ), NULL, NULL );
boost::winapi::LocalFree( lpMsgBuf );
}
}
UINT_ const code_page = message_cp_win32();
int r = boost::winapi::WideCharToMultiByte( code_page, 0, wbuffer, -1, buffer, static_cast<int>( len ), NULL, NULL );
if( r == 0 )
{
return unknown_message_win32( ev, buffer, len );

View File

@@ -108,6 +108,10 @@ system-run initialization_test.cpp ;
run header_only_test.cpp : : : -<library>/boost/system//boost_system ;
run header_only_test.cpp : : : -<library>/boost/system//boost_system <define>BOOST_NO_ANSI_APIS : header_only_test_no_ansi ;
run header_only_test.cpp : : : -<library>/boost/system//boost_system <define>BOOST_SYSTEM_USE_UTF8 : header_only_test_utf8 ;
run error_code_test.cpp : : : -<library>/boost/system//boost_system <define>BOOST_ERROR_CODE_HEADER_ONLY <define>BOOST_NO_ANSI_APIS : error_code_test_no_ansi ;
run error_code_test.cpp : : : -<library>/boost/system//boost_system <define>BOOST_ERROR_CODE_HEADER_ONLY <define>BOOST_SYSTEM_USE_UTF8 : error_code_test_utf8 ;
run config_test.cpp : : : <test-info>always_show_run_output ;