diff options
author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2020-04-24 09:41:56 +0300 |
---|---|---|
committer | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2020-04-24 10:14:33 +0300 |
commit | 77738ac6f572edc0b34879b5741e192ccb89a9e7 (patch) | |
tree | 578cddc6de39059d3298bda47a3869ba893f4749 | |
parent | b036e56e67a79ea45b5faf4baf38ca2ff2129416 (diff) | |
download | mpv-77738ac6f572edc0b34879b5741e192ccb89a9e7.tar.bz2 mpv-77738ac6f572edc0b34879b5741e192ccb89a9e7.tar.xz |
win32: SGR emulation: minor fixup on invalid sequence
This fixes two issues with invalid value after 38/48:
- It was not detected correctly and ended up skipping 4 instead of 0.
- The intent was to skip 0, but it's better to skip the rest.
Behavior with valid 2/5 after 38/48 was correct and is unaffected.
-rw-r--r-- | osdep/terminal-win.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/osdep/terminal-win.c b/osdep/terminal-win.c index 27740f9be3..e19f7dbe96 100644 --- a/osdep/terminal-win.c +++ b/osdep/terminal-win.c @@ -304,8 +304,11 @@ void mp_write_console_ansi(HANDLE wstream, char *buf) attr |= stdoutAttrs & BACKGROUND_ALL; } else if (p == 38 || p == 48) { // ignore and skip sub-values // 256 colors: <38/48>;5;N true colors: <38/48>;2;R;G;B - if (n+1 < num_params) - n += params[n+1] == 5 ? 2 : 2 ? 4 : 0; + if (n+1 < num_params) { + n += params[n+1] == 5 ? 2 + : params[n+1] == 2 ? 4 + : num_params; /* unrecognized -> the rest */ + } } } |