summaryrefslogtreecommitdiffstats
path: root/src/libutil/expression.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-07-16 14:41:17 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-07-16 14:41:17 +0100
commit7fd9e99c6c1884593eb17dcb71734701b95c726a (patch)
tree4f9a428756f1f11917ccb33c4b204bfde2561b81 /src/libutil/expression.c
parenta4864356682637d4bede27a618e4da0097162cb5 (diff)
downloadrspamd-7fd9e99c6c1884593eb17dcb71734701b95c726a.tar.gz
rspamd-7fd9e99c6c1884593eb17dcb71734701b95c726a.zip
[Fix] Fix expressions logic for and/or and float values
Diffstat (limited to 'src/libutil/expression.c')
-rw-r--r--src/libutil/expression.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/libutil/expression.c b/src/libutil/expression.c
index fc967f404..553767c3a 100644
--- a/src/libutil/expression.c
+++ b/src/libutil/expression.c
@@ -29,7 +29,6 @@
#define MIN_RESORT_EVALS 50
#define MAX_RESORT_EVALS 150
-#define DOUBLE_EPSILON 1e-9
enum rspamd_expression_elt_type {
ELT_OP = 0,
@@ -1232,7 +1231,7 @@ rspamd_ast_do_unary_op (struct rspamd_expression_elt *elt, gdouble operand)
switch (elt->p.op.op) {
case OP_NOT:
- ret = fabs (operand) > DOUBLE_EPSILON ? 0.0 : 1.0;
+ ret = fabs (operand) > DBL_EPSILON ? 0.0 : 1.0;
break;
default:
g_assert_not_reached ();
@@ -1306,10 +1305,10 @@ rspamd_ast_do_nary_op (struct rspamd_expression_elt *elt, gdouble val, gdouble a
ret = acc * val;
break;
case OP_AND:
- ret = (acc * val);
+ ret = (acc > DBL_EPSILON) && (val > DBL_EPSILON);
break;
case OP_OR:
- ret = (acc + val);
+ ret = (acc > DBL_EPSILON) || (val > DBL_EPSILON);
break;
default:
case OP_NOT:
@@ -1355,7 +1354,7 @@ rspamd_ast_process_node (struct rspamd_expression *e, GNode *node,
elt->value = process_data->process_closure (process_data->ud, elt->p.atom);
- if (fabs (elt->value) > 1e-9) {
+ if (fabs (elt->value) > DBL_EPSILON) {
elt->p.atom->hits ++;
if (process_data->trace) {