pidgin.next.minor: fe5da079: Patch from Paul Aurich to add purple_str...

grim at pidgin.im grim at pidgin.im
Mon Jan 5 23:01:37 EST 2009


-----------------------------------------------------------------
Revision: fe5da0794c92922951ce4e0418f0b0f3ca2a76a1
Ancestor: 13b7de74e7154a98a5c09bf0c56e9498389318f7
Author: paul at aurich.com
Date: 2009-01-06T03:39:51
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/fe5da0794c92922951ce4e0418f0b0f3ca2a76a1

Modified files:
        libpurple/account.c libpurple/blist.c libpurple/buddyicon.c
        libpurple/certificate.c libpurple/cipher.c libpurple/cmds.c
        libpurple/conversation.c libpurple/core.c
        libpurple/desktopitem.c libpurple/idle.c libpurple/log.c
        libpurple/plugin.c libpurple/pounce.c libpurple/prefs.c
        libpurple/privacy.c libpurple/proxy.c libpurple/prpl.c
        libpurple/savedstatuses.c libpurple/server.c
        libpurple/status.c libpurple/stun.c libpurple/util.c
        libpurple/util.h libpurple/whiteboard.c libpurple/xmlnode.c

ChangeLog: 

Patch from Paul Aurich to add purple_strequal to help readability and simplicity of code.  Ie, don't need to negate the value of strcmp, since this does a strcmp and does the negation for us

closes #7790


-------------- next part --------------
============================================================
--- libpurple/account.c	9c1be679ec65675028d2765287f21bd0422d66a5
+++ libpurple/account.c	3426119e006117dd2d22d01912eb618cdad6daa3
@@ -178,9 +178,7 @@ status_attr_to_xmlnode(const PurpleStatu
 	{
 		const char *string_value = purple_value_get_string(attr_value);
 		const char *default_string_value = purple_value_get_string(default_value);
-		if (((string_value == NULL) && (default_string_value == NULL)) ||
-			((string_value != NULL) && (default_string_value != NULL) &&
-			 !strcmp(string_value, default_string_value)))
+		if (purple_strequal(string_value, default_string_value))
 			return NULL;
 		value = g_strdup(purple_value_get_string(attr_value));
 	}
@@ -506,11 +504,11 @@ parse_settings(xmlnode *node, PurpleAcco
 			/* Ignore this setting */
 			continue;
 
-		if (!strcmp(str_type, "string"))
+		if (purple_strequal(str_type, "string"))
 			type = PURPLE_PREF_STRING;
-		else if (!strcmp(str_type, "int"))
+		else if (purple_strequal(str_type, "int"))
 			type = PURPLE_PREF_INT;
-		else if (!strcmp(str_type, "bool"))
+		else if (purple_strequal(str_type, "bool"))
 			type = PURPLE_PREF_BOOLEAN;
 		else
 			/* Ignore this setting */
@@ -655,17 +653,17 @@ parse_proxy_info(xmlnode *node, PurpleAc
 	child = xmlnode_get_child(node, "type");
 	if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
 	{
-		if (!strcmp(data, "global"))
+		if (purple_strequal(data, "global"))
 			purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_USE_GLOBAL);
-		else if (!strcmp(data, "none"))
+		else if (purple_strequal(data, "none"))
 			purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_NONE);
-		else if (!strcmp(data, "http"))
+		else if (purple_strequal(data, "http"))
 			purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_HTTP);
-		else if (!strcmp(data, "socks4"))
+		else if (purple_strequal(data, "socks4"))
 			purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_SOCKS4);
-		else if (!strcmp(data, "socks5"))
+		else if (purple_strequal(data, "socks5"))
 			purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_SOCKS5);
-		else if (!strcmp(data, "envvar"))
+		else if (purple_strequal(data, "envvar"))
 			purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_USE_ENVVAR);
 		else
 		{
@@ -2022,7 +2020,7 @@ purple_account_get_status_type(const Pur
 	{
 		PurpleStatusType *status_type = (PurpleStatusType *)l->data;
 
-		if (!strcmp(purple_status_type_get_id(status_type), id))
+		if (purple_strequal(purple_status_type_get_id(status_type), id))
 			return status_type;
 	}
 
@@ -2631,11 +2629,11 @@ purple_accounts_find(const char *name, c
 
 	for (l = purple_accounts_get_all(); l != NULL; l = l->next) {
 		account = (PurpleAccount *)l->data;
-		if (protocol_id && strcmp(account->protocol_id, protocol_id))
+		if (protocol_id && !purple_strequal(account->protocol_id, protocol_id))
 		  continue;
 
 		who = g_strdup(purple_normalize(account, name));
-		if (!strcmp(purple_normalize(account, purple_account_get_username(account)), who)) {
+		if (purple_strequal(purple_normalize(account, purple_account_get_username(account)), who)) {
 			g_free(who);
 			return account;
 		}
============================================================
--- libpurple/blist.c	aeee64e1f14ece36f14d6c0a2a061dfc383daec8
+++ libpurple/blist.c	8d2a2bf1c38e25d46adec9af61e5fd46a3e9026e
@@ -82,7 +82,7 @@ static guint _purple_blist_hbuddy_equal(
 
 static guint _purple_blist_hbuddy_equal(struct _purple_hbuddy *hb1, struct _purple_hbuddy *hb2)
 {
-	return ((!strcmp(hb1->name, hb2->name)) && hb1->account == hb2->account && hb1->group == hb2->group);
+	return (purple_strequal(hb1->name, hb2->name) && hb1->account == hb2->account && hb1->group == hb2->group);
 }
 
 static void _purple_blist_hbuddy_free_key(struct _purple_hbuddy *hb)
@@ -382,11 +382,11 @@ parse_setting(PurpleBlistNode *node, xml
 	if (!value)
 		return;
 
-	if (!type || !strcmp(type, "string"))
+	if (!type || purple_strequal(type, "string"))
 		purple_blist_node_set_string(node, name, value);
-	else if (!strcmp(type, "bool"))
+	else if (purple_strequal(type, "bool"))
 		purple_blist_node_set_bool(node, name, atoi(value));
-	else if (!strcmp(type, "int"))
+	else if (purple_strequal(type, "int"))
 		purple_blist_node_set_int(node, name, atoi(value));
 
 	g_free(value);
@@ -453,9 +453,9 @@ parse_contact(PurpleGroup *group, xmlnod
 	for (x = cnode->child; x; x = x->next) {
 		if (x->type != XMLNODE_TYPE_TAG)
 			continue;
-		if (!strcmp(x->name, "buddy"))
+		if (purple_strequal(x->name, "buddy"))
 			parse_buddy(group, contact, x);
-		else if (!strcmp(x->name, "setting"))
+		else if (purple_strequal(x->name, "setting"))
 			parse_setting((PurpleBlistNode*)contact, x);
 	}
 
@@ -528,12 +528,12 @@ parse_group(xmlnode *groupnode)
 	for (cnode = groupnode->child; cnode; cnode = cnode->next) {
 		if (cnode->type != XMLNODE_TYPE_TAG)
 			continue;
-		if (!strcmp(cnode->name, "setting"))
+		if (purple_strequal(cnode->name, "setting"))
 			parse_setting((PurpleBlistNode*)group, cnode);
-		else if (!strcmp(cnode->name, "contact") ||
-				!strcmp(cnode->name, "person"))
+		else if (purple_strequal(cnode->name, "contact") ||
+				purple_strequal(cnode->name, "person"))
 			parse_contact(group, cnode);
-		else if (!strcmp(cnode->name, "chat"))
+		else if (purple_strequal(cnode->name, "chat"))
 			parse_chat(group, cnode);
 	}
 }
@@ -590,11 +590,11 @@ purple_blist_load()
 				if (x->type != XMLNODE_TYPE_TAG)
 					continue;
 
-				if (!strcmp(x->name, "permit")) {
+				if (purple_strequal(x->name, "permit")) {
 					name = xmlnode_get_data(x);
 					purple_privacy_permit_add(account, name, TRUE);
 					g_free(name);
-				} else if (!strcmp(x->name, "block")) {
+				} else if (purple_strequal(x->name, "block")) {
 					name = xmlnode_get_data(x);
 					purple_privacy_deny_add(account, name, TRUE);
 					g_free(name);
@@ -1061,7 +1061,7 @@ void purple_blist_rename_group(PurpleGro
 	g_return_if_fail(source != NULL);
 	g_return_if_fail(new_name != NULL);
 
-	if (*new_name == '\0' || !strcmp(new_name, source->name))
+	if (*new_name == '\0' || purple_strequal(new_name, source->name))
 		return;
 
 	dest = purple_find_group(new_name);
@@ -1128,7 +1128,7 @@ void purple_blist_rename_group(PurpleGro
 
 	/* Notify all PRPLs */
 	/* TODO: Is this condition needed?  Seems like it would always be TRUE */
-	if(old_name && source && strcmp(source->name, old_name)) {
+	if(old_name && purple_strequal(source->name, old_name)) {
 		for (accts = purple_group_get_accounts(source); accts; accts = g_slist_remove(accts, accts->data)) {
 			PurpleAccount *account = accts->data;
 			PurpleConnection *gc = NULL;
============================================================
--- libpurple/buddyicon.c	efab297a033aa745c5daf19fe596d6dc2030bcd8
+++ libpurple/buddyicon.c	ceeb5921a7322b8fde9c1d3ac8d2fc83806d4d93
@@ -988,7 +988,7 @@ delete_buddy_icon_settings(PurpleBlistNo
 {
 	purple_blist_node_remove_setting(node, setting_name);
 
-	if (!strcmp(setting_name, "buddy_icon"))
+	if (purple_strequal(setting_name, "buddy_icon"))
 	{
 		purple_blist_node_remove_setting(node, "avatar_hash");
 		purple_blist_node_remove_setting(node, "icon_checksum");
@@ -1085,7 +1085,7 @@ migrate_buddy_icon(PurpleBlistNode *node
 
 		g_free(new_filename);
 
-		if (!strcmp(setting_name, "buddy_icon"))
+		if (purple_strequal(setting_name, "buddy_icon"))
 		{
 			const char *hash;
 
@@ -1100,7 +1100,7 @@ migrate_buddy_icon(PurpleBlistNode *node
 				PurpleAccount *account = purple_buddy_get_account((PurpleBuddy *)node);
 				const char *prpl_id = purple_account_get_protocol_id(account);
 
-				if (!strcmp(prpl_id, "prpl-yahoo"))
+				if (purple_strequal(prpl_id, "prpl-yahoo"))
 				{
 					int checksum = purple_blist_node_get_int(node, "icon_checksum");
 					if (checksum != 0)
============================================================
--- libpurple/certificate.c	9995d369819ae34fce47d4c0c2a95bc4902bf27b
+++ libpurple/certificate.c	a79459c94d3a2744be5aa0aa6da71ac34d0902f3
@@ -791,7 +791,7 @@ x509_ca_locate_cert(GList *lst, const gc
 
 	for (cur = lst; cur; cur = cur->next) {
 		x509_ca_element *el = cur->data;
-		if (el->dn && !strcmp(dn, el->dn)) {
+		if (purple_strequal(dn, el->dn)) {
 			return el;
 		}
 	}
============================================================
--- libpurple/cipher.c	bf64520f28875ff1e958fe7fa311f2a234a58d22
+++ libpurple/cipher.c	a36e3bfe2bf5931e3f5ea5924513e26b2a306470
@@ -659,7 +659,7 @@ hmac_set_opt(PurpleCipherContext *contex
 
 	hctx = purple_cipher_context_get_data(context);
 
-	if (!strcmp(name, "hash")) {
+	if (purple_strequal(name, "hash")) {
 		g_free(hctx->name);
 		if (hctx->hash)
 			purple_cipher_context_destroy(hctx->hash);
@@ -676,7 +676,7 @@ hmac_get_opt(PurpleCipherContext *contex
 
 	hctx = purple_cipher_context_get_data(context);
 
-	if (!strcmp(name, "hash")) {
+	if (purple_strequal(name, "hash")) {
 		return hctx->name;
 	}
 
@@ -1692,11 +1692,11 @@ sha1_set_opt(PurpleCipherContext *contex
 
 	ctx = purple_cipher_context_get_data(context);
 
-	if(!strcmp(name, "sizeHi")) {
+	if(purple_strequal(name, "sizeHi")) {
 		ctx->sizeHi = GPOINTER_TO_INT(value);
-	} else if(!strcmp(name, "sizeLo")) {
+	} else if(purple_strequal(name, "sizeLo")) {
 		ctx->sizeLo = GPOINTER_TO_INT(value);
-	} else if(!strcmp(name, "lenW")) {
+	} else if(purple_strequal(name, "lenW")) {
 		ctx->lenW = GPOINTER_TO_INT(value);
 	}
 }
@@ -1707,11 +1707,11 @@ sha1_get_opt(PurpleCipherContext *contex
 
 	ctx = purple_cipher_context_get_data(context);
 
-	if(!strcmp(name, "sizeHi")) {
+	if(purple_strequal(name, "sizeHi")) {
 		return GINT_TO_POINTER(ctx->sizeHi);
-	} else if(!strcmp(name, "sizeLo")) {
+	} else if(purple_strequal(name, "sizeLo")) {
 		return GINT_TO_POINTER(ctx->sizeLo);
-	} else if(!strcmp(name, "lenW")) {
+	} else if(purple_strequal(name, "lenW")) {
 		return GINT_TO_POINTER(ctx->lenW);
 	}
 
@@ -1942,7 +1942,7 @@ rc4_set_opt(PurpleCipherContext *context
 
 	ctx = purple_cipher_context_get_data(context);
 
-	if(!strcmp(name, "key_len")) {
+	if(purple_strequal(name, "key_len")) {
 		ctx->key_len = GPOINTER_TO_INT(value);
 	}
 }
@@ -1967,7 +1967,7 @@ rc4_get_opt(PurpleCipherContext *context
 
 	ctx = purple_cipher_context_get_data(context);
 
-	if(!strcmp(name, "key_len")) {
+	if(purple_strequal(name, "key_len")) {
 		return GINT_TO_POINTER(ctx->key_len);
 	}
 
============================================================
--- libpurple/cmds.c	d7e728f8d66b98344fa230141a50c183bed3d6a9
+++ libpurple/cmds.c	210cee32104c954b31dbb1911ac045198af640ac
@@ -236,7 +236,7 @@ PurpleCmdStatus purple_cmd_do_command(Pu
 	for (l = cmds; l; l = l->next) {
 		c = l->data;
 
-		if (strcmp(c->cmd, cmd) != 0)
+		if (!purple_strequal(c->cmd, cmd))
 			continue;
 
 		found = TRUE;
@@ -250,8 +250,8 @@ PurpleCmdStatus purple_cmd_do_command(Pu
 
 		right_type = TRUE;
 
-		if ((c->flags & PURPLE_CMD_FLAG_PRPL_ONLY) && c->prpl_id &&
-		    (strcmp(c->prpl_id, prpl_id) != 0))
+		if ((c->flags & PURPLE_CMD_FLAG_PRPL_ONLY) &&
+		    !purple_strequal(c->prpl_id, prpl_id))
 			continue;
 
 		right_prpl = TRUE;
@@ -320,8 +320,8 @@ GList *purple_cmd_list(PurpleConversatio
 			if (!(c->flags & PURPLE_CMD_FLAG_CHAT))
 				continue;
 
-		if (conv && (c->flags & PURPLE_CMD_FLAG_PRPL_ONLY) && c->prpl_id &&
-		    (strcmp(c->prpl_id, purple_account_get_protocol_id(purple_conversation_get_account(conv))) != 0))
+		if (conv && (c->flags & PURPLE_CMD_FLAG_PRPL_ONLY) &&
+		    !purple_strequal(c->prpl_id, purple_account_get_protocol_id(purple_conversation_get_account(conv))))
 			continue;
 
 		ret = g_list_append(ret, c->cmd);
@@ -342,7 +342,7 @@ GList *purple_cmd_help(PurpleConversatio
 	for (l = cmds; l; l = l->next) {
 		c = l->data;
 
-		if (cmd && (strcmp(cmd, c->cmd) != 0))
+		if (cmd && !purple_strequal(cmd, c->cmd))
 			continue;
 
 		if (conv && (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM))
@@ -352,8 +352,8 @@ GList *purple_cmd_help(PurpleConversatio
 			if (!(c->flags & PURPLE_CMD_FLAG_CHAT))
 				continue;
 
-		if (conv && (c->flags & PURPLE_CMD_FLAG_PRPL_ONLY) && c->prpl_id &&
-		    (strcmp(c->prpl_id, purple_account_get_protocol_id(purple_conversation_get_account(conv))) != 0))
+		if (conv && (c->flags & PURPLE_CMD_FLAG_PRPL_ONLY) &&
+		    !purple_strequal(c->prpl_id, purple_account_get_protocol_id(purple_conversation_get_account(conv))))
 			continue;
 
 		ret = g_list_append(ret, c->help);
============================================================
--- libpurple/conversation.c	921d574013173337b344c91da08adb65db86b660
+++ libpurple/conversation.c	73d3d0a936e4d7ecaf9e4213ca4798cf18c663d5
@@ -912,7 +912,7 @@ purple_conversation_write(PurpleConversa
 
 				if (purple_account_get_alias(account) != NULL)
 					alias = account->alias;
-				else if (b != NULL && strcmp(purple_buddy_get_name(b), purple_buddy_get_contact_alias(b)))
+				else if (b != NULL && !purple_strequal(purple_buddy_get_name(b), purple_buddy_get_contact_alias(b)))
 					alias = purple_buddy_get_contact_alias(b);
 				else if (purple_connection_get_display_name(gc) != NULL)
 					alias = purple_connection_get_display_name(gc);
@@ -1480,7 +1480,7 @@ purple_conv_chat_write(PurpleConvChat *c
 
 		str = g_strdup(purple_normalize(account, who));
 
-		if (!strcmp(str, purple_normalize(account, chat->nick))) {
+		if (purple_strequal(str, purple_normalize(account, chat->nick))) {
 			flags |= PURPLE_MESSAGE_SEND;
 		} else {
 			flags |= PURPLE_MESSAGE_RECV;
@@ -1601,7 +1601,7 @@ purple_conv_chat_add_users(PurpleConvCha
 		const char *extra_msg = (extra_msgs ? extra_msgs->data : NULL);
 
 		if(!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) {
-			if (!strcmp(chat->nick, purple_normalize(conv->account, user))) {
+			if (purple_strequal(chat->nick, purple_normalize(conv->account, user))) {
 				const char *alias2 = purple_account_get_alias(conv->account);
 				if (alias2 != NULL)
 					alias = alias2;
@@ -1692,7 +1692,7 @@ purple_conv_chat_rename_user(PurpleConvC
 	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
 	g_return_if_fail(prpl_info != NULL);
 
-	if (!strcmp(chat->nick, purple_normalize(conv->account, old_user))) {
+	if (purple_strequal(chat->nick, purple_normalize(conv->account, old_user))) {
 		const char *alias;
 
 		/* Note this for later. */
============================================================
--- libpurple/core.c	ee050e8aabddd66cbfc85a4623c132f2607a1627
+++ libpurple/core.c	5c64ed7d4f06cbd8caac0d46b4906795272413e9
@@ -341,15 +341,7 @@ purple_core_ensure_single_instance()
 			const char *user_dir = purple_user_dir();
 			char *dbus_owner_user_dir = purple_dbus_owner_user_dir();
 
-			if (NULL == user_dir && NULL != dbus_owner_user_dir)
-				is_single_instance = TRUE;
-			else if (NULL != user_dir && NULL == dbus_owner_user_dir)
-				is_single_instance = TRUE;
-			else if (NULL == user_dir && NULL == dbus_owner_user_dir)
-				is_single_instance = FALSE;
-			else
-				is_single_instance = strcmp(dbus_owner_user_dir, user_dir);
-
+			is_single_instance = !purple_strequal(dbus_owner_user_dir, user_dir);
 			g_free(dbus_owner_user_dir);
 		}
 	}
@@ -480,7 +472,7 @@ purple_core_migrate(void)
 		if (g_file_test(name, G_FILE_TEST_IS_SYMLINK))
 		{
 			/* We're only going to duplicate a logs symlink. */
-			if (!strcmp(entry, "logs"))
+			if (purple_strequal(entry, "logs"))
 			{
 				char *link;
 #if GLIB_CHECK_VERSION(2,4,0)
@@ -523,7 +515,8 @@ purple_core_migrate(void)
 
 				logs_dir = g_build_filename(user_dir, "logs", NULL);
 
-				if (!strcmp(link, "../.purple/logs") || !strcmp(link, logs_dir))
+				if (purple_strequal(link, "../.purple/logs") ||
+				    purple_strequal(link, logs_dir))
 				{
 					/* If the symlink points to the new directory, we're
 					 * likely just trying again after a failed migration,
@@ -568,7 +561,7 @@ purple_core_migrate(void)
 		/* Deal with directories... */
 		if (g_file_test(name, G_FILE_TEST_IS_DIR))
 		{
-			if (!strcmp(entry, "icons"))
+			if (purple_strequal(entry, "icons"))
 			{
 				/* This is a special case for the Album plugin, which
 				 * stores data in the icons folder.  We're not copying
@@ -637,7 +630,7 @@ purple_core_migrate(void)
 
 				g_dir_close(icons_dir);
 			}
-			else if (!strcmp(entry, "plugins"))
+			else if (purple_strequal(entry, "plugins"))
 			{
 				/* Do nothing, because we broke plugin compatibility.
 				 * This means that the plugins directory gets left behind. */
============================================================
--- libpurple/desktopitem.c	4ffb78baee41eddd99ce46de0f661bda7fe94b77
+++ libpurple/desktopitem.c	389a1112f5a24456d75edc3ac58653afd552dc3c
@@ -108,30 +108,30 @@ type_from_string (const char *type)
 
 	switch (type [0]) {
 	case 'A':
-		if (!strcmp (type, "Application"))
+		if (purple_strequal (type, "Application"))
 			return PURPLE_DESKTOP_ITEM_TYPE_APPLICATION;
 		break;
 	case 'L':
-		if (!strcmp (type, "Link"))
+		if (purple_strequal (type, "Link"))
 			return PURPLE_DESKTOP_ITEM_TYPE_LINK;
 		break;
 	case 'F':
-		if (!strcmp (type, "FSDevice"))
+		if (purple_strequal (type, "FSDevice"))
 			return PURPLE_DESKTOP_ITEM_TYPE_FSDEVICE;
 		break;
 	case 'M':
-		if (!strcmp (type, "MimeType"))
+		if (purple_strequal (type, "MimeType"))
 			return PURPLE_DESKTOP_ITEM_TYPE_MIME_TYPE;
 		break;
 	case 'D':
-		if (!strcmp (type, "Directory"))
+		if (purple_strequal (type, "Directory"))
 			return PURPLE_DESKTOP_ITEM_TYPE_DIRECTORY;
 		break;
 	case 'S':
-		if (!strcmp (type, "Service"))
+		if (purple_strequal (type, "Service"))
 			return PURPLE_DESKTOP_ITEM_TYPE_SERVICE;
 
-		else if (!strcmp (type, "ServiceType"))
+		else if (purple_strequal (type, "ServiceType"))
 			return PURPLE_DESKTOP_ITEM_TYPE_SERVICE_TYPE;
 		break;
 	default:
@@ -149,12 +149,12 @@ find_section (PurpleDesktopItem *item, c
 
 	if (section == NULL)
 		return NULL;
-	if (strcmp (section, "Desktop Entry") == 0)
+	if (purple_strequal (section, "Desktop Entry"))
 		return NULL;
 
 	for (li = item->sections; li != NULL; li = li->next) {
 		sec = li->data;
-		if (strcmp (sec->name, section) == 0)
+		if (purple_strequal (sec->name, section))
 			return sec;
 	}
 
@@ -264,7 +264,7 @@ _purple_desktop_item_set_string (PurpleD
 
 	set (item, attr, value);
 
-	if (strcmp (attr, PURPLE_DESKTOP_ITEM_TYPE) == 0)
+	if (purple_strequal (attr, PURPLE_DESKTOP_ITEM_TYPE))
 		item->type = type_from_string (value);
 }
 
@@ -354,16 +354,16 @@ get_encoding (FILE *df)
 			p++;
 			if (*p == ' ')
 				p++;
-			if (strcmp (p, "UTF-8") == 0) {
+			if (purple_strequal (p, "UTF-8")) {
 				return ENCODING_UTF8;
-			} else if (strcmp (p, "Legacy-Mixed") == 0) {
+			} else if (purple_strequal (p, "Legacy-Mixed")) {
 				return ENCODING_LEGACY_MIXED;
 			} else {
 				/* According to the spec we're not supposed
 				 * to read a file like this */
 				return ENCODING_UNKNOWN;
 			}
-		} else if (strcmp ("[KDE Desktop Entry]", buf) == 0) {
+		} else if (purple_strequal ("[KDE Desktop Entry]", buf)) {
 			old_kde = TRUE;
 			/* don't break yet, we still want to support
 			 * Encoding even here */
@@ -557,7 +557,7 @@ decode_string (const char *value, Encodi
 		char *utf8_string;
 		if (char_encoding == NULL)
 			return NULL;
-		if (strcmp (char_encoding, "ASCII") == 0) {
+		if (purple_strequal (char_encoding, "ASCII")) {
 			return decode_string_and_dup (value);
 		}
 		utf8_string = g_convert (value, -1, "UTF-8", char_encoding,
@@ -673,7 +673,7 @@ insert_key (PurpleDesktopItem *item,
 	char *val;
 	/* we always store everything in UTF-8 */
 	if (cur_section == NULL &&
-	    strcmp (key, PURPLE_DESKTOP_ITEM_ENCODING) == 0) {
+	    purple_strequal (key, PURPLE_DESKTOP_ITEM_ENCODING)) {
 		k = g_strdup (key);
 		val = g_strdup ("UTF-8");
 	} else {
@@ -697,7 +697,7 @@ insert_key (PurpleDesktopItem *item,
 		 * on sort order, so convert to semicolons */
 		if (old_kde &&
 		    cur_section == NULL &&
-		    strcmp (key, PURPLE_DESKTOP_ITEM_SORT_ORDER) == 0 &&
+		    purple_strequal (key, PURPLE_DESKTOP_ITEM_SORT_ORDER) &&
 		    strchr (val, ';') == NULL) {
 			int i;
 			for (i = 0; val[i] != '\0'; i++) {
@@ -720,7 +720,7 @@ insert_key (PurpleDesktopItem *item,
 
 		/* Take care of the language part */
 		if (locale != NULL &&
-		    strcmp (locale, "C") == 0) {
+		    purple_strequal (locale, "C")) {
 			char *p;
 			/* Whack C locale */
 			p = strchr (k, '[');
@@ -791,8 +791,7 @@ setup_type (PurpleDesktopItem *item, con
 						PURPLE_DESKTOP_ITEM_TYPE);
 	if (type == NULL && uri != NULL) {
 		char *base = g_path_get_basename (uri);
-		if (base != NULL &&
-		    strcmp (base, ".directory") == 0) {
+		if (purple_strequal(base, ".directory")) {
 			/* This gotta be a directory */
 			g_hash_table_replace (item->main_hash,
 					      g_strdup (PURPLE_DESKTOP_ITEM_TYPE), 
@@ -813,7 +812,7 @@ lookup_locale (const PurpleDesktopItem *
 lookup_locale (const PurpleDesktopItem *item, const char *key, const char *locale)
 {
 	if (locale == NULL ||
-	    strcmp (locale, "C") == 0) {
+	    purple_strequal (locale, "C")) {
 		return lookup (item, key);
 	} else {
 		const char *ret;
@@ -857,7 +856,7 @@ sanitize (PurpleDesktopItem *item, const
 	type = lookup (item, PURPLE_DESKTOP_ITEM_TYPE);
 
 	/* understand old gnome style url exec thingies */
-	if (type != NULL && strcmp (type, "URL") == 0) {
+	if (purple_strequal(type, "URL")) {
 		const char *exec = lookup (item, PURPLE_DESKTOP_ITEM_EXEC);
 		set (item, PURPLE_DESKTOP_ITEM_TYPE, "Link");
 		if (exec != NULL) {
@@ -968,13 +967,11 @@ ditem_load (FILE *df,
 					cur_section->keys = g_list_reverse
 						(cur_section->keys);
 				}
-				if (strcmp (CharBuffer,
-					    "KDE Desktop Entry") == 0) {
+				if (purple_strequal (CharBuffer, "KDE Desktop Entry")) {
 					/* Main section */
 					cur_section = NULL;
 					old_kde = TRUE;
-				} else if (strcmp (CharBuffer,
-						   "Desktop Entry") == 0) {
+				} else if (purple_strequal(CharBuffer, "Desktop Entry")) {
 					/* Main section */
 					cur_section = NULL;
 				} else {
============================================================
--- libpurple/idle.c	4c2f40738284bcb7eca06867ba0f4c3c09771d9b
+++ libpurple/idle.c	9952f567571e34828f4395d2ae034f9fcd877473
@@ -126,14 +126,14 @@ check_idleness(void)
 	idle_reporting = purple_prefs_get_string("/purple/away/idle_reporting");
 	auto_away = purple_prefs_get_bool("/purple/away/away_when_idle");
 
-	if (!strcmp(idle_reporting, "system") &&
+	if (purple_strequal(idle_reporting, "system") &&
 		(idle_ui_ops != NULL) && (idle_ui_ops->get_time_idle != NULL))
 	{
 		/* Use system idle time (mouse or keyboard movement, etc.) */
 		time_idle = idle_ui_ops->get_time_idle();
 		idle_recheck_interval = 1;
 	}
-	else if (!strcmp(idle_reporting, "purple"))
+	else if (purple_strequal(idle_reporting, "purple"))
 	{
 		/* Use 'Purple idle' */
 		time_idle = time(NULL) - last_active_time;
============================================================
--- libpurple/log.c	ee57f460fd0eac6d880b27bafd3fc1ebc592c00f
+++ libpurple/log.c	514ba9820fad672aa6e38d96bfe5a804cb93eb8f
@@ -200,7 +200,7 @@ static guint _purple_logsize_user_equal(
 static guint _purple_logsize_user_equal(struct _purple_logsize_user *lu1,
 		struct _purple_logsize_user *lu2)
 {
-	return (lu1->account == lu2->account && (!strcmp(lu1->name, lu2->name)));
+	return (lu1->account == lu2->account && purple_strequal(lu1->name, lu2->name));
 }
 
 static void _purple_logsize_user_free_key(struct _purple_logsize_user *lu)
@@ -324,7 +324,7 @@ static void logger_pref_cb(const char *n
 	GSList *l = loggers;
 	while (l) {
 		logger = l->data;
-		if (!strcmp(logger->id, value)) {
+		if (purple_strequal(logger->id, value)) {
 			purple_log_logger_set(logger);
 			return;
 		}
@@ -406,7 +406,7 @@ void purple_log_logger_add (PurpleLogLog
 	if (g_slist_find(loggers, logger))
 		return;
 	loggers = g_slist_append(loggers, logger);
-	if (strcmp(purple_prefs_get_string("/purple/logging/format"), logger->id) == 0) {
+	if (purple_strequal(purple_prefs_get_string("/purple/logging/format"), logger->id)) {
 		purple_prefs_trigger_callback("/purple/logging/format");
 	}
 }
@@ -1019,7 +1019,7 @@ static void log_get_log_sets_common(GHas
 				continue;
 			prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
 
-			if (!strcmp(protocol_unescaped, prpl_info->list_icon((PurpleAccount *)account_iter->data, NULL)))
+			if (purple_strequal(protocol_unescaped, prpl_info->list_icon((PurpleAccount *)account_iter->data, NULL)))
 				accounts = g_list_prepend(accounts, account_iter->data);
 		}
 		g_free(protocol_unescaped);
@@ -1039,7 +1039,7 @@ static void log_get_log_sets_common(GHas
 			/* Find the account for username in the list of accounts for protocol. */
 			username_unescaped = purple_unescape_filename(username);
 			for (account_iter = g_list_first(accounts) ; account_iter != NULL ; account_iter = account_iter->next) {
-				if (!strcmp(((PurpleAccount *)account_iter->data)->username, username_unescaped)) {
+				if (purple_strequal(((PurpleAccount *)account_iter->data)->username, username_unescaped)) {
 					account = account_iter->data;
 					break;
 				}
@@ -1068,14 +1068,14 @@ static void log_get_log_sets_common(GHas
 				/* Chat for .chat or .system at the end of the name to determine the type. */
 				if (len >= 7) {
 					gchar *tmp = &name[len - 7];
-					if (!strcmp(tmp, ".system")) {
+					if (purple_strequal(tmp, ".system")) {
 						set->type = PURPLE_LOG_SYSTEM;
 						*tmp = '\0';
 					}
 				}
 				if (len > 5) {
 					gchar *tmp = &name[len - 5];
-					if (!strcmp(tmp, ".chat")) {
+					if (purple_strequal(tmp, ".chat")) {
 						set->type = PURPLE_LOG_CHAT;
 						*tmp = '\0';
 					}
@@ -1773,29 +1773,29 @@ static GList *old_logger_list(PurpleLogT
 			sscanf(convostart, "%*s %s %d %d:%d:%d %d",
 			       month, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &tm.tm_year);
 			/* Ugly hack, in case current locale is not English */
-			if (strcmp(month, "Jan") == 0) {
+			if (purple_strequal(month, "Jan")) {
 				tm.tm_mon= 0;
-			} else if (strcmp(month, "Feb") == 0) {
+			} else if (purple_strequal(month, "Feb")) {
 				tm.tm_mon = 1;
-			} else if (strcmp(month, "Mar") == 0) {
+			} else if (purple_strequal(month, "Mar")) {
 				tm.tm_mon = 2;
-			} else if (strcmp(month, "Apr") == 0) {
+			} else if (purple_strequal(month, "Apr")) {
 				tm.tm_mon = 3;
-			} else if (strcmp(month, "May") == 0) {
+			} else if (purple_strequal(month, "May")) {
 				tm.tm_mon = 4;
-			} else if (strcmp(month, "Jun") == 0) {
+			} else if (purple_strequal(month, "Jun")) {
 				tm.tm_mon = 5;
-			} else if (strcmp(month, "Jul") == 0) {
+			} else if (purple_strequal(month, "Jul")) {
 				tm.tm_mon = 6;
-			} else if (strcmp(month, "Aug") == 0) {
+			} else if (purple_strequal(month, "Aug")) {
 				tm.tm_mon = 7;
-			} else if (strcmp(month, "Sep") == 0) {
+			} else if (purple_strequal(month, "Sep")) {
 				tm.tm_mon = 8;
-			} else if (strcmp(month, "Oct") == 0) {
+			} else if (purple_strequal(month, "Oct")) {
 				tm.tm_mon = 9;
-			} else if (strcmp(month, "Nov") == 0) {
+			} else if (purple_strequal(month, "Nov")) {
 				tm.tm_mon = 10;
-			} else if (strcmp(month, "Dec") == 0) {
+			} else if (purple_strequal(month, "Dec")) {
 				tm.tm_mon = 11;
 			}
 			tm.tm_year -= 1900;
@@ -1930,7 +1930,7 @@ static void old_logger_get_log_sets(Purp
 
 		/* Make sure we're dealing with a log file. */
 		ext = &name[len - 4];
-		if (strcmp(ext, ".log")) {
+		if (!purple_strequal(ext, ".log")) {
 			g_free(name);
 			continue;
 		}
@@ -1943,7 +1943,7 @@ static void old_logger_get_log_sets(Purp
 		set->type = PURPLE_LOG_IM;
 		if (len > 9) {
 			char *tmp = &name[len - 9];
-			if (!strcmp(tmp, ".chat")) {
+			if (purple_strequal(tmp, ".chat")) {
 				set->type = PURPLE_LOG_CHAT;
 				*tmp = '\0';
 			}
@@ -1972,7 +1972,7 @@ static void old_logger_get_log_sets(Purp
 				{
 					PurpleBuddy *buddy = (PurpleBuddy *)bnode;
 
-					if (!strcmp(purple_buddy_get_name(buddy), name)) {
+					if (purple_strequal(purple_buddy_get_name(buddy), name)) {
 						set->account = purple_buddy_get_account(buddy);
 						set->buddy = TRUE;
 						found = TRUE;
============================================================
--- libpurple/plugin.c	2549ba41e1aa06b741a66c3d04e95c6874b10cc8
+++ libpurple/plugin.c	d9e12a96e6ad59cfd66e00915b5c20fb1e5feac6
@@ -218,7 +218,7 @@ purple_plugin_probe(const char *filename
 	g_free(basename);
 	if (plugin != NULL)
 	{
-		if (!strcmp(filename, plugin->path))
+		if (purple_strequal(filename, plugin->path))
 			return plugin;
 		else if (!purple_plugin_is_unloadable(plugin))
 		{
@@ -357,7 +357,7 @@ purple_plugin_probe(const char *filename
 		return NULL;
 	}
 	else if (plugin->info->ui_requirement &&
-			strcmp(plugin->info->ui_requirement, purple_core_get_ui()))
+			!purple_strequal(plugin->info->ui_requirement, purple_core_get_ui()))
 	{
 		plugin->error = g_strdup_printf(_("You are using %s, but this plugin requires %s."),
 					purple_core_get_ui(), plugin->info->ui_requirement);
@@ -1538,7 +1538,7 @@ purple_plugins_find_with_name(const char
 	for (l = plugins; l != NULL; l = l->next) {
 		plugin = l->data;
 
-		if (!strcmp(plugin->info->name, name))
+		if (purple_strequal(plugin->info->name, name))
 			return plugin;
 	}
 
@@ -1554,7 +1554,7 @@ purple_plugins_find_with_filename(const 
 	for (l = plugins; l != NULL; l = l->next) {
 		plugin = l->data;
 
-		if (plugin->path != NULL && !strcmp(plugin->path, filename))
+		if (purple_strequal(plugin->path, filename))
 			return plugin;
 	}
 
@@ -1577,7 +1577,7 @@ purple_plugins_find_with_basename(const 
 
 		if (plugin->path != NULL) {
 			tmp = purple_plugin_get_basename(plugin->path);
-			if (!strcmp(tmp, basename))
+			if (purple_strequal(tmp, basename))
 			{
 				g_free(tmp);
 				return plugin;
@@ -1603,7 +1603,7 @@ purple_plugins_find_with_id(const char *
 	{
 		plugin = l->data;
 
-		if (plugin->info->id != NULL && !strcmp(plugin->info->id, id))
+		if (purple_strequal(plugin->info->id, id))
 			return plugin;
 	}
 
============================================================
--- libpurple/pounce.c	790461f82b18c5b5e500f8b5d0bfd2565e268bda
+++ libpurple/pounce.c	41ff91aae25bcbc3f573eba3949709cdd29493dc
@@ -326,7 +326,7 @@ start_element_handler(GMarkupParseContex
 		data->buffer = NULL;
 	}
 
-	if (!strcmp(element_name, "pounce")) {
+	if (purple_strequal(element_name, "pounce")) {
 		const char *ui = g_hash_table_lookup(atts, "ui");
 
 		if (ui == NULL) {
@@ -338,7 +338,7 @@ start_element_handler(GMarkupParseContex
 
 		data->events = 0;
 	}
-	else if (!strcmp(element_name, "account")) {
+	else if (purple_strequal(element_name, "account")) {
 		const char *protocol_id = g_hash_table_lookup(atts, "protocol");
 
 		if (protocol_id == NULL) {
@@ -348,7 +348,7 @@ start_element_handler(GMarkupParseContex
 		else
 			data->protocol_id = g_strdup(protocol_id);
 	}
-	else if (!strcmp(element_name, "option")) {
+	else if (purple_strequal(element_name, "option")) {
 		const char *type = g_hash_table_lookup(atts, "type");
 
 		if (type == NULL) {
@@ -358,7 +358,7 @@ start_element_handler(GMarkupParseContex
 		else
 			data->option_type = g_strdup(type);
 	}
-	else if (!strcmp(element_name, "event")) {
+	else if (purple_strequal(element_name, "event")) {
 		const char *type = g_hash_table_lookup(atts, "type");
 
 		if (type == NULL) {
@@ -368,7 +368,7 @@ start_element_handler(GMarkupParseContex
 		else
 			data->event_type = g_strdup(type);
 	}
-	else if (!strcmp(element_name, "action")) {
+	else if (purple_strequal(element_name, "action")) {
 		const char *type = g_hash_table_lookup(atts, "type");
 
 		if (type == NULL) {
@@ -378,7 +378,7 @@ start_element_handler(GMarkupParseContex
 		else
 			data->action_name = g_strdup(type);
 	}
-	else if (!strcmp(element_name, "param")) {
+	else if (purple_strequal(element_name, "param")) {
 		const char *param_name = g_hash_table_lookup(atts, "name");
 
 		if (param_name == NULL) {
@@ -404,7 +404,7 @@ end_element_handler(GMarkupParseContext 
 		data->buffer = NULL;
 	}
 
-	if (!strcmp(element_name, "account")) {
+	if (purple_strequal(element_name, "account")) {
 		char *tmp;
 		g_free(data->account_name);
 		data->account_name = g_strdup(buffer);
@@ -412,43 +412,43 @@ end_element_handler(GMarkupParseContext 
 		data->protocol_id = g_strdup(_purple_oscar_convert(buffer, tmp));
 		g_free(tmp);
 	}
-	else if (!strcmp(element_name, "pouncee")) {
+	else if (purple_strequal(element_name, "pouncee")) {
 		g_free(data->pouncee);
 		data->pouncee = g_strdup(buffer);
 	}
-	else if (!strcmp(element_name, "option")) {
-		if (!strcmp(data->option_type, "on-away"))
+	else if (purple_strequal(element_name, "option")) {
+		if (purple_strequal(data->option_type, "on-away"))
 			data->options |= PURPLE_POUNCE_OPTION_AWAY;
 
 		g_free(data->option_type);
 		data->option_type = NULL;
 	}
-	else if (!strcmp(element_name, "event")) {
-		if (!strcmp(data->event_type, "sign-on"))
+	else if (purple_strequal(element_name, "event")) {
+		if (purple_strequal(data->event_type, "sign-on"))
 			data->events |= PURPLE_POUNCE_SIGNON;
-		else if (!strcmp(data->event_type, "sign-off"))
+		else if (purple_strequal(data->event_type, "sign-off"))
 			data->events |= PURPLE_POUNCE_SIGNOFF;
-		else if (!strcmp(data->event_type, "away"))
+		else if (purple_strequal(data->event_type, "away"))
 			data->events |= PURPLE_POUNCE_AWAY;
-		else if (!strcmp(data->event_type, "return-from-away"))
+		else if (purple_strequal(data->event_type, "return-from-away"))
 			data->events |= PURPLE_POUNCE_AWAY_RETURN;
-		else if (!strcmp(data->event_type, "idle"))
+		else if (purple_strequal(data->event_type, "idle"))
 			data->events |= PURPLE_POUNCE_IDLE;
-		else if (!strcmp(data->event_type, "return-from-idle"))
+		else if (purple_strequal(data->event_type, "return-from-idle"))
 			data->events |= PURPLE_POUNCE_IDLE_RETURN;
-		else if (!strcmp(data->event_type, "start-typing"))
+		else if (purple_strequal(data->event_type, "start-typing"))
 			data->events |= PURPLE_POUNCE_TYPING;
-		else if (!strcmp(data->event_type, "typed"))
+		else if (purple_strequal(data->event_type, "typed"))
 			data->events |= PURPLE_POUNCE_TYPED;
-		else if (!strcmp(data->event_type, "stop-typing"))
+		else if (purple_strequal(data->event_type, "stop-typing"))
 			data->events |= PURPLE_POUNCE_TYPING_STOPPED;
-		else if (!strcmp(data->event_type, "message-received"))
+		else if (purple_strequal(data->event_type, "message-received"))
 			data->events |= PURPLE_POUNCE_MESSAGE_RECEIVED;
 
 		g_free(data->event_type);
 		data->event_type = NULL;
 	}
-	else if (!strcmp(element_name, "action")) {
+	else if (purple_strequal(element_name, "action")) {
 		if (data->pounce != NULL) {
 			purple_pounce_action_register(data->pounce, data->action_name);
 			purple_pounce_action_set_enabled(data->pounce, data->action_name, TRUE);
@@ -457,7 +457,7 @@ end_element_handler(GMarkupParseContext 
 		g_free(data->action_name);
 		data->action_name = NULL;
 	}
-	else if (!strcmp(element_name, "param")) {
+	else if (purple_strequal(element_name, "param")) {
 		if (data->pounce != NULL) {
 			purple_pounce_action_set_attribute(data->pounce, data->action_name,
 											 data->param_name, buffer);
@@ -466,7 +466,7 @@ end_element_handler(GMarkupParseContext 
 		g_free(data->param_name);
 		data->param_name = NULL;
 	}
-	else if (!strcmp(element_name, "events")) {
+	else if (purple_strequal(element_name, "events")) {
 		PurpleAccount *account;
 
 		account = purple_accounts_find(data->account_name, data->protocol_id);
@@ -499,11 +499,11 @@ end_element_handler(GMarkupParseContext 
 		g_free(data->pouncee);
 		data->pouncee = NULL;
 	}
-	else if (!strcmp(element_name, "save")) {
+	else if (purple_strequal(element_name, "save")) {
 		if (data->pounce != NULL)
 			purple_pounce_set_save(data->pounce, TRUE);
 	}
-	else if (!strcmp(element_name, "pounce")) {
+	else if (purple_strequal(element_name, "pounce")) {
 		data->pounce  = NULL;
 		data->events  = 0;
 		data->options = 0;
@@ -1023,7 +1023,7 @@ GList *purple_pounces_get_all_for_ui(con
 
 	for (iter = pounces; iter; iter = iter->next) {
 		PurplePounce *pounce = iter->data;
-		if (pounce->ui_type && strcmp(pounce->ui_type, ui) == 0)
+		if (purple_strequal(pounce->ui_type, ui))
 			list = g_list_prepend(list, pounce);
 	}
 	list = g_list_reverse(list);
============================================================
--- libpurple/prefs.c	155bb1ed1363d3d72bfc07cb890818a4cdb90e3d
+++ libpurple/prefs.c	27c261111e7b276735e92534529e455ca759fac6
@@ -250,33 +250,34 @@ prefs_start_element_handler (GMarkupPars
 	GString *pref_name_full;
 	GList *tmp;
 
-	if(strcmp(element_name, "pref") && strcmp(element_name, "item"))
+	if(!purple_strequal(element_name, "pref") &&
+	   !purple_strequal(element_name, "item"))
 		return;
 
 	for(i = 0; attribute_names[i]; i++) {
-		if(!strcmp(attribute_names[i], "name")) {
+		if(purple_strequal(attribute_names[i], "name")) {
 			pref_name = attribute_values[i];
-		} else if(!strcmp(attribute_names[i], "type")) {
-			if(!strcmp(attribute_values[i], "bool"))
+		} else if(purple_strequal(attribute_names[i], "type")) {
+			if(purple_strequal(attribute_values[i], "bool"))
 				pref_type = PURPLE_PREF_BOOLEAN;
-			else if(!strcmp(attribute_values[i], "int"))
+			else if(purple_strequal(attribute_values[i], "int"))
 				pref_type = PURPLE_PREF_INT;
-			else if(!strcmp(attribute_values[i], "string"))
+			else if(purple_strequal(attribute_values[i], "string"))
 				pref_type = PURPLE_PREF_STRING;
-			else if(!strcmp(attribute_values[i], "stringlist"))
+			else if(purple_strequal(attribute_values[i], "stringlist"))
 				pref_type = PURPLE_PREF_STRING_LIST;
-			else if(!strcmp(attribute_values[i], "path"))
+			else if(purple_strequal(attribute_values[i], "path"))
 				pref_type = PURPLE_PREF_PATH;
-			else if(!strcmp(attribute_values[i], "pathlist"))
+			else if(purple_strequal(attribute_values[i], "pathlist"))
 				pref_type = PURPLE_PREF_PATH_LIST;
 			else
 				return;
-		} else if(!strcmp(attribute_names[i], "value")) {
+		} else if(purple_strequal(attribute_names[i], "value")) {
 			pref_value = attribute_values[i];
 		}
 	}
 
-	if(!strcmp(element_name, "item")) {
+	if(purple_strequal(element_name, "item")) {
 		struct purple_pref *pref;
 
 		pref_name_full = g_string_new("");
@@ -301,7 +302,7 @@ prefs_start_element_handler (GMarkupPars
 	} else {
 		char *decoded;
 
-		if(!pref_name || !strcmp(pref_name, "/"))
+		if(!pref_name || purple_strequal(pref_name, "/"))
 			return;
 
 		pref_name_full = g_string_new(pref_name);
@@ -352,7 +353,7 @@ prefs_end_element_handler(GMarkupParseCo
 						  const gchar *element_name,
 						  gpointer user_data, GError **error)
 {
-	if(prefs_stack && !strcmp(element_name, "pref")) {
+	if(prefs_stack && purple_strequal(element_name, "pref")) {
 		g_free(prefs_stack->data);
 		prefs_stack = g_list_delete_link(prefs_stack, prefs_stack);
 	}
@@ -521,7 +522,7 @@ find_pref_parent(const char *name)
 	char *parent_name = get_path_dirname(name);
 	struct purple_pref *ret = &prefs;
 
-	if(strcmp(parent_name, "/")) {
+	if(!purple_strequal(parent_name, "/")) {
 		ret = find_pref(parent_name);
 	}
 
@@ -571,7 +572,7 @@ add_pref(PurplePrefType type, const char
 	my_name = get_path_basename(name);
 
 	for(sibling = parent->first_child; sibling; sibling = sibling->sibling) {
-		if(!strcmp(sibling->name, my_name)) {
+		if(purple_strequal(sibling->name, my_name)) {
 			g_free(my_name);
 			return NULL;
 		}
@@ -848,10 +849,7 @@ purple_prefs_set_string(const char *name
 			return;
 		}
 
-		if((value && !pref->value.string) ||
-				(!value && pref->value.string) ||
-				(value && pref->value.string &&
-				 strcmp(pref->value.string, value))) {
+		if (!purple_strequal(pref->value.string, value)) {
 			g_free(pref->value.string);
 			pref->value.string = g_strdup(value);
 			do_callbacks(name, pref);
@@ -908,10 +906,7 @@ purple_prefs_set_path(const char *name, 
 			return;
 		}
 
-		if((value && !pref->value.string) ||
-				(!value && pref->value.string) ||
-				(value && pref->value.string &&
-				 strcmp(pref->value.string, value))) {
+		if (!purple_strequal(pref->value.string, value)) {
 			g_free(pref->value.string);
 			pref->value.string = g_strdup(value);
 			do_callbacks(name, pref);
@@ -1105,7 +1100,7 @@ purple_prefs_rename_node(struct purple_p
 		next = child->sibling;
 		for(newchild = newpref->first_child; newchild != NULL; newchild = newchild->sibling)
 		{
-			if(!strcmp(child->name, newchild->name))
+			if(purple_strequal(child->name, newchild->name))
 			{
 				purple_prefs_rename_node(child, newchild);
 				break;
============================================================
--- libpurple/privacy.c	9961c84b0bfe9b32cecd8bef660726745f94bd34
+++ libpurple/privacy.c	d70a03e1031ac1fc9deff4d76f74fb27523efd35
@@ -261,7 +261,7 @@ purple_privacy_allow(PurpleAccount *acco
 				for (list = account->permit; list != NULL;) {
 					char *person = list->data;
 					list = list->next;
-					if (strcmp(norm, person) != 0)
+					if (!purple_strequal(norm, person))
 						purple_privacy_permit_remove(account, person, local);
 				}
 			}
@@ -305,7 +305,7 @@ purple_privacy_deny(PurpleAccount *accou
 				for (list = account->deny; list != NULL; ) {
 					char *person = list->data;
 					list = list->next;
-					if (strcmp(norm, person) != 0)
+					if (!purple_strequal(norm, person))
 						purple_privacy_deny_remove(account, person, local);
 				}
 			}
============================================================
--- libpurple/proxy.c	112accff674b00f35bfa8e46e367930b98beb6cc
+++ libpurple/proxy.c	912b6c761da831ffd6ed5c8c099499906e99fd31
@@ -228,13 +228,13 @@ purple_gnome_proxy_get_info(void)
 	g_free(err);
 	err = NULL;
 
-	if (!strcmp(tmp, "none\n")) {
+	if (purple_strequal(tmp, "none\n")) {
 		info.type = PURPLE_PROXY_NONE;
 		g_free(tmp);
 		return &info;
 	}
 
-	if (strcmp(tmp, "manual\n")) {
+	if (purple_strequal(tmp, "manual\n")) {
 		/* Unknown setting.  Fallback to using our global proxy settings. */
 		g_free(tmp);
 		return purple_global_proxy_get_info();
@@ -263,7 +263,7 @@ purple_gnome_proxy_get_info(void)
 	g_free(err);
 	err = NULL;
 
-	if (!strcmp(tmp, "true\n"))
+	if (purple_strequal(tmp, "true\n"))
 		use_same_proxy = TRUE;
 	g_free(tmp);
 	tmp = NULL;
@@ -2242,31 +2242,31 @@ proxy_pref_cb(const char *name, PurplePr
 {
 	PurpleProxyInfo *info = purple_global_proxy_get_info();
 
-	if (!strcmp(name, "/purple/proxy/type")) {
+	if (purple_strequal(name, "/purple/proxy/type")) {
 		int proxytype;
 		const char *type = value;
 
-		if (!strcmp(type, "none"))
+		if (purple_strequal(type, "none"))
 			proxytype = PURPLE_PROXY_NONE;
-		else if (!strcmp(type, "http"))
+		else if (purple_strequal(type, "http"))
 			proxytype = PURPLE_PROXY_HTTP;
-		else if (!strcmp(type, "socks4"))
+		else if (purple_strequal(type, "socks4"))
 			proxytype = PURPLE_PROXY_SOCKS4;
-		else if (!strcmp(type, "socks5"))
+		else if (purple_strequal(type, "socks5"))
 			proxytype = PURPLE_PROXY_SOCKS5;
-		else if (!strcmp(type, "envvar"))
+		else if (purple_strequal(type, "envvar"))
 			proxytype = PURPLE_PROXY_USE_ENVVAR;
 		else
 			proxytype = -1;
 
 		purple_proxy_info_set_type(info, proxytype);
-	} else if (!strcmp(name, "/purple/proxy/host"))
+	} else if (purple_strequal(name, "/purple/proxy/host"))
 		purple_proxy_info_set_host(info, value);
-	else if (!strcmp(name, "/purple/proxy/port"))
+	else if (purple_strequal(name, "/purple/proxy/port"))
 		purple_proxy_info_set_port(info, GPOINTER_TO_INT(value));
-	else if (!strcmp(name, "/purple/proxy/username"))
+	else if (purple_strequal(name, "/purple/proxy/username"))
 		purple_proxy_info_set_username(info, value);
-	else if (!strcmp(name, "/purple/proxy/password"))
+	else if (purple_strequal(name, "/purple/proxy/password"))
 		purple_proxy_info_set_password(info, value);
 }
 
============================================================
--- libpurple/prpl.c	1e2df97bcf949adfc848ee4e0770cfdd0c6233b0
+++ libpurple/prpl.c	4644ab12f743d3e7e2580718d20c3fb281ac8107
@@ -511,7 +511,7 @@ purple_find_prpl(const char *id)
 	for (l = purple_plugins_get_protocols(); l != NULL; l = l->next) {
 		plugin = (PurplePlugin *)l->data;
 
-		if (!strcmp(plugin->info->id, id))
+		if (purple_strequal(plugin->info->id, id))
 			return plugin;
 	}
 
============================================================
--- libpurple/savedstatuses.c	5f842ca17975257f3af208f4125d43cb00d34d52
+++ libpurple/savedstatuses.c	dccc30531667e9a088fca357c187ef6cb4e897d8
@@ -461,7 +461,7 @@ parse_status(xmlnode *status)
 	ret = g_new0(PurpleSavedStatus, 1);
 
 	attrib = xmlnode_get_attrib(status, "transient");
-	if ((attrib == NULL) || (strcmp(attrib, "true")))
+	if (!purple_strequal(attrib, "true"))
 	{
 		/* Read the title */
 		attrib = xmlnode_get_attrib(status, "name");
@@ -940,7 +940,7 @@ purple_savedstatus_find(const char *titl
 	for (iter = saved_statuses; iter != NULL; iter = iter->next)
 	{
 		status = (PurpleSavedStatus *)iter->data;
-		if ((status->title != NULL) && !strcmp(status->title, title))
+		if (purple_strequal(status->title, title))
 			return status;
 	}
 
@@ -975,8 +975,7 @@ purple_savedstatus_find_transient_by_typ
 		status = (PurpleSavedStatus *)iter->data;
 		if ((status->type == type) && purple_savedstatus_is_transient(status) &&
 			!purple_savedstatus_has_substatuses(status) &&
-			(((status->message == NULL) && (message == NULL)) ||
-			((status->message != NULL) && (message != NULL) && !strcmp(status->message, message))))
+			purple_strequal(status->message, message))
 		{
 			return status;
 		}
============================================================
--- libpurple/server.c	cc04d8db50d252161193a2cf9631e04055d424f7
+++ libpurple/server.c	de678a21a58dafae9424502b2964f90a4dd51a11
@@ -152,7 +152,7 @@ int serv_send_im(PurpleConnection *gc, c
 	auto_reply_pref = purple_prefs_get_string("/purple/away/auto_reply");
 	if((gc->flags & PURPLE_CONNECTION_AUTO_RESP) &&
 			!purple_presence_is_available(presence) &&
-			strcmp(auto_reply_pref, "never")) {
+			!purple_strequal(auto_reply_pref, "never")) {
 
 		struct last_auto_response *lar;
 		lar = get_last_auto_response(gc, name);
@@ -253,17 +253,14 @@ serv_got_alias(PurpleConnection *gc, con
 		buddies = g_slist_delete_link(buddies, buddies);
 
 		server_alias = purple_buddy_get_server_alias(b);
-		if((server_alias == NULL && alias == NULL) ||
-		    (server_alias && alias && !strcmp(server_alias, alias)))
-		{
+
+		if (purple_strequal(server_alias, alias))
 			continue;
-		}
 
 		purple_blist_server_alias_buddy(b, alias);
 
 		conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, purple_buddy_get_name(b), account);
-		if(conv != NULL && alias != NULL &&
-		   who != NULL && strcmp(alias, who))
+		if (conv != NULL && alias != NULL && purple_strequal(alias, who))
 		{
 			char *escaped = g_markup_escape_text(who, -1);
 			char *escaped2 = g_markup_escape_text(alias, -1);
@@ -298,7 +295,7 @@ purple_serv_got_private_alias(PurpleConn
 		buddies = g_slist_delete_link(buddies, buddies);
 
 		balias = purple_buddy_get_local_buddy_alias(b);
-		if((!balias && !alias) || (balias && alias && !strcmp(balias, alias)))
+		if (purple_strequal(balias, alias))
 			continue;
 
 		purple_blist_alias_buddy(b, alias);
@@ -673,8 +670,8 @@ void serv_got_im(PurpleConnection *gc, c
 		if ((primitive == PURPLE_STATUS_AVAILABLE) ||
 			(primitive == PURPLE_STATUS_INVISIBLE) ||
 			mobile ||
-		    !strcmp(auto_reply_pref, "never") ||
-		    (!purple_presence_is_idle(presence) && !strcmp(auto_reply_pref, "awayidle")))
+		    purple_strequal(auto_reply_pref, "never") ||
+		    (!purple_presence_is_idle(presence) && purple_strequal(auto_reply_pref, "awayidle")))
 		{
 			g_free(name);
 			return;
============================================================
--- libpurple/status.c	c21ff46fb2b8f6bba1a04b9432b8f2cc84876c35
+++ libpurple/status.c	2d637f1940c8b35926c4da545e1c51f3eb185bef
@@ -203,7 +203,7 @@ purple_primitive_get_type_from_id(const 
 
     for (i = 0; i < PURPLE_STATUS_NUM_PRIMITIVES; i++)
     {
-        if (!strcmp(id, status_primitive_map[i].id))
+		if (purple_strequal(id, status_primitive_map[i].id))
             return status_primitive_map[i].type;
     }
 
@@ -451,7 +451,7 @@ purple_status_type_get_attr(const Purple
 	{
 		PurpleStatusAttr *attr = (PurpleStatusAttr *)l->data;
 
-		if (!strcmp(purple_status_attr_get_id(attr), id))
+		if (purple_strequal(purple_status_attr_get_id(attr), id))
 			return attr;
 	}
 
@@ -477,7 +477,7 @@ purple_status_type_find_with_id(GList *s
 	{
 		status_type = status_types->data;
 
-		if (!strcmp(id, status_type->id))
+		if (purple_strequal(id, status_type->id))
 			return status_type;
 
 		status_types = status_types->next;
@@ -782,12 +782,8 @@ purple_status_set_active_with_attrs_list
 		{
 			const gchar *string_data = l->data;
 			l = l->next;
-			if (((string_data == NULL) && (value->data.string_data == NULL)) ||
-				((string_data != NULL) && (value->data.string_data != NULL) &&
-				!strcmp(string_data, value->data.string_data)))
-			{
+			if (purple_strequal(string_data, value->data.string_data))
 				continue;
-			}
 			purple_status_set_attr_string(status, id, string_data);
 			changed = TRUE;
 		}
@@ -1451,7 +1447,7 @@ purple_presence_get_status(const PurpleP
 		{
 			PurpleStatus *temp_status = l->data;
 
-			if (!strcmp(status_id, purple_status_get_id(temp_status)))
+			if (purple_strequal(status_id, purple_status_get_id(temp_status)))
 				status = temp_status;
 		}
 
============================================================
--- libpurple/stun.c	e32c63a72d633dd1f0989716cb866e05b496df9e
+++ libpurple/stun.c	e4f2b3d4c374182d54989682dd48110b078a2fbb
@@ -388,9 +388,7 @@ PurpleStunNatDiscovery *purple_stun_disc
 		/** Deal with the server name having changed since we did the
 		    lookup */
 		if (servername && strlen(servername) > 1
-				&& ((nattype.servername
-					&& strcmp(servername, nattype.servername))
-				|| !nattype.servername)) {
+				&& !purple_strequal(servername, nattype.servername)) {
 			use_cached_result = FALSE;
 		}
 
============================================================
--- libpurple/util.c	8fe1bdf7b7e9cd5c76089fceb1db72956899b6d0
+++ libpurple/util.c	63cdf725999fed1c93e7d3d4651400679e1ad4d6
@@ -1409,7 +1409,7 @@ purple_markup_html_to_xhtml(const char *
 						struct purple_parse_tag *pt = tags->data;
 						if(xhtml)
 							g_string_append_printf(xhtml, "</%s>", pt->dest_tag);
-						if(plain && !strcmp(pt->src_tag, "a")) {
+						if(plain && purple_strequal(pt->src_tag, "a")) {
 							/* if this is a link, we have to add the url to the plaintext, too */
 							if (cdata && url &&
 									(!g_string_equal(cdata, url) && (g_ascii_strncasecmp(url->str, "mailto:", 7) != 0 ||
@@ -2949,7 +2949,7 @@ purple_running_kde(void)
 	g_free(tmp);
 
 	session = g_getenv("KDE_FULL_SESSION");
-	if (session != NULL && !strcmp(session, "true"))
+	if (purple_strequal(session, "true"))
 		return TRUE;
 
 	/* If you run Purple from Konsole under !KDE, this will provide a
@@ -2990,6 +2990,17 @@ purple_fd_get_ip(int fd)
 /**************************************************************************
  * String Functions
  **************************************************************************/
+gboolean
+purple_strequal(const gchar *left, const gchar *right)
+{
+#if GLIB_CHECK_VERSION(2,16,0)
+	return (g_strcmp0(left, right) == 0);
+#else
+	return ((left == NULL && right == NULL) ||
+	        (left != NULL && right != NULL && strcmp(left, right) == 0));
+#endif
+}
+
 const char *
 purple_normalize(const PurpleAccount *account, const char *str)
 {
@@ -3104,7 +3115,7 @@ purple_str_has_suffix(const char *s, con
 	g_return_val_if_fail(x != NULL, FALSE);
 
 	off = strlen(s) - strlen(x);
-	return (off >= 0 && !strcmp(s + off, x));
+	return (off >= 0 && purple_strequal(s + off, x));
 #endif
 }
 
@@ -4701,7 +4712,7 @@ const char *_purple_oscar_convert(const 
 
 const char *_purple_oscar_convert(const char *act, const char *protocol)
 {
-	if (protocol && act && strcmp(protocol, "prpl-oscar") == 0) {
+	if (act && purple_strequal(protocol, "prpl-oscar")) {
 		int i;
 		for (i = 0; act[i] != '\0'; i++)
 			if (!isdigit(act[i]))
============================================================
--- libpurple/util.h	62c0624b2e3267b01a6bd6c85f825d393d1859fc
+++ libpurple/util.h	d75c0030d8e1fceb03f825eb4ac41da30795423d
@@ -775,6 +775,20 @@ char *purple_fd_get_ip(int fd);
 /*@{*/
 
 /**
+ * Tests two strings for equality.
+ *
+ * Unlike strcmp(), this function will not crash if one or both of the
+ * strings are @c NULL.
+ *
+ * @param left	A string
+ * @param right A string to compare with left
+ *
+ * @return @c TRUE if the strings are the same, else @c FALSE.
+ * @since 2.6.0
+ */
+gboolean purple_strequal(const gchar *left, const gchar *right);
+
+/**
  * Normalizes a string, so that it is suitable for comparison.
  *
  * The returned string will point to a static buffer, so if the
============================================================
--- libpurple/whiteboard.c	7d81d4843faa1752537444cd1b3736cfa673f91d
+++ libpurple/whiteboard.c	a4708cc57ac7fa0796f4653663de5f055b9576d4
@@ -115,7 +115,7 @@ PurpleWhiteboard *purple_whiteboard_get_
 	{
 		wb = l->data;
 
-		if(wb->account == account && !strcmp(wb->who, who))
+		if(wb->account == account && purple_strequal(wb->who, who))
 			return wb;
 
 		l = l->next;
============================================================
--- libpurple/xmlnode.c	cc943561f4f4a718619ef7e5e7e4ad1b520b09b3
+++ libpurple/xmlnode.c	14e29a35b86ea347eb37200d28859dce0242d9b3
@@ -129,7 +129,7 @@ xmlnode_remove_attrib(xmlnode *node, con
 	for(attr_node = node->child; attr_node; attr_node = attr_node->next)
 	{
 		if(attr_node->type == XMLNODE_TYPE_ATTRIB &&
-				!strcmp(attr_node->name, attr))
+				purple_strequal(attr_node->name, attr))
 		{
 			if(sibling == NULL) {
 				node->child = attr_node->next;
@@ -146,20 +146,6 @@ xmlnode_remove_attrib(xmlnode *node, con
 	}
 }
 
-/* Compare two nullable xmlns strings.
- * They are considered equal if they're both NULL or the strings are equal
- */
-static gboolean _xmlnode_compare_xmlns(const char *xmlns1, const char *xmlns2) {
-	gboolean equal = FALSE;
-
-	if (xmlns1 == NULL && xmlns2 == NULL)
-		equal = TRUE;
-	else if (xmlns1 != NULL && xmlns2 != NULL && !strcmp(xmlns1, xmlns2))
-		equal = TRUE;
-
-	return equal;
-}
-
 void
 xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns)
 {
@@ -171,8 +157,8 @@ xmlnode_remove_attrib_with_namespace(xml
 	for(attr_node = node->child; attr_node; attr_node = attr_node->next)
 	{
 		if(attr_node->type == XMLNODE_TYPE_ATTRIB &&
-		   !strcmp(attr_node->name, attr) &&
-		   _xmlnode_compare_xmlns(xmlns, attr_node->xmlns))
+		   purple_strequal(attr,  attr_node->name) &&
+		   purple_strequal(xmlns, attr_node->xmlns))
 		{
 			if(sibling == NULL) {
 				node->child = attr_node->next;
@@ -252,7 +238,7 @@ xmlnode_get_attrib(xmlnode *node, const 
 	g_return_val_if_fail(attr != NULL, NULL);
 
 	for(x = node->child; x; x = x->next) {
-		if(x->type == XMLNODE_TYPE_ATTRIB && !strcmp(attr, x->name)) {
+		if(x->type == XMLNODE_TYPE_ATTRIB && purple_strequal(attr, x->name)) {
 			return x->data;
 		}
 	}
@@ -270,8 +256,8 @@ xmlnode_get_attrib_with_namespace(xmlnod
 
 	for(x = node->child; x; x = x->next) {
 		if(x->type == XMLNODE_TYPE_ATTRIB &&
-		   !strcmp(attr, x->name) &&
-		   _xmlnode_compare_xmlns(xmlns, x->xmlns)) {
+		   purple_strequal(attr,  x->name) &&
+		   purple_strequal(xmlns, x->xmlns)) {
 			return x->data;
 		}
 	}
@@ -382,8 +368,8 @@ xmlnode_get_child_with_namespace(const x
 		if(ns)
 			xmlns = xmlnode_get_namespace(x);
 
-		if(x->type == XMLNODE_TYPE_TAG && name && !strcmp(parent_name, x->name)
-				&& (!ns || (xmlns && !strcmp(ns, xmlns)))) {
+		if(x->type == XMLNODE_TYPE_TAG && purple_strequal(parent_name, x->name)
+				&& purple_strequal(ns, xmlns)) {
 			ret = x;
 			break;
 		}
@@ -471,7 +457,7 @@ xmlnode_to_str_helper(xmlnode *node, int
 		g_hash_table_foreach(node->namespace_map,
 			(GHFunc)xmlnode_to_str_foreach_append_ns, text);
 	} else if (node->xmlns) {
-		if(!node->parent || !node->parent->xmlns || strcmp(node->xmlns, node->parent->xmlns))
+		if(!node->parent || !purple_strequal(node->xmlns, node->parent->xmlns))
 		{
 			char *xmlns = g_markup_escape_text(node->xmlns, -1);
 			g_string_append_printf(text, " xmlns='%s'", xmlns);
@@ -866,8 +852,8 @@ xmlnode_get_next_twin(xmlnode *node)
 		if(ns)
 			xmlns = xmlnode_get_namespace(sibling);
 
-		if(sibling->type == XMLNODE_TYPE_TAG && !strcmp(node->name, sibling->name) &&
-				(!ns || (xmlns && !strcmp(ns, xmlns))))
+		if(sibling->type == XMLNODE_TYPE_TAG && purple_strequal(node->name, sibling->name) &&
+				purple_strequal(ns, xmlns))
 			return sibling;
 	}
 


More information about the Commits mailing list