[hackers] [scc] [cc1] Fix readline() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 12 Jan 2017 08:57:50 +0100 (CET)

commit bde0ef892aeb95d7aaa95ffb11b0bd82b2a31d9c
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Jan 12 08:51:17 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Jan 12 08:51:17 2017 +0100

    [cc1] Fix readline()
    
    After the modification of macro expansions to use push up buffers
    readline was broken, because after expanding a macro we have
    to return always from readline, otherwise we can remove some
    newline from the input. This new version also makes better use
    of 'goto' than the previous version.

diff --git a/cc1/lex.c b/cc1/lex.c
index d861be6..d7e8aa3 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
_AT_@ -202,27 +202,21 @@ readline(void)
         char *bp, *lim;
         char c, peekc = 0;
 
-repeat_from_file:
- *input->line = '\0';
- input->p = input->line;
-
-repeat_from_expand:
- input->begin = input->p;
-
- if (*input->begin)
- return 1;
+repeat:
 
         if (eof)
                 return 0;
-
         if (!input->fp) {
                 delinput();
- goto repeat_from_expand;
+ return 1;
         }
         if (feof(input->fp)) {
                 delinput();
- goto repeat_from_file;
+ goto repeat;
         }
+
+ *input->line = '\0';
+ input->begin = input->p = input->line;
         lim = &input->line[INPUTSIZ-1];
         for (bp = input->line; bp < lim; *bp++ = c) {
                 c = (peekc) ? peekc : readchar();
Received on Thu Jan 12 2017 - 08:57:50 CET

This archive was generated by hypermail 2.3.0 : Thu Jan 12 2017 - 09:00:17 CET