aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_config.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-17 18:53:07 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-17 18:53:07 +0100
commit795b01a1b5a4998cb3d2b004ce109e0f505076eb (patch)
tree69885d1f3b18c2596fc0d5fc041624dc06131d8e /src/lua/lua_config.c
parentc6a703e720a6a3d20a86db115272ca356d59fa11 (diff)
downloadrspamd-795b01a1b5a4998cb3d2b004ce109e0f505076eb.tar.gz
rspamd-795b01a1b5a4998cb3d2b004ce109e0f505076eb.zip
Really allow to specify multiplier in return value.
Diffstat (limited to 'src/lua/lua_config.c')
-rw-r--r--src/lua/lua_config.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 5eddcbb82..2862c62de 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -635,11 +635,20 @@ lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud)
gboolean res;
GList *opts = NULL;
gint i;
+ gdouble flag = 1.0;
if (lua_type (cd->L, level + 1) == LUA_TBOOLEAN) {
res = lua_toboolean (cd->L, level + 1);
if (res) {
- for (i = lua_gettop (cd->L); i > level + 1; i --) {
+ gint first_opt = 2;
+
+ if (lua_type (cd->L, level + 2) == LUA_TNUMBER) {
+ flag = lua_tonumber (cd->L, level + 2);
+ /* Shift opt index */
+ first_opt = 3;
+ }
+
+ for (i = lua_gettop (cd->L); i >= level + first_opt; i --) {
if (lua_type (cd->L, i) == LUA_TSTRING) {
const char *opt = lua_tostring (cd->L, i);
@@ -647,7 +656,7 @@ lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud)
rspamd_mempool_strdup (task->task_pool, opt));
}
}
- insert_result (task, cd->symbol, 1.0, opts);
+ insert_result (task, cd->symbol, flag, opts);
}
}
lua_pop (cd->L, nresults);