summaryrefslogtreecommitdiffstats
path: root/tty-keys.c
diff options
context:
space:
mode:
authornicm <nicm>2015-11-14 11:45:43 +0000
committernicm <nicm>2015-11-14 11:45:43 +0000
commit205d15e82d9e4aa90c7980b509d3489ad8eb6c2a (patch)
treedf0a0b3b1181ca5822722638eae32721d7711463 /tty-keys.c
parentf401791a5689799ddf3cfa6ecee7da60318febf7 (diff)
All these return values from utf8_* are confusing, use an enum.
Diffstat (limited to 'tty-keys.c')
-rw-r--r--tty-keys.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tty-keys.c b/tty-keys.c
index cc6b934a..52dae4f7 100644
--- a/tty-keys.c
+++ b/tty-keys.c
@@ -472,9 +472,10 @@ tty_keys_next(struct tty *tty)
const char *buf;
size_t len, size;
cc_t bspace;
- int delay, expired = 0, more;
+ int delay, expired = 0;
key_code key;
struct utf8_data ud;
+ enum utf8_state more;
u_int i;
/* Get key buffer. */
@@ -539,17 +540,16 @@ first_key:
}
/* Is this valid UTF-8? */
- if (utf8_open(&ud, (u_char)*buf)) {
+ if ((more = utf8_open(&ud, (u_char)*buf) == UTF8_MORE)) {
size = ud.size;
if (len < size) {
if (expired)
goto discard_key;
goto partial_key;
}
- more = 1;
for (i = 1; i < size; i++)
more = utf8_append(&ud, (u_char)buf[i]);
- if (more != 0)
+ if (more != UTF8_DONE)
goto discard_key;
key = utf8_combine(&ud);
log_debug("UTF-8 key %.*s %#llx", (int)size, buf, key);
@@ -656,7 +656,7 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size)
struct utf8_data ud;
u_int i, value, x, y, b, sgr_b;
u_char sgr_type, c;
- int more;
+ enum utf8_state more;
/*
* Standard mouse sequences are \033[M followed by three characters
@@ -697,14 +697,14 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size)
return (1);
if (tty->mode & MODE_MOUSE_UTF8) {
- if (utf8_open(&ud, buf[*size])) {
+ if (utf8_open(&ud, buf[*size]) == UTF8_MORE) {
if (ud.size != 2)
return (-1);
(*size)++;
if (len <= *size)
return (1);
more = utf8_append(&ud, buf[*size]);
- if (more != 0)
+ if (more != UTF8_DONE)
return (-1);
value = utf8_combine(&ud);
} else