summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorPavel Tvrdik <pawel.tvrdik@gmail.com>2016-09-20 15:13:01 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2016-09-21 13:35:52 +0200
commit768d5e1058693d2bfb7c3bcbe04306097c3246a0 (patch)
tree97b6d1887b7cea60e31f11fd989a605fd931be53 /filter
parent75ac3d199d1fd5b199dd753915234b8634c272e5 (diff)
Add !~ operator to filter grammar
Diffstat (limited to 'filter')
-rw-r--r--filter/config.Y1
-rw-r--r--filter/filter.c10
2 files changed, 11 insertions, 0 deletions
diff --git a/filter/config.Y b/filter/config.Y
index da605710..9fffd651 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -735,6 +735,7 @@ term:
| term '>' term { $$ = f_new_inst(); $$->code = '<'; $$->a1.p = $3; $$->a2.p = $1; }
| term GEQ term { $$ = f_new_inst(); $$->code = P('<','='); $$->a1.p = $3; $$->a2.p = $1; }
| term '~' term { $$ = f_new_inst(); $$->code = '~'; $$->a1.p = $1; $$->a2.p = $3; }
+ | term NMA term { $$ = f_new_inst(); $$->code = P('!','~'); $$->a1.p = $1; $$->a2.p = $3; }
| '!' term { $$ = f_new_inst(); $$->code = '!'; $$->a1.p = $2; }
| DEFINED '(' term ')' { $$ = f_new_inst(); $$->code = P('d','e'); $$->a1.p = $3; }
diff --git a/filter/filter.c b/filter/filter.c
index ccdfed36..2f5f00d8 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -716,6 +716,16 @@ interpret(struct f_inst *what)
runtime( "~ applied on unknown type pair" );
res.val.i = !!res.val.i;
break;
+
+ case P('!','~'):
+ TWOARGS;
+ res.type = T_BOOL;
+ res.val.i = val_in_range(v1, v2);
+ if (res.val.i == CMP_ERROR)
+ runtime( "!~ applied on unknown type pair" );
+ res.val.i = !res.val.i;
+ break;
+
case P('d','e'):
ONEARG;
res.type = T_BOOL;