summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kamil Kozar <dkk089@gmail.com>2017-11-19 03:43:01 +0100
committerDaniel Kamil Kozar <dkk089@gmail.com>2017-11-19 03:43:01 +0100
commit6452e8ffe24532385f8338e96dc34b76d8b85a1a (patch)
tree2e95015e35ddd8b28f83c19bd360524ed72d45c0
parent1b13b8cd2c16bfeafc5a69e8765d46eb2a5536a9 (diff)
downloadpidgin-6452e8ffe24532385f8338e96dc34b76d8b85a1a.tar.gz
Use utf8 functions in gtk_smiley_tree_lookup
-rw-r--r--pidgin/gtkimhtml.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/pidgin/gtkimhtml.c b/pidgin/gtkimhtml.c
index ef55686c33..d758697f76 100644
--- a/pidgin/gtkimhtml.c
+++ b/pidgin/gtkimhtml.c
@@ -2052,44 +2052,48 @@ static gint
gtk_smiley_tree_lookup (GtkSmileyTree *tree,
const gchar *text)
{
+ gunichar text_ch = g_utf8_get_char(text);
GtkSmileyTree *t = tree;
- const gchar *x = text;
- const gchar *amp;
- gint alen;
gint len = 0;
gint lastlen = 0;
-
- while (*x) {
+
+ while (text_ch) {
+ const gchar *amp;
gchar *pos;
+ gint alen;
if (!t->values)
break;
- if(*x == '&' && (amp = purple_markup_unescape_entity(x, &alen))) {
+ if((amp = purple_markup_unescape_entity(text, &alen))) {
gboolean matched = TRUE;
+ const char *amp_next = g_utf8_next_char(amp);
+
/* Make sure all chars of the unescaped value match */
- while (*(amp + 1)) {
- pos = strchr (t->values->str, *amp);
+ while (g_utf8_get_char(amp_next)) {
+ pos = g_utf8_strchr (t->values->str, -1, g_utf8_get_char(amp));
if (pos)
t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)];
else {
matched = FALSE;
break;
}
- amp++;
+ amp = amp_next;
+ amp_next = g_utf8_next_char(amp_next);
}
+
if (!matched)
break;
-
- pos = strchr (t->values->str, *amp);
+
+ pos = g_utf8_strchr (t->values->str, -1, g_utf8_get_char(amp));
}
- else if (*x == '<') /* Because we're all WYSIWYG now, a '<'
+ else if (text_ch == '<') /* Because we're all WYSIWYG now, a '<'
* char should only appear as the start of a tag. Perhaps a safer (but costlier)
* check would be to call gtk_imhtml_is_tag on it */
break;
else {
- alen = 1;
- pos = strchr (t->values->str, *x);
+ alen = g_unichar_to_utf8 (text_ch, NULL);
+ pos = g_utf8_strchr (t->values->str, -1, text_ch);
}
if (pos) {
@@ -2099,8 +2103,9 @@ gtk_smiley_tree_lookup (GtkSmileyTree *tree,
} else
break;
- x += alen;
len += alen;
+ text = g_utf8_next_char(text);
+ text_ch = g_utf8_get_char(text);
}
if (t->image)