From 77738ac6f572edc0b34879b5741e192ccb89a9e7 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Fri, 24 Apr 2020 09:41:56 +0300 Subject: 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. --- osdep/terminal-win.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'osdep') 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 */ + } } } -- cgit v1.2.3