Mercurial > pidgin
changeset 25894:a6e3cb32cdd2
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
committer: Gary Kramlich <grim@reaperworld.com>
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Tue, 06 Jan 2009 03:39:51 +0000 |
parents | 991796129108 |
children | b52e0b60429d |
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 |
diffstat | 25 files changed, 230 insertions(+), 246 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/account.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/account.c Tue Jan 06 03:39:51 2009 +0000 @@ -178,9 +178,7 @@ { 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 @@ /* 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 @@ 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 @@ { 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 @@ 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; }
--- a/libpurple/blist.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/blist.c Tue Jan 06 03:39:51 2009 +0000 @@ -82,7 +82,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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;
--- a/libpurple/buddyicon.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/buddyicon.c Tue Jan 06 03:39:51 2009 +0000 @@ -988,7 +988,7 @@ { 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 @@ g_free(new_filename); - if (!strcmp(setting_name, "buddy_icon")) + if (purple_strequal(setting_name, "buddy_icon")) { const char *hash; @@ -1100,7 +1100,7 @@ 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)
--- a/libpurple/certificate.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/certificate.c Tue Jan 06 03:39:51 2009 +0000 @@ -791,7 +791,7 @@ 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; } }
--- a/libpurple/cipher.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/cipher.c Tue Jan 06 03:39:51 2009 +0000 @@ -659,7 +659,7 @@ 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 @@ hctx = purple_cipher_context_get_data(context); - if (!strcmp(name, "hash")) { + if (purple_strequal(name, "hash")) { return hctx->name; } @@ -1692,11 +1692,11 @@ 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 @@ 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 @@ 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 @@ 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); }
--- a/libpurple/cmds.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/cmds.c Tue Jan 06 03:39:51 2009 +0000 @@ -236,7 +236,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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);
--- a/libpurple/conversation.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/conversation.c Tue Jan 06 03:39:51 2009 +0000 @@ -912,7 +912,7 @@ 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 @@ 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 @@ 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 @@ 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. */
--- a/libpurple/core.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/core.c Tue Jan 06 03:39:51 2009 +0000 @@ -341,15 +341,7 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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. */
--- a/libpurple/desktopitem.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/desktopitem.c Tue Jan 06 03:39:51 2009 +0000 @@ -108,30 +108,30 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ /* 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 @@ 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 *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 @@ 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 @@ 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 {
--- a/libpurple/idle.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/idle.c Tue Jan 06 03:39:51 2009 +0000 @@ -126,14 +126,14 @@ 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;
--- a/libpurple/log.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/log.c Tue Jan 06 03:39:51 2009 +0000 @@ -200,7 +200,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ /* 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 @@ 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 @@ /* 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 @@ 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 @@ { 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;
--- a/libpurple/plugin.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/plugin.c Tue Jan 06 03:39:51 2009 +0000 @@ -218,7 +218,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { plugin = l->data; - if (plugin->info->id != NULL && !strcmp(plugin->info->id, id)) + if (purple_strequal(plugin->info->id, id)) return plugin; }
--- a/libpurple/pounce.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/pounce.c Tue Jan 06 03:39:51 2009 +0000 @@ -326,7 +326,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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);
--- a/libpurple/prefs.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/prefs.c Tue Jan 06 03:39:51 2009 +0000 @@ -250,33 +250,34 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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;
--- a/libpurple/privacy.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/privacy.c Tue Jan 06 03:39:51 2009 +0000 @@ -261,7 +261,7 @@ 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 @@ 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); } }
--- a/libpurple/proxy.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/proxy.c Tue Jan 06 03:39:51 2009 +0000 @@ -228,13 +228,13 @@ 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 @@ 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 @@ { 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); }
--- a/libpurple/prpl.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/prpl.c Tue Jan 06 03:39:51 2009 +0000 @@ -511,7 +511,7 @@ 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; }
--- a/libpurple/savedstatuses.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/savedstatuses.c Tue Jan 06 03:39:51 2009 +0000 @@ -461,7 +461,7 @@ 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 @@ 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 @@ 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; }
--- a/libpurple/server.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/server.c Tue Jan 06 03:39:51 2009 +0000 @@ -152,7 +152,7 @@ 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 @@ 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 @@ 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 @@ 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;
--- a/libpurple/status.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/status.c Tue Jan 06 03:39:51 2009 +0000 @@ -203,7 +203,7 @@ 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 @@ { 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 @@ { 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 @@ { 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 @@ { 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; }
--- a/libpurple/stun.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/stun.c Tue Jan 06 03:39:51 2009 +0000 @@ -388,9 +388,7 @@ /** 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; }
--- a/libpurple/util.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/util.c Tue Jan 06 03:39:51 2009 +0000 @@ -1409,7 +1409,7 @@ 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 @@ 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 @@ /************************************************************************** * 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 @@ 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 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]))
--- a/libpurple/util.h Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/util.h Tue Jan 06 03:39:51 2009 +0000 @@ -775,6 +775,20 @@ /*@{*/ /** + * 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
--- a/libpurple/whiteboard.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/whiteboard.c Tue Jan 06 03:39:51 2009 +0000 @@ -115,7 +115,7 @@ { 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;
--- a/libpurple/xmlnode.c Fri Jan 02 22:52:17 2009 +0000 +++ b/libpurple/xmlnode.c Tue Jan 06 03:39:51 2009 +0000 @@ -129,7 +129,7 @@ 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 @@ } } -/* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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; }