Allow matching on enums:

if !(scope ~ [ SCOPE_HOST, SCOPE_SITE ]) then {
                print "Failed in test";
                quitbird;
        }
This commit is contained in:
Pavel Machek 2000-06-01 08:32:49 +00:00
parent 42542c56c2
commit 1895e81e05
3 changed files with 20 additions and 8 deletions

View file

@ -226,6 +226,7 @@ set_atom:
| pair { $$.type = T_PAIR; $$.val.i = $1; } | pair { $$.type = T_PAIR; $$.val.i = $1; }
| fipa { $$ = $1; } | fipa { $$ = $1; }
| fprefix { $$ = $1; } | fprefix { $$ = $1; }
| ENUM { $$.type = $1 >> 16; $$.val.i = $1 & 0xffff; }
; ;
set_item: set_item:

View file

@ -143,14 +143,21 @@ val_in_range(struct f_val v1, struct f_val v2)
if (res != CMP_ERROR) if (res != CMP_ERROR)
return res; return res;
if (((v1.type == T_INT) || ((v1.type == T_IP) || (v1.type == T_PREFIX)) && (v2.type == T_SET))) { if (v2.type == T_SET)
struct f_tree *n; switch (v1.type) {
n = find_tree(v2.val.t, v1); case T_ENUM:
if (!n) case T_INT:
return 0; case T_IP:
return !! (val_simple_in_range(v1, n->from)); /* We turn CMP_ERROR into compared ok, and that's fine */ case T_PREFIX:
} {
struct f_tree *n;
n = find_tree(v2.val.t, v1);
if (!n)
return 0;
return !! (val_simple_in_range(v1, n->from)); /* We turn CMP_ERROR into compared ok, and that's fine */
}
}
return CMP_ERROR; return CMP_ERROR;
} }

View file

@ -36,6 +36,10 @@ protocol static {
print scope; print scope;
scope = SCOPE_HOST; scope = SCOPE_HOST;
print scope; print scope;
if !(scope ~ [ SCOPE_HOST, SCOPE_SITE ]) then {
print "Failed in test";
quitbird;
}
preference = 15; preference = 15;
print preference; print preference;