aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar kmeaw <kmeaw@flib.ru>2009-06-11 13:11:57 +0400
committerGravatar kmeaw <kmeaw@flib.ru>2009-06-11 13:11:57 +0400
commit1b3399fc78549bb54cde385e63518e70e504b90c (patch)
treeceddca14fcd4c8d1d3c568e42e3cf3b7ce5cc84c /uzbl.c
parent05fe402bb00c85a6f4c044c0917f2a6bfee87f89 (diff)
keycmd_bs: fix invalid utf-8 char chopping code
This code failed on strings that end on a multibyte character.
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/uzbl.c b/uzbl.c
index f1c27b1..6c99db8 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -883,9 +883,12 @@ keycmd_nl (WebKitWebView *page, GArray *argv) {
static void
keycmd_bs (WebKitWebView *page, GArray *argv) {
+ gchar *prev;
(void)page;
(void)argv;
- g_string_truncate(uzbl.state.keycmd, uzbl.state.keycmd->len - 1);
+ prev = g_utf8_find_prev_char(uzbl.state.keycmd->str, uzbl.state.keycmd->str + uzbl.state.keycmd->len);
+ if (prev)
+ g_string_truncate(uzbl.state.keycmd, prev - uzbl.state.keycmd->str);
update_title();
}