diff options
Diffstat (limited to 'src/plugins/irc')
-rw-r--r-- | src/plugins/irc/irc-debug.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/plugins/irc/irc-debug.c b/src/plugins/irc/irc-debug.c index 6644060e5..309667b76 100644 --- a/src/plugins/irc/irc-debug.c +++ b/src/plugins/irc/irc-debug.c @@ -55,7 +55,9 @@ void irc_debug_printf (struct t_irc_server *server, int send, int modified, const char *message) { - char *buf; + char *buf, *buf2; + const char *ptr_buf; + int pos_buf, pos_buf2, char_size, i; if (!weechat_irc_plugin->debug || !message) return; @@ -87,6 +89,32 @@ irc_debug_printf (struct t_irc_server *server, int send, int modified, } buf = weechat_iconv_to_internal (NULL, message); + buf2 = malloc ((strlen (buf) * 3) + 1); + if (buf2) + { + ptr_buf = (buf) ? buf : message; + pos_buf = 0; + pos_buf2 = 0; + while (ptr_buf[pos_buf]) + { + if (ptr_buf[pos_buf] < 32) + { + buf2[pos_buf2++] = '\\'; + buf2[pos_buf2++] = (ptr_buf[pos_buf] / 10) + '0'; + buf2[pos_buf2++] = (ptr_buf[pos_buf] % 10) + '0'; + pos_buf++; + } + else + { + char_size = weechat_utf8_char_size (ptr_buf + pos_buf); + for (i = 0; i < char_size; i++) + { + buf2[pos_buf2++] = ptr_buf[pos_buf++]; + } + } + } + buf2[pos_buf2] = '\0'; + } weechat_printf (irc_debug_buffer, "%s%s%s%s%s\t%s", @@ -99,9 +127,11 @@ irc_debug_printf (struct t_irc_server *server, int send, int modified, (send) ? ((modified) ? IRC_DEBUG_PREFIX_SEND_MOD : IRC_DEBUG_PREFIX_SEND) : ((modified) ? IRC_DEBUG_PREFIX_RECV_MOD : IRC_DEBUG_PREFIX_RECV), - (buf) ? buf : message); + (buf2) ? buf2 : ((buf) ? buf : message)); if (buf) free (buf); + if (buf2) + free (buf2); } /* |