ref: 77f45146adc228d86119395efa68aa0fb1437191
parent: 249ecda69e6ec6de2dde995cc370239e9ff3e775
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Oct 31 03:54:55 EDT 2021
cc1: Add proper handling of strings too long When a string is too long we can just ignore everything until we find end of string or quotes.
--- a/src/cmd/cc/cc1/lex.c
+++ b/src/cmd/cc/cc1/lex.c
@@ -554,8 +554,15 @@
if (c == '\\')
c = escape();
if (bp == &yytext[STRINGSIZ+1]) {
- /* TODO: proper error handling here */
- error("string too long");
+ for (++input->p; *input->p != '"'; ++input->p) {
+ if (*input->p == '\\')
+ ++input->p;
+ if (*input->p == '\0')
+ break;
+ }
+ --bp;
+ errorp("string too long");
+ break;
}
*bp++ = c;
}