From: Anicka Bernathova Date: Wed, 2 Jul 2008 13:32:14 +0000 (+0200) Subject: hura! X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=31c10c20686bedf984ae26def24d7ee73f833391;p=umpf.git hura! --- 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; }