Mercurial > pidgin.yaz
diff libpurple/util.c @ 25385: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 | 43b721aa4b76 |
children | 584063555949 |
line wrap: on
line diff
--- 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]))