scc

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

commit b213e5a835707e8d347e804d9911c13526138f07
parent 7b0ece05732ca278a0e18e40c16f29804f01c5cc
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 11 May 2015 10:10:16 +0200

Add better error control in #line

Diffstat:
Mcc1/cpp.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -85,6 +85,8 @@ line(char *s) { char *p, *q; + if (!isdigit(*p)) + goto bad_line; for (p = s; isdigit(*p); ++p) /* nothing */; switch (*p) { @@ -106,11 +108,13 @@ line(char *s) setfline(atoi(s)-1); return p; default: - goto bad_line; + goto bad_file; } +bad_file: + error("second parameter of #line is not a valid filename"); bad_line: - error("incorrect #line directive"); + error("first parameter of #line is not a positive integer"); } static char *