pidgin: f4772c83: Modified patch from Andrei Mozzhuhin to ...
sadrul at pidgin.im
sadrul at pidgin.im
Thu May 1 18:47:54 EDT 2008
-----------------------------------------------------------------
Revision: f4772c83f8bb71a92817219521ee475abba9d365
Ancestor: 39e32015d9933273a0bf98e480cbaa3e311eb02e
Author: sadrul at pidgin.im
Date: 2008-05-01T22:42:21
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/f4772c83f8bb71a92817219521ee475abba9d365
Modified files:
COPYRIGHT pidgin/gtkconv.c
ChangeLog:
Modified patch from Andrei Mozzhuhin to fix tab-completion when non-ascii
characters are involved. Closes #5653.
-------------- next part --------------
============================================================
--- COPYRIGHT 5b9d56f5744968846cb64e5d7468df21edcad9c3
+++ COPYRIGHT 346b900169ce7f59809c8d73d79502e35544a52c
@@ -263,6 +263,7 @@ Sergio Moretto
John Moody
Tim Mooney
Sergio Moretto
+Andrei Mozzhuhin
Christian Muise
Richard Nelson
Dennis Nezic
============================================================
--- pidgin/gtkconv.c 81c12dc5e72ca53472850497a17763689b7479cb
+++ pidgin/gtkconv.c a2421f1b66a110d21f7e59c46ae4a55b1fb44a0d
@@ -3980,11 +3980,10 @@ static void
}
static void
-tab_complete_process_item(int *most_matched, char *entered, char **partial, char *nick_partial,
+tab_complete_process_item(int *most_matched, char *entered, gsize entered_bytes, char **partial, char *nick_partial,
GList **matches, gboolean command, char *name)
{
- strncpy(nick_partial, name, strlen(entered));
- nick_partial[strlen(entered)] = '\0';
+ memcpy(nick_partial, name, entered_bytes);
if (purple_utf8_strcasecmp(nick_partial, entered))
return;
@@ -4029,6 +4028,7 @@ tab_complete(PurpleConversation *conv)
const char *prefix;
GList *matches = NULL;
gboolean command = FALSE;
+ gsize entered_bytes = 0;
gtkconv = PIDGIN_CONVERSATION(conv);
@@ -4048,19 +4048,24 @@ tab_complete(PurpleConversation *conv)
/* if we're at the end of ": " we need to move back 2 spaces */
start = strlen(text) - 1;
- if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) {
+ if (start >= 1 && !strncmp(&text[start-1], ": ", 2)) {
gtk_text_iter_backward_chars(&word_start, 2);
- start-=2;
}
- /* find the start of the word that we're tabbing */
- while (start >= 0 && text[start] != ' ') {
- gtk_text_iter_backward_char(&word_start);
- start--;
+ /* find the start of the word that we're tabbing.
+ * Using gtk_text_iter_backward_word_start won't work, because a nick can contain
+ * characters (e.g. '.', '/' etc.) that Pango may think are word separators. */
+ while (gtk_text_iter_backward_char(&word_start)) {
+ if (gtk_text_iter_get_char(&word_start) == ' ') {
+ /* Reached the whitespace before the start of the word. Move forward once */
+ gtk_text_iter_forward_char(&word_start);
+ break;
+ }
}
prefix = pidgin_get_cmd_prefix();
- if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) {
+ if (gtk_text_iter_get_offset(&word_start) == 0 &&
+ (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) {
command = TRUE;
gtk_text_iter_forward_chars(&word_start, strlen(prefix));
}
@@ -4069,13 +4074,14 @@ tab_complete(PurpleConversation *conv)
entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start,
&cursor, FALSE);
+ entered_bytes = strlen(entered);
if (!g_utf8_strlen(entered, -1)) {
g_free(entered);
return (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) ? TRUE : FALSE;
}
- nick_partial = g_malloc(strlen(entered)+1);
+ nick_partial = g_malloc0(entered_bytes + 1);
if (command) {
GList *list = purple_cmd_list(conv);
@@ -4083,7 +4089,7 @@ tab_complete(PurpleConversation *conv)
/* Commands */
for (l = list; l != NULL; l = l->next) {
- tab_complete_process_item(&most_matched, entered, &partial, nick_partial,
+ tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial,
&matches, TRUE, l->data);
}
g_list_free(list);
@@ -4096,7 +4102,7 @@ tab_complete(PurpleConversation *conv)
/* Users */
for (; l != NULL; l = l->next) {
- tab_complete_process_item(&most_matched, entered, &partial, nick_partial,
+ tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial,
&matches, TRUE, ((PurpleConvChatBuddy *)l->data)->name);
}
@@ -4114,7 +4120,7 @@ tab_complete(PurpleConversation *conv)
-1);
if (name && alias && strcmp(name, alias))
- tab_complete_process_item(&most_matched, entered, &partial, nick_partial,
+ tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial,
&matches, FALSE, alias);
g_free(name);
g_free(alias);
More information about the Commits
mailing list