ref: 2edbdb8b2a7914d14f1b080179a057879144378e
parent: 664e782912da639d082308433dd7dddfcf9922ce
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu May 7 11:18:13 EDT 2015
Add newline() This function increment the current line number and check if the file is too long (more of 65536 lines).
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -64,6 +64,13 @@
return input->nline;
}
+static void
+newline(void)
+{
+ if (++input->nline == 0)
+ die("input file too long");
+}
+
static uint8_t
integer(char *s, char base)
{
@@ -181,7 +188,7 @@
warn("character constant out of range");
break;
case '\n':
- ++input->nline;
+ newline();
if ((c = getchar()) == '\\')
goto repeat;
break;
@@ -403,7 +410,7 @@
while (isspace(c = getchar())) {
if (c == '\n')
- ++input->nline;
+ newline();
}
return c;
}