From f7f13352d71192a3b280f5d1a95020f34ff201a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 3 Dec 2022 10:14:30 +0100 Subject: [PATCH] core: remove useless call to mbstowcs in function debug_unicode_char --- src/core/wee-debug.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c index 6c4145cdd..ebe370735 100644 --- a/src/core/wee-debug.c +++ b/src/core/wee-debug.c @@ -769,11 +769,11 @@ void debug_unicode_char (unsigned int codepoint) { char utf8_char[5], hexa[64], *ptr_hexa; - wchar_t wstring[4+2]; - int i, size, length_wcswidth; + int i, size, width; utf8_int_string (codepoint, utf8_char); size = strlen (utf8_char); + width = wcwidth ((wchar_t)codepoint); hexa[0] = '\0'; ptr_hexa = hexa; @@ -792,10 +792,6 @@ debug_unicode_char (unsigned int codepoint) } ptr_hexa[0] = '\0'; - length_wcswidth = -1; - if (mbstowcs (wstring, utf8_char, 1) != (size_t)(-1)) - length_wcswidth = wcswidth (wstring, 1); - gui_chat_printf (NULL, "\t \"%s\" (%u, U+%04X, %s): %d %s/%s %d, %d %s/%s %d, %d, %d", utf8_char, @@ -809,7 +805,7 @@ debug_unicode_char (unsigned int codepoint) gui_chat_strlen (utf8_char), GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), GUI_COLOR(GUI_COLOR_CHAT), - length_wcswidth, + width, utf8_strlen_screen (utf8_char), gui_chat_strlen_screen (utf8_char)); } @@ -831,7 +827,7 @@ debug_unicode_string (const char *string) "(codepoint, hex codepoint, UTF-8 sequence): " "strlen %s/%s " "utf8_strlen, gui_chat_strlen %s/%s " - "wcswidth, utf8_strlen_screen, gui_chat_strlen_screen:"), + "wcwidth, utf8_strlen_screen, gui_chat_strlen_screen:"), GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), GUI_COLOR(GUI_COLOR_CHAT), GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),