summaryrefslogtreecommitdiffstats
path: root/src/lua/lua_regexp.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-25 13:17:21 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-25 13:17:21 +0100
commitc2765b3eb3c3beb3d9f42dc061761df2e300904c (patch)
tree0f5924f4fd821b16a258465d9dcb0068e5332bf2 /src/lua/lua_regexp.c
parenta1be94b4c4b59de216e0b8b721a951b2325f7215 (diff)
downloadrspamd-c2765b3eb3c3beb3d9f42dc061761df2e300904c.tar.gz
rspamd-c2765b3eb3c3beb3d9f42dc061761df2e300904c.zip
Use modules preload for lua.
Diffstat (limited to 'src/lua/lua_regexp.c')
-rw-r--r--src/lua/lua_regexp.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c
index 41703bc04..4e893d81d 100644
--- a/src/lua/lua_regexp.c
+++ b/src/lua/lua_regexp.c
@@ -274,7 +274,16 @@ lua_regexp_destroy (lua_State *L)
return 0;
}
-gint
+static gint
+lua_load_regexp (lua_State * L)
+{
+ lua_newtable (L);
+ luaL_register (L, NULL, regexplib_f);
+
+ return 1;
+}
+
+void
luaopen_glib_regexp (lua_State * L)
{
luaL_newmetatable (L, "rspamd{regexp}");
@@ -286,10 +295,8 @@ luaopen_glib_regexp (lua_State * L)
lua_pushstring (L, "rspamd{regexp}");
lua_rawset (L, -3);
- luaL_register (L, NULL, regexplib_m);
- luaL_register (L, "regexp", regexplib_f);
+ luaL_register (L, NULL, regexplib_m);
+ rspamd_lua_add_preload (L, "regexp", lua_load_regexp);
regexp_static_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
-
- return 1;
}