summaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lauxlib.c b/lauxlib.c
index dcb913f0..2eaa163b 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.194 2009/11/25 15:27:51 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.195 2009/12/17 16:20:01 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*/
@@ -73,7 +73,7 @@ static int findfield (lua_State *L, int objidx, int level) {
73static int pushglobalfuncname (lua_State *L, lua_Debug *ar) { 73static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
74 int top = lua_gettop(L); 74 int top = lua_gettop(L);
75 lua_getinfo(L, "f", ar); /* push function */ 75 lua_getinfo(L, "f", ar); /* push function */
76 lua_pushvalue(L, LUA_GLOBALSINDEX); /* push global table */ 76 lua_pushglobaltable(L);
77 if (findfield(L, top + 1, 2)) { 77 if (findfield(L, top + 1, 2)) {
78 lua_copy(L, -1, top + 1); /* move name to proper place */ 78 lua_copy(L, -1, top + 1); /* move name to proper place */
79 lua_pop(L, 2); /* remove pushed values */ 79 lua_pop(L, 2); /* remove pushed values */
@@ -678,7 +678,8 @@ LUALIB_API void luaL_register (lua_State *L, const char *libname,
678 if (!lua_istable(L, -1)) { /* not found? */ 678 if (!lua_istable(L, -1)) { /* not found? */
679 lua_pop(L, 1); /* remove previous result */ 679 lua_pop(L, 1); /* remove previous result */
680 /* try global variable (and create one if it does not exist) */ 680 /* try global variable (and create one if it does not exist) */
681 if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, libsize(l)) != NULL) 681 lua_pushglobaltable(L);
682 if (luaL_findtable(L, 0, libname, libsize(l)) != NULL)
682 luaL_error(L, "name conflict for module " LUA_QS, libname); 683 luaL_error(L, "name conflict for module " LUA_QS, libname);
683 lua_pushvalue(L, -1); 684 lua_pushvalue(L, -1);
684 lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ 685 lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */
@@ -713,7 +714,7 @@ LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
713LUALIB_API const char *luaL_findtable (lua_State *L, int idx, 714LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
714 const char *fname, int szhint) { 715 const char *fname, int szhint) {
715 const char *e; 716 const char *e;
716 lua_pushvalue(L, idx); 717 if (idx) lua_pushvalue(L, idx);
717 do { 718 do {
718 e = strchr(fname, '.'); 719 e = strchr(fname, '.');
719 if (e == NULL) e = fname + strlen(fname); 720 if (e == NULL) e = fname + strlen(fname);