aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-08 15:57:43 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-08 16:35:42 +0100
commit561594bb943bfdc9c9b888c1eacc2a6d34ca882b (patch)
tree06f78a8d9351964807b0578e6f47ecaac1fcf073 /src
parent47e27ce0f8ecf8dff0f9abc0e0fb466a64fdc736 (diff)
downloadrspamd-561594bb943bfdc9c9b888c1eacc2a6d34ca882b.tar.gz
rspamd-561594bb943bfdc9c9b888c1eacc2a6d34ca882b.zip
[Minor] Allow to create fann from table of layers
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_fann.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lua/lua_fann.c b/src/lua/lua_fann.c
index 3d15c6417..51d42b573 100644
--- a/src/lua/lua_fann.c
+++ b/src/lua/lua_fann.c
@@ -116,8 +116,17 @@ lua_fann_create (lua_State *L)
if (nlayers > 0) {
layers = g_malloc (nlayers * sizeof (layers[0]));
- for (i = 0; i < nlayers; i ++) {
- layers[i] = luaL_checknumber (L, i + 2);
+ if (lua_type (L, 2) == LUA_TNUMBER) {
+ for (i = 0; i < nlayers; i ++) {
+ layers[i] = luaL_checknumber (L, i + 2);
+ }
+ }
+ else if (lua_type (L, 2) == LUA_TTABLE) {
+ for (i = 0; i < nlayers; i ++) {
+ lua_rawgeti (L, 2, i + 1);
+ layers[i] = luaL_checknumber (L, -1);
+ lua_pop (L, 1);
+ }
}
f = fann_create_standard_array (nlayers, layers);