adium: 1e356233: C89-ify. Use g_list_prepend instead of g...

zacw at adiumx.com zacw at adiumx.com
Tue Apr 14 02:08:12 EDT 2009


-----------------------------------------------------------------
Revision: 1e35623360b0e8ccb5b6f537879a7eaa5a2a4cbe
Ancestor: 094626e87db8585973e6d853818b32a11e16e9ce
Author: zacw at adiumx.com
Date: 2009-04-14T05:50:32
Branch: im.pidgin.adium
URL: http://d.pidgin.im/viewmtn/revision/info/1e35623360b0e8ccb5b6f537879a7eaa5a2a4cbe

Modified files:
        libpurple/conversation.c libpurple/protocols/irc/irc.c
        libpurple/protocols/irc/msgs.c

ChangeLog: 

C89-ify. Use g_list_prepend instead of g_list_append. Check if "cb" is non-NULL before accessing.

-------------- next part --------------
============================================================
--- libpurple/conversation.c	20f73b103031c2d42dbf0fff818fbef3453dc625
+++ libpurple/conversation.c	d41262e5e5e3de86413c65e5f4cc399731d0ecef
@@ -2090,14 +2090,17 @@ purple_conv_chat_cb_set_attribute(Purple
 void
 purple_conv_chat_cb_set_attribute(PurpleConvChat *chat, PurpleConvChatBuddy *cb, const char *key, const char *value)
 {
+	PurpleConversation *conv;
+	PurpleConversationUiOps *ops;
+	
 	g_return_if_fail(cb != NULL);
 	g_return_if_fail(key != NULL);
 	g_return_if_fail(value != NULL);
 	
 	g_hash_table_replace(cb->attributes, g_strdup(key), g_strdup(value));
 	
-	PurpleConversation *conv = purple_conv_chat_get_conversation(chat);
-	PurpleConversationUiOps *ops = purple_conversation_get_ui_ops(conv);
+	conv = purple_conv_chat_get_conversation(chat);
+	ops = purple_conversation_get_ui_ops(conv);
 	
 	if (ops != NULL && ops->chat_update_user != NULL)
 		ops->chat_update_user(conv, cb->name);
@@ -2106,6 +2109,9 @@ purple_conv_chat_cb_set_attributes(Purpl
 void
 purple_conv_chat_cb_set_attributes(PurpleConvChat *chat, PurpleConvChatBuddy *cb, GList *keys, GList *values)
 {
+	PurpleConversation *conv;
+	PurpleConversationUiOps *ops;
+	
 	g_return_if_fail(cb != NULL);
 	g_return_if_fail(keys != NULL);
 	g_return_if_fail(values != NULL);
@@ -2116,8 +2122,8 @@ purple_conv_chat_cb_set_attributes(Purpl
 		values = g_list_next(values);
 	}
 	
-	PurpleConversation *conv = purple_conv_chat_get_conversation(chat);
-	PurpleConversationUiOps *ops = purple_conversation_get_ui_ops(conv);
+	conv = purple_conv_chat_get_conversation(chat);
+	ops = purple_conversation_get_ui_ops(conv);
 	
 	if (ops != NULL && ops->chat_update_user != NULL)
 		ops->chat_update_user(conv, cb->name);
============================================================
--- libpurple/protocols/irc/irc.c	6b64d8348119626d1e3bfd88e631581bcff8528a
+++ libpurple/protocols/irc/irc.c	0269b86b36489485d32e9e0586313674c5703ed0
@@ -227,9 +227,9 @@ static void irc_who_channel(PurpleConver
 static void irc_who_channel(PurpleConversation *conv, struct irc_conn *irc)
 {
 	if (purple_conversation_get_account(conv) == irc->account && purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
-		purple_debug(PURPLE_DEBUG_INFO, "irc", "Performing periodic who on %s", purple_conversation_get_name(conv));
+		char *buf = irc_format(irc, "vc", "WHO", purple_conversation_get_name(conv));
 		
-		char *buf = irc_format(irc, "vc", "WHO", purple_conversation_get_name(conv));
+		purple_debug(PURPLE_DEBUG_INFO, "irc", "Performing periodic who on %s", purple_conversation_get_name(conv));
 		irc_send(irc, buf);
 		g_free(buf);
 	}
============================================================
--- libpurple/protocols/irc/msgs.c	48563a02f945387cf9cb439f8f114d2252f11663
+++ libpurple/protocols/irc/msgs.c	fffb5a9ee98cdfe78c3a1451c834bb53b2796e38
@@ -420,31 +420,38 @@ void irc_msg_who(struct irc_conn *irc, c
 void irc_msg_who(struct irc_conn *irc, const char *name, const char *from, char **args)
 {
 	if (!strcmp(name, "352")) {
-		PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
+		PurpleConversation *conv;
+		PurpleConvChat *chat;
+		PurpleConvChatBuddy *cb;
+		
+		char *userhost, *realname;
+		
+		PurpleConvChatBuddyFlags flags;
+		GList *keys = NULL, *values = NULL;
+		
+		conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
 		if (!conv) {
 			purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a WHO response for %s, which doesn't exist\n", args[1]);
 			return;
 		}
 
-		PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), args[5]);
+		cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), args[5]);
 		if (!cb) {
 			purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a WHO response for %s who isn't a buddy.\n", args[5]);
 			return;
 		}
 
-		PurpleConvChat *chat = PURPLE_CONV_CHAT(conv);
+		chat = PURPLE_CONV_CHAT(conv);
 		
-		char *userhost = g_strdup_printf("%s@%s", args[2], args[3]);
-		char *realname = g_strdup(args[8]);
+		userhost = g_strdup_printf("%s@%s", args[2], args[3]);
+		realname = g_strdup(args[8]);
 		
-		GList *keys = NULL, *values = NULL;
+		keys = g_list_prepend(keys, "userhost");
+		values = g_list_prepend(values, userhost);
 		
-		keys = g_list_append(keys, "userhost");
-		values = g_list_append(values, userhost);
+		keys = g_list_prepend(keys, "realname");
+		values = g_list_prepend(values, realname);
 		
-		keys = g_list_append(keys, "realname");
-		values = g_list_append(values, realname);
-		
 		purple_conv_chat_cb_set_attributes(chat, cb, keys, values);
 		
 		g_list_free(keys);
@@ -453,7 +460,7 @@ void irc_msg_who(struct irc_conn *irc, c
 		g_free(userhost);
 		g_free(realname);
 		
-		PurpleConvChatBuddyFlags flags = purple_conv_chat_user_get_flags(chat, cb->name);
+		flags = purple_conv_chat_user_get_flags(chat, cb->name);
 		
 		// (G|H)...
 		if (args[6][0] == 'G' && !(flags & PURPLE_CBFLAGS_AWAY)) {
@@ -851,7 +858,8 @@ void irc_msg_join(struct irc_conn *irc, 
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
 	PurpleConversation *convo;
 	PurpleConvChat *chat;
-	char *nick = irc_mask_nick(from), *userhost;
+	PurpleConvChatBuddy *cb;
+	char *nick = irc_mask_nick(from), *userhost, *buf;
 	struct irc_buddy *ib;
 	static int id = 1;
 
@@ -876,7 +884,7 @@ void irc_msg_join(struct irc_conn *irc, 
 					   GINT_TO_POINTER(FALSE));
 		
 		// Get the real name and user host for all participants.
-		char *buf = irc_format(irc, "vc", "WHO", args[0]);
+		buf = irc_format(irc, "vc", "WHO", args[0]);
 		irc_send(irc, buf);
 		g_free(buf);
 		
@@ -899,9 +907,11 @@ void irc_msg_join(struct irc_conn *irc, 
 	
 	purple_conv_chat_add_user(chat, nick, userhost, PURPLE_CBFLAGS_NONE, TRUE);
 	
-	PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(chat, nick);
+	cb = purple_conv_chat_cb_find(chat, nick);
 	
-	purple_conv_chat_cb_set_attribute(chat, cb, "userhost", userhost);
+	if (cb) {
+		purple_conv_chat_cb_set_attribute(chat, cb, "userhost", userhost);
+	}
 	
 	if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) {
 		ib->flag = TRUE;


More information about the Commits mailing list