From 778dd8b3d546183b640965195804997fd2ac1a22 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 8 Jul 2016 00:32:59 -0700 Subject: [PATCH] watch: Don't attempt to ungetc parts of unknown ANSI escape sequences If process_ansi encountered an unknown character when processing an ANSI escape sequence, it would ungetc all the characters read so far, except for the character just read, and the opening '\033['. ungetting the middle of the escape sequence does not produce useful results, and also relies on the unportable assumption that ungetc works on multiple characters (which glibc does not support). Discard the characters instead. Signed-off-by: Josh Triplett --- watch.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/watch.c b/watch.c index c2078089..277807e1 100644 --- a/watch.c +++ b/watch.c @@ -217,8 +217,6 @@ static void process_ansi(FILE * fp) break; } if ((c < '0' || c > '9') && c != ';') { - while (--i >= 0) - ungetc(buf[i], fp); return; } buf[i] = (char)c; -- 2.40.0