summary refs log tree commit diff stats
path: root/src/fe-gtk
diff options
context:
space:
mode:
authorTingPing <tngpng@gmail.com>2013-05-16 09:21:55 +0000
committerTingPing <tngpng@gmail.com>2013-05-16 09:21:55 +0000
commit26cefd0587a5ca092a7b4ee442c144eee9e19dc5 (patch)
treefef3578c0f1e829a74ab47c7dd543b790c3e12d2 /src/fe-gtk
parent25d07937660f8fc6cc95c8ff6f1506e9dde216f8 (diff)
Have rawlog properly handle newlines
This is most noticable with /cycle or the missing USER command on connect.
Diffstat (limited to 'src/fe-gtk')
-rw-r--r--src/fe-gtk/rawlog.c25
1 files changed, 17 insertions, 8 deletions
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);
 }