scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 70920c23871f743fcdd012868694af575fc9045b
parent 490b2ddc64c800327ab07b4b3e5e56ed434fd38e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 19 Jan 2017 09:57:54 +0100

[cc1] Improve error handling in string()

Diffstat:
Mcc1/lex.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/cc1/lex.c b/cc1/lex.c @@ -515,12 +515,16 @@ string(void) *bp++ = '"'; repeat: for (++input->p; (c = *input->p) != '"'; ++input->p) { - if (c == '\0') - error("missing terminating '\"' character"); + if (c == '\0') { + errorp("missing terminating '\"' character"); + break; + } if (c == '\\') c = escape(); - if (bp == &yytext[STRINGSIZ+1]) + if (bp == &yytext[STRINGSIZ+1]) { + /* TODO: proper error handling here */ error("string too long"); + } *bp++ = c; }