From 69d474b3a7c581c4a44329ddf2065e7e158e2657 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 17 Feb 2020 11:48:50 +0100 Subject: [PATCH] Refactor win_print_outgoing() We never use the printf like behaviour anyways. --- src/ui/chatwin.c | 4 ++-- src/ui/privwin.c | 2 +- src/ui/window.c | 15 ++++----------- src/ui/window.h | 8 +++----- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 4b0fd889..ac1a83d7 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -328,7 +328,7 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, if (request_receipt && id) { win_print_outgoing_with_receipt((ProfWin*)chatwin, enc_char, "me", message, id, replace_id); } else { - win_print_outgoing((ProfWin*)chatwin, enc_char, id, replace_id, "%s", message); + win_print_outgoing((ProfWin*)chatwin, enc_char, id, replace_id, message); } // save last id and message for LMC @@ -351,7 +351,7 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) ProfWin *window = (ProfWin*)chatwin; - win_print_outgoing(window, enc_char, message->id, message->replace_id, "%s", message->plain); + win_print_outgoing(window, enc_char, message->id, message->replace_id, message->plain); int num = wins_get_num(window); status_bar_active(num, WIN_CHAT, chatwin->barejid); } diff --git a/src/ui/privwin.c b/src/ui/privwin.c index 8fc1bcc7..b05c67cf 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -95,7 +95,7 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message) { assert(privwin != NULL); - win_print_outgoing((ProfWin*)privwin, '-', NULL, NULL ,"%s", message); + win_print_outgoing((ProfWin*)privwin, '-', NULL, NULL , message); } void diff --git a/src/ui/window.c b/src/ui/window.c index a1c71241..8039ab8f 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1196,26 +1196,19 @@ win_print_outgoing_muc_msg(ProfWin *window, char ch, const char *const me, const } void -win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message, ...) +win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message) { + //TODO: we always use current timestamp here. instead of the message->timestamp one if available. i think somewhere else we check whether it exists first. GDateTime *timestamp = g_date_time_new_now_local(); - va_list arg; - va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); - g_string_vprintf(fmt_msg, message, arg); - if (replace_id) { - _win_correct(window, fmt_msg->str, id, replace_id); + _win_correct(window, message, id, replace_id); } else { - _win_printf(window, ch, 0, timestamp, 0, THEME_TEXT_THEM, "me", id, "%s", fmt_msg->str); + _win_printf(window, ch, 0, timestamp, 0, THEME_TEXT_THEM, "me", id, "%s", message); } inp_nonblocking(TRUE); g_date_time_unref(timestamp); - - g_string_free(fmt_msg, TRUE); - va_end(arg); } void diff --git a/src/ui/window.h b/src/ui/window.h index 2bd11621..25cfbbbf 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -63,17 +63,15 @@ void win_show_status_string(ProfWin *window, const char *const from, const char *const default_show); void win_print_them(ProfWin *window, theme_item_t theme_item, char ch, int flags, const char *const them); +void win_print_incoming(ProfWin *window, const char *const from, ProfMessage *message); +void win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message); +void win_print_outgoing_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message, char *id, const char *const replace_id); void win_println_incoming_muc_msg(ProfWin *window, char ch, int flags, const char *const them, const char *const id, const char *const replace_id, const char *const message, ...); void win_print_outgoing_muc_msg(ProfWin *window, char ch, const char *const me, const char *const id, const char *const replace_id, const char *const message, ...); - -void win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message, ...); -void win_print_incoming(ProfWin *window, const char *const from, ProfMessage *message); void win_print_history(ProfWin *window, GDateTime *timestamp, const char *const message, ...); void win_print_http_upload(ProfWin *window, const char *const message, char *url); -void win_print_outgoing_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message, char *id, const char *const replace_id); - void win_newline(ProfWin *window); void win_redraw(ProfWin *window); int win_roster_cols(void);