aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-01-17 14:24:30 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-01-17 14:24:30 -0200
commit56c17ba4c7bfc1ed6df3d255f056053745835769 (patch)
tree2632572a9a00f086c3b4bc3fca61bfd04510fcaf
parentdaddc57abd31e30215922a716cb6d26422f3658b (diff)
downloadlua-56c17ba4c7bfc1ed6df3d255f056053745835769.tar.gz
lua-56c17ba4c7bfc1ed6df3d255f056053745835769.tar.bz2
lua-56c17ba4c7bfc1ed6df3d255f056053745835769.zip
detail
-rw-r--r--lauxlib.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 91a62dc8..f5e1a764 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.174 2007/09/14 13:26:28 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.175 2008/01/03 17:07:59 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -586,14 +586,13 @@ static int libsize (const luaL_Reg *l) {
586LUALIB_API void luaL_register (lua_State *L, const char *libname, 586LUALIB_API void luaL_register (lua_State *L, const char *libname,
587 const luaL_Reg *l) { 587 const luaL_Reg *l) {
588 if (libname) { 588 if (libname) {
589 int size = libsize(l);
590 /* check whether lib already exists */ 589 /* check whether lib already exists */
591 luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", size); 590 luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
592 lua_getfield(L, -1, libname); /* get _LOADED[libname] */ 591 lua_getfield(L, -1, libname); /* get _LOADED[libname] */
593 if (!lua_istable(L, -1)) { /* not found? */ 592 if (!lua_istable(L, -1)) { /* not found? */
594 lua_pop(L, 1); /* remove previous result */ 593 lua_pop(L, 1); /* remove previous result */
595 /* try global variable (and create one if it does not exist) */ 594 /* try global variable (and create one if it does not exist) */
596 if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) 595 if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, libsize(l)) != NULL)
597 luaL_error(L, "name conflict for module " LUA_QS, libname); 596 luaL_error(L, "name conflict for module " LUA_QS, libname);
598 lua_pushvalue(L, -1); 597 lua_pushvalue(L, -1);
599 lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ 598 lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */