}
static gint
-rspamd_ast_do_op (struct rspamd_expression_elt *elt, gint val, gint acc, gint lim)
+rspamd_ast_do_op (struct rspamd_expression_elt *elt, gint val,
+ gint acc, gint lim, gboolean first_elt)
{
gint ret = val;
ret = acc + val;
break;
case OP_GE:
- ret = acc >= lim;
+ ret = first_elt ? (val >= lim) : (acc >= lim);
break;
case OP_GT:
- ret = acc > lim;
+ ret = first_elt ? (val > lim) : (acc > lim);
break;
case OP_LE:
- ret = acc <= lim;
+ ret = first_elt ? (val <= lim) : (acc <= lim);
break;
case OP_LT:
- ret = acc < lim;
+ ret = first_elt ? (val < lim) : (acc < lim);
break;
case OP_MULT:
case OP_AND:
- ret = acc && val;
+ ret = first_elt ? (val) : (acc && val);
break;
case OP_OR:
- ret = acc || val;
+ ret = first_elt ? (val) : (acc || val);
break;
default:
g_assert (0);
val = rspamd_ast_process_node (expr, flags, cld, data, track);
if (acc == G_MININT) {
- acc = val;
+ acc = rspamd_ast_do_op (elt, val, 0, lim, TRUE);
+ }
+ else {
+ acc = rspamd_ast_do_op (elt, val, acc, lim, FALSE);
}
-
- acc = rspamd_ast_do_op (elt, val, acc, lim);
if (!(flags & RSPAMD_EXPRESSION_FLAG_NOOPT)) {
if (rspamd_ast_node_done (elt, parelt, acc, lim)) {