[hackers] [scc] Fix #line || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 18 Jul 2015 10:27:46 +0200 (CEST)

commit afa1694d36865e5f2d5858e641c573502edaef92
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Jul 18 09:08:28 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sat Jul 18 09:08:28 2015 +0200

    Fix #line
    
    The validation of the fields in #line were incorrect, and the last
    token was not consumed, generating an error in cpp() due to garbage
    at the end of the line.

diff --git a/cc1/cpp.c b/cc1/cpp.c
index 3eecc54..094bd65 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -409,15 +409,14 @@ too_long:
 static void
 line(void)
 {
- Type *tp;
         long n;
+ char *endp;
 
         if (cppoff)
                 return;
- if ((n = strtol(input->p, &input->p, 10)) <= 0 || n > USHRT_MAX)
- error("first parameter of #line is not a positive integer");
 
- if (yytoken != CONSTANT || yylval.sym->type != inttype)
+ n = strtol(yytext, &endp, 10);
+ if (n <= 0 || n > USHRT_MAX || *endp != '\0')
                 error("first parameter of #line is not a positive integer");
 
         input->nline = yylval.sym->u.i;
_AT_@ -425,11 +424,11 @@ line(void)
         if (yytoken == EOFTOK)
                 return;
 
- tp = yylval.sym->type;
- if (yytoken != CONSTANT || tp->op != ARY && tp->type != chartype)
+ if (*yytext != '\"'|| yylen == 1)
                 error("second parameter of #line is not a valid filename");
         free(input->fname);
         input->fname = xstrdup(yylval.sym->u.s);
+ next();
 }
 
 static void
Received on Sat Jul 18 2015 - 10:27:46 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 18 2015 - 10:36:11 CEST