diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-30 15:57:47 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-30 15:57:47 +0100 |
commit | e94fe5faba0b43fa9685988e0290c5c84e2ff048 (patch) | |
tree | 0cf9f20922254665e79dc1491f996e8bd4439495 | |
parent | 633b66378c1eb7ea7f65887272eccc0d80fdc61a (diff) | |
download | rspamd-e94fe5faba0b43fa9685988e0290c5c84e2ff048.tar.gz rspamd-e94fe5faba0b43fa9685988e0290c5c84e2ff048.zip |
Fix comparision operators.
-rw-r--r-- | src/libutil/expression.c | 12 | ||||
-rw-r--r-- | test/lua/unit/expressions.lua | 1 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/libutil/expression.c b/src/libutil/expression.c index d4559e765..7faebb547 100644 --- a/src/libutil/expression.c +++ b/src/libutil/expression.c @@ -863,7 +863,7 @@ rspamd_ast_node_done (struct rspamd_expression_elt *elt, } static gint -rspamd_ast_do_op (struct rspamd_expression_elt *elt, gint val, gint acc) +rspamd_ast_do_op (struct rspamd_expression_elt *elt, gint val, gint acc, gint lim) { gint ret = val; @@ -877,16 +877,16 @@ rspamd_ast_do_op (struct rspamd_expression_elt *elt, gint val, gint acc) ret = acc + val; break; case OP_GE: - ret = acc >= val; + ret = acc >= lim; break; case OP_GT: - ret = acc > val; + ret = acc > lim; break; case OP_LE: - ret = acc <= val; + ret = acc <= lim; break; case OP_LT: - ret = acc < val; + ret = acc < lim; break; case OP_MULT: case OP_AND: @@ -980,7 +980,7 @@ rspamd_ast_process_node (struct rspamd_expression *expr, gint flags, GNode *node acc = val; } - acc = rspamd_ast_do_op (elt, val, acc); + acc = rspamd_ast_do_op (elt, val, acc, lim); if (!(flags & RSPAMD_EXPRESSION_FLAG_NOOPT)) { if (rspamd_ast_node_done (elt, parelt, acc, lim)) { diff --git a/test/lua/unit/expressions.lua b/test/lua/unit/expressions.lua index 1dc92997e..b2e66e8cc 100644 --- a/test/lua/unit/expressions.lua +++ b/test/lua/unit/expressions.lua @@ -85,6 +85,7 @@ context("Rspamd expressions", function() {'(A + B + C + D) > 1 && F || E', 1}, {'(A + B + C + D) > 100 && F || !E', 0}, {'F && ((A + B + C + D) > 1)', 0}, + {'(E) && ((B + B + B + B) >= 1)', 0}, {'!!C', 1}, } for _,c in ipairs(cases) do |