From 56c17ba4c7bfc1ed6df3d255f056053745835769 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 17 Jan 2008 14:24:30 -0200 Subject: detail --- lauxlib.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index 91a62dc8..f5e1a764 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.174 2007/09/14 13:26:28 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.175 2008/01/03 17:07:59 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -586,14 +586,13 @@ static int libsize (const luaL_Reg *l) { LUALIB_API void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l) { if (libname) { - int size = libsize(l); /* check whether lib already exists */ - luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", size); + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); lua_getfield(L, -1, libname); /* get _LOADED[libname] */ if (!lua_istable(L, -1)) { /* not found? */ lua_pop(L, 1); /* remove previous result */ /* try global variable (and create one if it does not exist) */ - if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, libsize(l)) != NULL) luaL_error(L, "name conflict for module " LUA_QS, libname); lua_pushvalue(L, -1); lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ -- cgit v1.2.3-55-g6feb