]> khamidou — GitHub mirrors - croma.git/commitdiff
fixing a bug
authorkhamidou <karim@lambda-expr.org>
Wed, 25 Feb 2009 20:51:46 +0000 (21:51 +0100)
committerkhamidou <karim@lambda-expr.org>
Wed, 25 Feb 2009 20:51:46 +0000 (21:51 +0100)
parse.c
tokens.h

diff --git a/parse.c b/parse.c
index c6d697d45b44d144d9772ddab605ebf32f2116c1..7135de8794d90a9406839810502c6e17f47b39cd 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -22,13 +22,13 @@ void expect(int t)
 
 }
 
-int init_parser(void)
+void init_parser(void)
 {
        TAILQ_INIT(&blocks_head);
 }
 
 
-int yyparse(void)
+void yyparse(void)
 {
        int t = yylex();
 
@@ -59,20 +59,20 @@ void foreach_expr(void)
        parse_block(b);
 
        char *p = b->parameters;
-       char *t = b->contents;
-       if (t == NULL)
+       char *c = b->contents;
+       if (c == NULL)
                abort("the impossible happened : b->contents == NULL !, file: %s, line %d", __FILE__, __LINE__);        
 
        while(strcmp(p, "\0") != 0) {
-               while(t != '\0') {
-                       if (*t == '$' && *t+1 == '$') {
+               while(c != '\0') {
+                       if (*c == '$' && *c+1 == '$') {
                                printf("%s", p);
-                       t++; /* skip them second '$' */
+                       c++; /* skip them second '$' */
                        } else {
-                               printf("%c", *t);
+                               printf("%c", *c);
                        }
                        
-                       t++;
+                       c++;
                }
                p++;
        }
@@ -85,6 +85,8 @@ void parse_arglist(struct croma_block *b)
                abort("the impossible happened : b == NULL !, file: %s, line %d", __FILE__, __LINE__);
 
        b->parameters = malloc(16*sizeof(char *));
+       char *s = b->parameters;
+
        int i;
        int t = yylex();
 
@@ -95,13 +97,12 @@ void parse_arglist(struct croma_block *b)
        */
        for (i = 0; i < 16; i++)
        {
-               b->parameters + i = strndup(yytext, MAX_PARAM_LEN);
+               *s++ = strndup(yytext, MAX_PARAM_LEN);
                expect(COMMA);
                expect(WORD);
        }
 
-       i++;
-       b->parameters + i = "\0";
+       *s++ = "\0";
 
        expect(RPAREN);
 
index bb2afc9a4798eba86aba6c8a6dd12708933b0e64..3631c6a9b422afb71cbe816b7528609d78d71b70 100644 (file)
--- a/tokens.h
+++ b/tokens.h
@@ -2,7 +2,8 @@
 #define __TOKENS_H__
 
 enum {
-       LPAREN, RPAREN, LBRACKET, RBRACKET, WORD, DOLDOL, SPACES, COMMA, FOREACH,
+       LPAREN, RPAREN, LBRACKET, RBRACKET, WORD, DOLDOL, SPACES, COMMA, 
+       FOREACH,
 };
 
 char *token_list[] = { "left parenthesis",