mirror of
https://github.com/lua/lua.git
synced 2025-01-14 05:43:00 +08:00
BUG: loadlib should not use Lua internals (lobject.h)
This commit is contained in:
parent
1a455acc81
commit
df50c84ee0
14
loadlib.c
14
loadlib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: loadlib.c,v 1.55 2006/09/11 14:07:24 roberto Exp roberto $
|
** $Id: loadlib.c,v 1.56 2006/10/10 17:40:17 roberto Exp roberto $
|
||||||
** Dynamic library loader for Lua
|
** Dynamic library loader for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
**
|
**
|
||||||
@ -16,9 +16,9 @@
|
|||||||
#define loadlib_c
|
#define loadlib_c
|
||||||
#define LUA_LIB
|
#define LUA_LIB
|
||||||
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "lobject.h"
|
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
|
||||||
|
#include "lauxlib.h"
|
||||||
#include "lualib.h"
|
#include "lualib.h"
|
||||||
|
|
||||||
|
|
||||||
@ -361,7 +361,7 @@ static const char *findfile (lua_State *L, const char *name,
|
|||||||
lua_remove(L, -2); /* remove path template */
|
lua_remove(L, -2); /* remove path template */
|
||||||
if (readable(filename)) /* does file exist and is readable? */
|
if (readable(filename)) /* does file exist and is readable? */
|
||||||
return filename; /* return that file name */
|
return filename; /* return that file name */
|
||||||
luaO_pushfstring(L, "\n\tno file " LUA_QS, filename);
|
lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
|
||||||
lua_remove(L, -2); /* remove file name */
|
lua_remove(L, -2); /* remove file name */
|
||||||
lua_concat(L, 2); /* add entry to possible error message */
|
lua_concat(L, 2); /* add entry to possible error message */
|
||||||
}
|
}
|
||||||
@ -422,8 +422,8 @@ static int loader_Croot (lua_State *L) {
|
|||||||
funcname = mkfuncname(L, name);
|
funcname = mkfuncname(L, name);
|
||||||
if ((stat = ll_loadfunc(L, filename, funcname)) != 0) {
|
if ((stat = ll_loadfunc(L, filename, funcname)) != 0) {
|
||||||
if (stat != ERRFUNC) loaderror(L, filename); /* real error */
|
if (stat != ERRFUNC) loaderror(L, filename); /* real error */
|
||||||
luaO_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,
|
lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,
|
||||||
name, filename);
|
name, filename);
|
||||||
return 1; /* function not found */
|
return 1; /* function not found */
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -437,7 +437,7 @@ static int loader_preload (lua_State *L) {
|
|||||||
luaL_error(L, LUA_QL("package.preload") " must be a table");
|
luaL_error(L, LUA_QL("package.preload") " must be a table");
|
||||||
lua_getfield(L, -1, name);
|
lua_getfield(L, -1, name);
|
||||||
if (lua_isnil(L, -1)) /* not found? */
|
if (lua_isnil(L, -1)) /* not found? */
|
||||||
luaO_pushfstring(L, "\n\tno field package.preload['%s']", name);
|
lua_pushfstring(L, "\n\tno field package.preload['%s']", name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user