]> mj.ucw.cz Git - umpf.git/blobdiff - code.c
redo variables
[umpf.git] / code.c
diff --git a/code.c b/code.c
index 2200d234dc8229f46172e576699f5499d56fb7d0..932bb9ab5d8766c3a43f508a43b5add5b27825ab 100644 (file)
--- a/code.c
+++ b/code.c
@@ -34,35 +34,34 @@ get_bucket_number(char* name)
 
 /* return var struct or NULL if not found */
 struct variable*
-get_var_struct(char* name, struct list* hash)
+get_var_struct(char* name, enum var_type type, struct list* hash)
 {
        int n;
        struct variable *p;
 
        n = get_bucket_number(name);
-       int nocase = isupper(*name);
        LIST_FOREACH(p, hash + n)
-               if (!(nocase ? strcasecmp : strcmp)(p->name,name))
+               if (!strcasecmp(p->name, name) && p->type == type)
                        return p;
 
        return NULL;
 }
 
 int
-find_var(char* name, struct list* hash)
+find_var(char* name, enum var_type type, struct list* hash)
 {
        int n;
        struct variable *p;
 
        n = get_bucket_number(name);
-       int nocase = isupper(*name);
        LIST_FOREACH(p, hash + n)
-               if (!(nocase ? strcasecmp : strcmp)(p->name,name))
+               if (!strcasecmp(p->name, name) && p->type == type)
                        return p->varcode;
 
        p = xmalloc(sizeof(struct variable));
        p->name = xstrdup(name);
        p->varcode = current_varcode++;
+       p->type = type;
        list_add_last(hash+n, &p->car);
 
        return p->varcode;