watch: interpret esc[m sequence

Commit 99fa7f removed watch crashing from having the null ANSI
sequence. However it just ignored that sequence instead of fixing it.

This change correctly checks buf (not undefined endptr) and sends
the reset attribute if found.

Closes: #12
This commit is contained in:
Craig Small 2015-11-18 22:48:09 +11:00
parent 471cf4cd36
commit 61dcba87c1

View File

@ -228,6 +228,9 @@ static void process_ansi(FILE * fp)
* attributes to apply, but typically there are between 1 and 3. * attributes to apply, but typically there are between 1 and 3.
*/ */
/* Special case of <ESC>[m */
if (buf[0] == '\0')
set_ansi_attribute(0);
for (endptr = numstart = buf; *endptr != '\0'; numstart = endptr + 1) { for (endptr = numstart = buf; *endptr != '\0'; numstart = endptr + 1) {
set_ansi_attribute(strtol(numstart, &endptr, 10)); set_ansi_attribute(strtol(numstart, &endptr, 10));