[hackers] [scc] [cc2] Give a better message in line without newline || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 28 Apr 2016 22:12:14 +0200 (CEST)

commit 253f3681886a5e397379a8a2cf9df9884c0926b6
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
AuthorDate: Wed Apr 27 22:00:02 2016 +0200
Commit: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
CommitDate: Wed Apr 27 22:00:02 2016 +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.

diff --git a/cc2/cc2.h b/cc2/cc2.h
index b79e6d2..9cb5c14 100644
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
_AT_@ -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
index 89a9e48..09b2353 100644
--- a/cc2/parser.c
+++ b/cc2/parser.c
_AT_@ -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;
Received on Thu Apr 28 2016 - 22:12:14 CEST

This archive was generated by hypermail 2.3.0 : Thu Apr 28 2016 - 22:24:16 CEST