diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-12-05 13:23:54 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-12-05 13:23:54 +0000 |
commit | 022977e0b7c160e6e33ec07f2c41f60707d43cb6 (patch) | |
tree | d2474ca5b8d68e3f9c677a7ede0aecb8f7ac6ee9 /src/lua/lua_config.c | |
parent | 9192f3cf4ca5d2fbc8701bcfe91edcfa1ee3192c (diff) | |
download | rspamd-022977e0b7c160e6e33ec07f2c41f60707d43cb6.tar.gz rspamd-022977e0b7c160e6e33ec07f2c41f60707d43cb6.zip |
[Rework] Adopt code for the new options
Diffstat (limited to 'src/lua/lua_config.c')
-rw-r--r-- | src/lua/lua_config.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 7c2b84609..48bb36e6d 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -808,6 +808,7 @@ lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud) gint level = lua_gettop (cd->L), nresults, err_idx; lua_State *L = cd->L; GString *tb; + struct symbol *s; lua_pushcfunction (L, &rspamd_lua_traceback); err_idx = lua_gettop (L); @@ -837,7 +838,6 @@ lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud) if (nresults >= 1) { /* Function returned boolean, so maybe we need to insert result? */ gint res = 0; - GList *opts = NULL; gint i; gdouble flag = 1.0; @@ -860,17 +860,18 @@ lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud) flag = res; } - for (i = lua_gettop (L); i >= level + first_opt; i--) { - if (lua_type (L, i) == LUA_TSTRING) { - const char *opt = lua_tostring (L, i); + s = rspamd_task_insert_result (task, cd->symbol, flag, NULL); - opts = g_list_prepend (opts, - rspamd_mempool_strdup (task->task_pool, - opt)); + if (s) { + for (i = lua_gettop (L); i >= level + first_opt; i--) { + if (lua_type (L, i) == LUA_TSTRING) { + const char *opt = lua_tostring (L, i); + + rspamd_task_add_result_option (task, s, opt); + } } } - rspamd_task_insert_result (task, cd->symbol, flag, opts); } lua_pop (L, nresults); |