diff options
author | Matthias Clasen <mclasen@redhat.com> | 2007-03-19 04:27:45 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2007-03-19 04:27:45 +0000 |
commit | a5978a15ec17c66c46415b89911e9633229cfed2 (patch) | |
tree | bfe5e7e50bcaa8141b22ad46e035785229b47305 /gtk/gtkentrycompletion.c | |
parent | f326c1e9ec6ed808656f1de5523c4a15a601747e (diff) | |
download | gtk+-a5978a15ec17c66c46415b89911e9633229cfed2.tar.gz |
Ensure that the prefix is valid UTF-8. (#419568, Nickolay V. Shmyrev)
2007-03-18 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkentrycompletion.c (gtk_entry_completion_compute_prefix):
Ensure that the prefix is valid UTF-8. (#419568, Nickolay V. Shmyrev)
svn path=/trunk/; revision=17543
Diffstat (limited to 'gtk/gtkentrycompletion.c')
-rw-r--r-- | gtk/gtkentrycompletion.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c index d4c51b4f49..d8bc08a06a 100644 --- a/gtk/gtkentrycompletion.c +++ b/gtk/gtkentrycompletion.c @@ -1500,7 +1500,7 @@ gtk_entry_completion_compute_prefix (GtkEntryCompletion *completion) else { gchar *p = prefix; - const gchar *q = text; + gchar *q = text; while (*p && *p == *q) { @@ -1509,6 +1509,19 @@ gtk_entry_completion_compute_prefix (GtkEntryCompletion *completion) } *p = '\0'; + + if (p > prefix) + { + /* strip a partial multibyte character */ + q = g_utf8_find_prev_char (prefix, p); + switch (g_utf8_get_char_validated (q, p - q)) + { + case (gunichar)-2: + case (gunichar)-1: + *q = 0; + default: ; + } + } } } |