mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
Merge pull request #7586 from heinrich5991/pr_ddnet_invalid_utf16_error
Make error message about invalid UTF-16 more precise
This commit is contained in:
commit
9e3d7c47fb
|
@ -182,7 +182,7 @@ bool dbg_assert_has_failed()
|
||||||
return dbg_assert_failing.load(std::memory_order_acquire);
|
return dbg_assert_failing.load(std::memory_order_acquire);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dbg_assert_imp(const char *filename, int line, int test, const char *msg)
|
void dbg_assert_imp(const char *filename, int line, bool test, const char *msg)
|
||||||
{
|
{
|
||||||
if(!test)
|
if(!test)
|
||||||
{
|
{
|
||||||
|
@ -1461,7 +1461,7 @@ std::string windows_format_system_message(unsigned long error)
|
||||||
|
|
||||||
std::optional<std::string> message = windows_wide_to_utf8(wide_message);
|
std::optional<std::string> message = windows_wide_to_utf8(wide_message);
|
||||||
LocalFree(wide_message);
|
LocalFree(wide_message);
|
||||||
return message.value_or("invalid error");
|
return message.value_or("(invalid UTF-16 in error message)");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4430,7 +4430,8 @@ void os_locale_str(char *locale, size_t length)
|
||||||
dbg_assert(GetUserDefaultLocaleName(wide_buffer, std::size(wide_buffer)) > 0, "GetUserDefaultLocaleName failure");
|
dbg_assert(GetUserDefaultLocaleName(wide_buffer, std::size(wide_buffer)) > 0, "GetUserDefaultLocaleName failure");
|
||||||
|
|
||||||
const std::optional<std::string> buffer = windows_wide_to_utf8(wide_buffer);
|
const std::optional<std::string> buffer = windows_wide_to_utf8(wide_buffer);
|
||||||
str_copy(locale, buffer.value_or("en-US").c_str(), length);
|
dbg_assert(buffer.has_value(), "GetUserDefaultLocaleName returned invalid UTF-16");
|
||||||
|
str_copy(locale, buffer.value().c_str(), length);
|
||||||
#elif defined(CONF_PLATFORM_MACOS)
|
#elif defined(CONF_PLATFORM_MACOS)
|
||||||
CFLocaleRef locale_ref = CFLocaleCopyCurrent();
|
CFLocaleRef locale_ref = CFLocaleCopyCurrent();
|
||||||
CFStringRef locale_identifier_ref = static_cast<CFStringRef>(CFLocaleGetValue(locale_ref, kCFLocaleIdentifier));
|
CFStringRef locale_identifier_ref = static_cast<CFStringRef>(CFLocaleGetValue(locale_ref, kCFLocaleIdentifier));
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
* @see dbg_break
|
* @see dbg_break
|
||||||
*/
|
*/
|
||||||
#define dbg_assert(test, msg) dbg_assert_imp(__FILE__, __LINE__, test, msg)
|
#define dbg_assert(test, msg) dbg_assert_imp(__FILE__, __LINE__, test, msg)
|
||||||
void dbg_assert_imp(const char *filename, int line, int test, const char *msg);
|
void dbg_assert_imp(const char *filename, int line, bool test, const char *msg);
|
||||||
|
|
||||||
#ifdef __clang_analyzer__
|
#ifdef __clang_analyzer__
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
Loading…
Reference in a new issue