From 31c10c20686bedf984ae26def24d7ee73f833391 Mon Sep 17 00:00:00 2001 From: Anicka Bernathova Date: Wed, 2 Jul 2008 15:32:14 +0200 Subject: [PATCH] hura! --- cond.y | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cond.y b/cond.y index 746dc40..0155cbd 100644 --- a/cond.y +++ b/cond.y @@ -41,6 +41,7 @@ boo: CONST EQ CONST { $$ = ! strcmp($1, $3); } %% #include +#include #define BUFSIZE 4096 @@ -48,24 +49,26 @@ int yylex(void) { - int c, last; - char temp[BUFSIZE]; - char* p=temp; + int i, c, last; while ((c = getchar ()) == ' ' || c == '\t'); if (c == '"'){ last = '"'; + i = 0; + if (!(yylval.str = malloc(BUFSIZE))){ + puts("Low memory"); + exit(0); + } while ((c = getchar()) != '"' || last == '\\'){ - *p = c; + yylval.str[i] = c; last = c; - p++; - if (p-temp >= BUFSIZE-1) + i++; + if (i >= BUFSIZE-1) break; } - *p = '\0'; + yylval.str[i] = '\0'; - strcpy(&yylval,temp); return CONST; } -- 2.39.2