ref: 68ccb5a199aa86efb8b07f550a64860cb5da950d
parent: 84ae6c8c605f208229ccf38cfcc6b42ae735b1db
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun May 10 07:58:33 EDT 2015
Add yylen variable This variable holds the length of the current lexem.
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -29,6 +29,7 @@
uint8_t yytoken;
struct yystype yylval;
char yytext[IDENTSIZ + 1];
+unsigned short yylen;
static uint8_t safe;
static Input *input;
@@ -206,12 +207,10 @@
static void
tok2str(void)
{
- size_t len;
-
- if ((len = input->p - input->begin) > IDENTSIZ)
+ if ((yylen = input->p - input->begin) > IDENTSIZ)
error("token too big");
- strncpy(yytext, input->begin, len);
- yytext[len] = '\0';
+ strncpy(yytext, input->begin, yylen);
+ yytext[yylen] = '\0';
fprintf(stderr ,"%s\n", yytext);
input->begin = input->p;
}