keyboard: Don't use next_utf8_char() to go back where we came from

We go one utf8 char back and then one forward.  Just remember the original
position instead, which also avoids a warning about potentially
dereferencing a NULL return value from next_utf8_char().
dev
Kristian Høgsberg 11 years ago
parent 0a8461b95e
commit 20ffdffc03
  1. 12
      clients/keyboard.c

@ -456,16 +456,6 @@ prev_utf8_char(const char *s, const char *p)
return NULL; return NULL;
} }
static const char *
next_utf8_char(const char *p)
{
if (*p == '\0')
return NULL;
for (++p; (*p & 0xc0) == 0x80; ++p)
;
return p;
}
static void static void
delete_before_cursor(struct virtual_keyboard *keyboard) delete_before_cursor(struct virtual_keyboard *keyboard)
{ {
@ -483,7 +473,7 @@ delete_before_cursor(struct virtual_keyboard *keyboard)
return; return;
} }
end = next_utf8_char(start); end = keyboard->surrounding_text + keyboard->surrounding_cursor;
wl_input_method_context_delete_surrounding_text(keyboard->context, wl_input_method_context_delete_surrounding_text(keyboard->context,
(start - keyboard->surrounding_text) - keyboard->surrounding_cursor, (start - keyboard->surrounding_text) - keyboard->surrounding_cursor,

Loading…
Cancel
Save