diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2014-10-02 11:02:14 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2014-10-02 12:52:50 +0200 |
commit | b2f008378a39104152b20a969942cd6c99644984 (patch) | |
tree | c3b502cb6e4dbeb33f1082037c4c24635dbdd1f6 /filter/config.Y | |
parent | 0479b44373892db273f3e0365c7cbaad2eeb0d5f (diff) |
Allows more constants in set literals.
Thanks to Michael Fincham for the bugreport.
Diffstat (limited to 'filter/config.Y')
-rw-r--r-- | filter/config.Y | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/filter/config.Y b/filter/config.Y index 04acfbab..e50e75ca 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -25,6 +25,23 @@ static inline u32 pair_b(u32 p) { return p & 0xFFFF; } * to the last item in a list (right ptr). For convenience, even items * are handled as one-item lists. Lists are merged by f_merge_items(). */ +static int +f_valid_set_type(int type) +{ + switch (type) + { + case T_INT: + case T_PAIR: + case T_QUAD: + case T_ENUM: + case T_IP: + case T_EC: + return 1; + + default: + return 0; + } +} static inline struct f_tree * f_new_item(struct f_val from, struct f_val to) @@ -473,10 +490,19 @@ fipa: */ set_atom: - expr { $$.type = T_INT; $$.val.i = $1; } + NUM { $$.type = T_INT; $$.val.i = $1; } | RTRID { $$.type = T_QUAD; $$.val.i = $1; } | fipa { $$ = $1; } | ENUM { $$.type = pair_a($1); $$.val.i = pair_b($1); } + | '(' term ')' { + $$ = f_eval($2, cfg_mem); + if (!f_valid_set_type($$.type)) cf_error("Set-incompatible type"); + } + | SYM { + if (!cf_symbol_is_constant($1)) cf_error("%s: constant expected", $1->name); + if (!f_valid_set_type(SYM_TYPE($1))) cf_error("%s: set-incompatible type", $1->name); + $$ = *(struct f_val *)($1->def); + } ; switch_atom: |