Improve error reporting of incomplete SGR codes

This commit is contained in:
Kovid Goyal
2017-11-05 10:17:40 +05:30
parent 3cb74a25ba
commit a614fe615f
2 changed files with 15 additions and 4 deletions

View File

@@ -487,13 +487,23 @@ parse_sgr(Screen *screen, uint32_t *buf, unsigned int num, unsigned int *params,
SEND_SGR;
break;
case COLOR1:
case COLOR3:
case NORMAL:
case MULTIPLE:
READ_PARAM;
SEND_SGR;
if (i > num_start) { READ_PARAM; }
if (num_params) { SEND_SGR; }
else { REPORT_ERROR("Incomplete SGR code"); }
break;
default:
case COLOR:
REPORT_ERROR("Invalid SGR code containing incomplete semi-colon separated color sequence");
break;
case COLOR3:
if (i > num_start) READ_PARAM;
if (num_params != 5) {
REPORT_ERROR("Invalid SGR code containing incomplete semi-colon separated color sequence");
break;
}
if (num_params) { SEND_SGR; }
else { REPORT_ERROR("Incomplete SGR code"); }
break;
}
#undef READ_PARAM