diff options
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.114 2004/06/02 13:50:46 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.115 2004/06/02 19:06:14 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 | */ |
@@ -243,6 +243,8 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname, | |||
243 | if (lua_isnil(L, -1)) { /* no? */ | 243 | if (lua_isnil(L, -1)) { /* no? */ |
244 | lua_pop(L, 1); | 244 | lua_pop(L, 1); |
245 | lua_newtable(L); /* create it */ | 245 | lua_newtable(L); /* create it */ |
246 | if (lua_getmetatable(L, LUA_GLOBALSINDEX)) | ||
247 | lua_setmetatable(L, -2); /* share metatable with global table */ | ||
246 | lua_pushvalue(L, -1); | 248 | lua_pushvalue(L, -1); |
247 | /* register it with given name */ | 249 | /* register it with given name */ |
248 | lua_setglobal(L, libname); | 250 | lua_setglobal(L, libname); |