From 07fa6b12a6d0e3f351050cad761bdaa467382bfb Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 9 Apr 2023 00:18:29 +0200 Subject: core: don't split on newline characters in printf_date_tags With support for rendering newline characters as new lines, we don't need to split the message on newline characters anymore in printf_date_tags. This allows you to print a line with multiple lines. --- src/gui/gui-chat.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index e9b06a7a4..66c7ee681 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -849,7 +849,6 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date, const char *tags, const char *message, ...) { time_t date_printed; - char *pos, *pos_end; if (!message) return; @@ -872,25 +871,14 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date, if (date <= 0) date = date_printed; - pos = vbuffer; - while (pos) + if (gui_init_ok) { - /* display until next end of line */ - pos_end = strchr (pos, '\n'); - if (pos_end) - pos_end[0] = '\0'; - - if (gui_init_ok) - { - gui_chat_printf_date_tags_internal (buffer, date, date_printed, - tags, pos); - } - else - { - gui_chat_add_line_waiting_buffer (pos); - } - - pos = (pos_end && pos_end[1]) ? pos_end + 1 : NULL; + gui_chat_printf_date_tags_internal (buffer, date, date_printed, + tags, vbuffer); + } + else + { + gui_chat_add_line_waiting_buffer (vbuffer); } free (vbuffer); -- cgit v1.2.3