commit 253f3681886a5e397379a8a2cf9df9884c0926b6
parent 8ec7fbf712e7b396a36fdfffe6070e47ed7b00b1
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
Date: Wed, 27 Apr 2016 22:00:02 +0200
[cc2] Give a better message in line without newline
In this case cc2 was printing the message of line too long, which
was wrong, but both cases shared the same test, line without newline.
Diffstat:
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/cc2/cc2.h b/cc2/cc2.h
@@ -113,6 +113,7 @@ enum nerrors {
ESTACKO, /* stack overflow */
ESTACKU, /* stack underflow */
ELNLINE, /* line too long */
+ ELNBLNE, /* line without new line */
EFERROR, /* error reading from file:%s*/
EBADID, /* incorrect symbol id */
ENUMERR
diff --git a/cc2/parser.c b/cc2/parser.c
@@ -313,7 +313,7 @@ repeat:
if ((len = strlen(line)) == 0 || line[0] == '\n')
goto repeat;
if (line[len-1] != '\n')
- error(ELNLINE);
+ error(len < sizeof(line)-1 ? ELNBLNE : ELNLINE);
line[len-1] = '\0';
c = *line;