Mercurial > pidgin.yaz
changeset 16155:fb6a333f517a
merge of '495fbd738a23f24591f098b137d932381b6bc8ad'
and '73ec1481dfb8cc0a42c4e942714c9652e7bd16eb'
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 15 Apr 2007 18:52:54 +0000 |
parents | fb752e199cef (current diff) fce68761da8c (diff) |
children | 34aa3c118e77 c4f779253fab |
files | libpurple/plugins/autoreply.c |
diffstat | 4 files changed, 46 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/util.c Sun Apr 15 18:44:44 2007 +0000 +++ b/libpurple/util.c Sun Apr 15 18:52:54 2007 +0000 @@ -134,14 +134,14 @@ accumulator |= str[i] - 48; else { - switch(str[i]) + switch(tolower(str[i])) { - case 'a': case 'A': accumulator |= 10; break; - case 'b': case 'B': accumulator |= 11; break; - case 'c': case 'C': accumulator |= 12; break; - case 'd': case 'D': accumulator |= 13; break; - case 'e': case 'E': accumulator |= 14; break; - case 'f': case 'F': accumulator |= 15; break; + case 'a': accumulator |= 10; break; + case 'b': accumulator |= 11; break; + case 'c': accumulator |= 12; break; + case 'd': accumulator |= 13; break; + case 'e': accumulator |= 14; break; + case 'f': accumulator |= 15; break; } }
--- a/libpurple/util.h Sun Apr 15 18:44:44 2007 +0000 +++ b/libpurple/util.h Sun Apr 15 18:52:54 2007 +0000 @@ -1017,7 +1017,10 @@ gchar *purple_utf8_salvage(const char *str); /** - * Compares two UTF-8 strings case-insensitively. + * Compares two UTF-8 strings case-insensitively. This string is + * more expensive than a simple g_utf8_collate() comparison because + * it calls g_utf8_casefold() on each string, which allocates new + * strings. * * @param a The first string. * @param b The second string.
--- a/pidgin/gtkprefs.c Sun Apr 15 18:44:44 2007 +0000 +++ b/pidgin/gtkprefs.c Sun Apr 15 18:52:54 2007 +0000 @@ -610,7 +610,7 @@ ret = 1; } else { /* Neither string is "none", default to normal sort */ - ret = g_utf8_collate(name1,name2); + ret = purple_utf8_strcasecmp(name1,name2); } g_free(name1);
--- a/pidgin/gtkthemes.c Sun Apr 15 18:44:44 2007 +0000 +++ b/pidgin/gtkthemes.c Sun Apr 15 18:52:54 2007 +0000 @@ -63,6 +63,35 @@ } } +static void +pidginthemes_destroy_smiley_theme(struct smiley_theme *theme) +{ + GHashTable *already_freed; + struct smiley_list *wer; + + already_freed = g_hash_table_new(g_direct_hash, g_direct_equal); + for (wer = theme->list; wer != NULL; wer = theme->list) { + while (wer->smileys) { + GtkIMHtmlSmiley *uio = wer->smileys->data; + if (uio->icon) + g_object_unref(uio->icon); + if (g_hash_table_lookup(already_freed, uio->file) == NULL) { + g_free(uio->file); + g_hash_table_insert(already_freed, uio->file, GINT_TO_POINTER(1)); + } + g_free(uio->smile); + g_free(uio); + wer->smileys = g_slist_remove(wer->smileys, uio); + } + theme->list = wer->next; + g_free(wer->sml); + g_free(wer); + } + theme->list = NULL; + + g_hash_table_destroy(already_freed); +} + void pidginthemes_load_smiley_theme(const char *file, gboolean load) { FILE *f = g_fopen(file, "r"); @@ -164,7 +193,7 @@ smiley->file = sfile; smiley->smile = g_strdup(l); smiley->hidden = hidden; - list->smileys = g_slist_append(list->smileys, smiley); + list->smileys = g_slist_prepend(list->smileys, smiley); have_used_sfile = TRUE; } while (isspace(*i)) @@ -180,31 +209,9 @@ fclose(f); if (!theme->name || !theme->desc || !theme->author) { - GSList *already_freed = NULL; - struct smiley_list *wer = theme->list, *wer2; - purple_debug_error("gtkthemes", "Invalid file format, not loading smiley theme from '%s'\n", file); - while (wer) { - while (wer->smileys) { - GtkIMHtmlSmiley *uio = wer->smileys->data; - if (uio->icon) - g_object_unref(uio->icon); - if (!g_slist_find(already_freed, uio->file)) { - g_free(uio->file); - already_freed = g_slist_append(already_freed, uio->file); - } - g_free(uio->smile); - g_free(uio); - wer->smileys = g_slist_remove(wer->smileys, uio); - } - wer2 = wer->next; - g_free(wer->sml); - g_free(wer); - wer = wer2; - } - theme->list = NULL; - g_slist_free(already_freed); + pidginthemes_destroy_smiley_theme(theme); g_free(theme->name); g_free(theme->desc); @@ -217,36 +224,14 @@ } if (new_theme) { - smiley_themes = g_slist_append(smiley_themes, theme); + smiley_themes = g_slist_prepend(smiley_themes, theme); } if (load) { GList *cnv; - if (current_smiley_theme) { - GSList *already_freed = NULL; - struct smiley_list *wer = current_smiley_theme->list, *wer2; - while (wer) { - while (wer->smileys) { - GtkIMHtmlSmiley *uio = wer->smileys->data; - if (uio->icon) - g_object_unref(uio->icon); - if (!g_slist_find(already_freed, uio->file)) { - g_free(uio->file); - already_freed = g_slist_append(already_freed, uio->file); - } - g_free(uio->smile); - g_free(uio); - wer->smileys = g_slist_remove(wer->smileys, uio); - } - wer2 = wer->next; - g_free(wer->sml); - g_free(wer); - wer = wer2; - } - current_smiley_theme->list = NULL; - g_slist_free(already_freed); - } + if (current_smiley_theme) + pidginthemes_destroy_smiley_theme(current_smiley_theme); current_smiley_theme = theme; for (cnv = purple_get_conversations(); cnv != NULL; cnv = cnv->next) {