mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
40e68d6514
commit
e10b362bdb
|
@ -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++];
|
||||
|
||||
|
|
Loading…
Reference in New Issue