]> mj.ucw.cz Git - umpf.git/commitdiff
cleanup
authorAnicka Bernathova <anicka@anicka.net>
Sun, 13 Jul 2008 22:37:12 +0000 (00:37 +0200)
committerAnicka Bernathova <anicka@anicka.net>
Sun, 13 Jul 2008 22:37:12 +0000 (00:37 +0200)
Makefile
int.c

index a699feef1a8a5a548ecf9eef8f092bb4bf15b7c2..beb1a6ec5ba7bc627dece8d5edc0193c72099f1e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 all: brum 
 
 CC=gcc
-CFLAGS=-Wall -W -Wno-pointer-sign  -g
+CFLAGS=-Wall -W -Wno-pointer-sign -Wstrict-prototypes -Wmissing-prototypes -O2 -g
 LDLIBS=-lpcre
 
 brum: brum.c cond.tab.o int.o lex.o ham.o lists.o
diff --git a/int.c b/int.c
index a9481808cb3b0b09cd888bdf76e0cc8511005cc6..8da089bfa4c15f5e73474107222aa8f4c997d2c6 100644 (file)
--- a/int.c
+++ b/int.c
@@ -42,40 +42,26 @@ get_bucket_number(char* name)
 static struct variable*
 find_var(char* name, char* value, struct list* hash)
 {
-       int n, found = 0;
+       int n;
        struct variable *p;
 
        n = get_bucket_number(name);
-
-       if (isupper(*name)){
-               LIST_FOREACH(p, hash + n)
-                       if (!strcasecmp(p->name,name)){
-                               found = 1;
-                               break;
-                       }
-       } else {
-               LIST_FOREACH(p, hash + n)
-                       if (!strcmp(p->name, name)){
-                               found = 1;
-                               break;
+       int nocase = !isupper(*name);
+       LIST_FOREACH(p, hash + n)
+               if (!(nocase ? strcasecmp : strcmp)(p->name,name)){
+                       if (value){
+                               free(p->value);
+                               p->value = value;
+                               p->modified = 1;
                        }
-       }
-
-       if (found && value){
-               free(p->value);
-               p->value = value;
-               p->modified = 1;
-       } else if (found && !value)
-               return p;
-       else {
-               p = xmalloc(sizeof(struct variable));
-               p->name = name; 
-               p->value = (value? value:xstrdup(""));
-               p->modified = 1;
-
-               list_add_last(hash+n, &p->car);
-       }
+                       return p;
+               }
 
+       p = xmalloc(sizeof(struct variable));
+       p->name = xstrdup(name); 
+       p->value = (value? value:xstrdup(""));
+       p->modified = 1;
+       list_add_last(hash+n, &p->car);
        return p;
 }
 
@@ -220,6 +206,8 @@ interp_cond(struct tree* t, struct list* hash)
                                return regex_cmp(left,right);
                        case CC('!','~'):
                                return !regex_cmp(left,right);
+                       default:
+                               die("Brrrchlemst!");
                } //TODO: add numbers
 
        } else {
@@ -238,6 +226,8 @@ interp_cond(struct tree* t, struct list* hash)
                                return (left || right) && !(left && right);
                        case '!':
                                return !left;
+                       default:
+                               die("Brrrchlemst!");
                }
        }
 }