summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShmuel Zeigerman <solomuz0@gmail.com>2012-04-04 13:04:03 +0300
committerShmuel Zeigerman <solomuz0@gmail.com>2012-04-04 13:04:03 +0300
commit20d043ccd51ae389cb189ac0c569cf9d714fbd31 (patch)
treea7558574fca53eaa3844b223a35ce46ffff4126a /src
parent6539761e2883147256aa366f87d7f1fb20e402b0 (diff)
downloadlrexlib-20d043ccd51ae389cb189ac0c569cf9d714fbd31.tar.gz
Add macro REX_CREATEGLOBALVAR.
Diffstat (limited to 'src')
-rw-r--r--src/algo.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/algo.h b/src/algo.h
index 39c7de9..2db4c81 100644
--- a/src/algo.h
+++ b/src/algo.h
@@ -668,7 +668,7 @@ static int algm_exec (lua_State *L) {
static void alg_register (lua_State *L, const luaL_Reg *r_methods,
const luaL_Reg *r_functions, const char *name) {
- /* create a new function environment to serve as a metatable for methods */
+ /* Create a new function environment to serve as a metatable for methods. */
#if LUA_VERSION_NUM == 501
lua_newtable (L);
lua_pushvalue (L, -1);
@@ -682,14 +682,18 @@ static void alg_register (lua_State *L, const luaL_Reg *r_methods,
lua_pushvalue(L, -1); /* mt.__index = mt */
lua_setfield(L, -2, "__index");
- /* register functions */
+ /* Register functions. */
+ lua_createtable(L, 0, 8);
#if LUA_VERSION_NUM == 501
- luaL_register (L, REX_LIBNAME, r_functions);
+ luaL_register (L, NULL, r_functions);
#else
- lua_newtable(L);
lua_pushvalue(L, -2);
luaL_setfuncs (L, r_functions, 1);
#endif
+#ifdef REX_CREATEGLOBALVAR
+ lua_pushvalue(L, -1);
+ lua_setglobal(L, REX_LIBNAME);
+#endif
lua_pushfstring (L, REX_VERSION" (for %s)", name);
lua_setfield (L, -2, "_VERSION");
}