diff options
author | wm4 <wm4@nowhere> | 2013-10-28 23:29:08 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-10-28 23:29:08 +0100 |
commit | e10b362bdb3772bd0634607cfe4d5ef27515777b (patch) | |
tree | 3e653bf4b759b3b0fec05f2823c1f189fec729d0 /osdep | |
parent | 40e68d65146518b9db2380a571b7dd6dabcf3585 (diff) | |
download | mpv-e10b362bdb3772bd0634607cfe4d5ef27515777b.tar.bz2 mpv-e10b362bdb3772bd0634607cfe4d5ef27515777b.tar.xz |
getch2: move global state to file scope variables
Using static variables for mutable state inside functions is a bad idea,
because it's not immediately obvious that it is what it is.
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/getch2.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/osdep/getch2.c b/osdep/getch2.c index e1586dc2eb..13eb47bc29 100644 --- a/osdep/getch2.c +++ b/osdep/getch2.c @@ -340,6 +340,11 @@ void get_screen_size(void) { static unsigned char getch2_buf[BUF_LEN]; static int getch2_len = 0; static int getch2_pos = 0; +static enum { + STATE_INITIAL, + STATE_UTF8, +} state = STATE_INITIAL; +static int utf8_len = 0; static void walk_buf(unsigned int count) { if (!(count < BUF_LEN && count <= getch2_len)) @@ -365,12 +370,6 @@ bool getch2(struct input_ctx *input_ctx) return retval; getch2_len += retval; - static enum { - STATE_INITIAL = 0, - STATE_UTF8, - } state = STATE_INITIAL; - static int utf8_len = 0; - while (getch2_pos < getch2_len) { unsigned char c = getch2_buf[getch2_pos++]; |