summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-12-03 10:14:30 +0100
committerSébastien Helleu <flashcode@flashtux.org>2022-12-03 10:14:30 +0100
commitf7f13352d71192a3b280f5d1a95020f34ff201a9 (patch)
treef1d0fb7336cd551ffa60cf9f68db6088ef22bf9e
parentbbd0f5d26bcbbeb7b88036f2a8b1f8a62cec4cf1 (diff)
downloadweechat-f7f13352d71192a3b280f5d1a95020f34ff201a9.zip
core: remove useless call to mbstowcs in function debug_unicode_char
-rw-r--r--src/core/wee-debug.c12
1 files 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),