From 26cefd0587a5ca092a7b4ee442c144eee9e19dc5 Mon Sep 17 00:00:00 2001 From: TingPing Date: Thu, 16 May 2013 09:21:55 +0000 Subject: Have rawlog properly handle newlines This is most noticable with /cycle or the missing USER command on connect. --- src/fe-gtk/rawlog.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/fe-gtk/rawlog.c b/src/fe-gtk/rawlog.c index d0564406..736013c9 100644 --- a/src/fe-gtk/rawlog.c +++ b/src/fe-gtk/rawlog.c @@ -154,20 +154,29 @@ open_rawlog (struct server *serv) void fe_add_rawlog (server *serv, char *text, int len, int outbound) { + char **split_text; char *new_text; + int i; if (!serv->gui->rawlog_window) return; - new_text = malloc (len + 7); + split_text = g_strsplit (text, "\r\n", 0); - len = sprintf (new_text, "\0033>>\017 %s", text); - if (outbound) + for (i = 0; i < g_strv_length (split_text); i++) { - new_text[1] = '4'; - new_text[2] = '<'; - new_text[3] = '<'; + if (split_text[i][0] == 0) + break; + + if (outbound) + new_text = g_strconcat ("\0034<<\017 ", split_text[i], NULL); + else + new_text = g_strconcat ("\0033>>\017 ", split_text[i], NULL); + + gtk_xtext_append (GTK_XTEXT (serv->gui->rawlog_textlist)->buffer, new_text, strlen (new_text)); + + g_free (new_text); } - gtk_xtext_append (GTK_XTEXT (serv->gui->rawlog_textlist)->buffer, new_text, len); - free (new_text); + + g_strfreev (split_text); } -- cgit 1.4.1