diff options
author | 2015-11-14 11:45:43 +0000 | |
---|---|---|
committer | 2015-11-14 11:45:43 +0000 | |
commit | 39d4fc02d8206b43e19f7b5ff5a46d60565cfbc5 (patch) | |
tree | 1b2051a39a034281767436ca338147fc794ab025 /usr.bin/tmux/key-string.c | |
parent | Rename a variable in utf8_combine for consistency and use 0xfffd for (diff) | |
download | wireguard-openbsd-39d4fc02d8206b43e19f7b5ff5a46d60565cfbc5.tar.xz wireguard-openbsd-39d4fc02d8206b43e19f7b5ff5a46d60565cfbc5.zip |
All these return values from utf8_* are confusing, use an enum.
Diffstat (limited to 'usr.bin/tmux/key-string.c')
-rw-r--r-- | usr.bin/tmux/key-string.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/tmux/key-string.c b/usr.bin/tmux/key-string.c index be03d06b17b..335a516112b 100644 --- a/usr.bin/tmux/key-string.c +++ b/usr.bin/tmux/key-string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-string.c,v 1.31 2015/11/14 10:57:59 nicm Exp $ */ +/* $OpenBSD: key-string.c,v 1.32 2015/11/14 11:45:43 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -144,10 +144,11 @@ key_string_lookup_string(const char *string) static const char *other = "!#()+,-.0123456789:;<=>?'\r\t"; key_code key; u_short u; - int size, more; + int size; key_code modifiers; struct utf8_data ud; u_int i; + enum utf8_state more; /* Is this a hexadecimal value? */ if (string[0] == '0' && string[1] == 'x') { @@ -173,13 +174,12 @@ key_string_lookup_string(const char *string) return (KEYC_NONE); } else { /* Try as a UTF-8 key. */ - if (utf8_open(&ud, (u_char)*string)) { + if ((more = utf8_open(&ud, (u_char)*string)) == UTF8_MORE) { if (strlen(string) != ud.size) return (KEYC_NONE); - more = 1; for (i = 1; i < ud.size; i++) more = utf8_append(&ud, (u_char)string[i]); - if (more != 0) + if (more != UTF8_DONE) return (KEYC_NONE); key = utf8_combine(&ud); return (key | modifiers); @@ -256,7 +256,7 @@ key_string_lookup_key(key_code key) /* Is this a UTF-8 key? */ if (key > 127 && key < KEYC_BASE) { - if (utf8_split(key, &ud) == 0) { + if (utf8_split(key, &ud) == UTF8_DONE) { memcpy(out, ud.data, ud.size); out[ud.size] = '\0'; return (out); |