Script: Removed various Lua functions (check LuaModifications.txt)

This commit is contained in:
Birunthan Mohanathas 2012-07-10 14:30:45 +03:00
parent 71aac3f6c2
commit bf15830f15
9 changed files with 46 additions and 45 deletions

View File

@ -360,6 +360,7 @@
<ClCompile Include="lua\lua\ldump.c" />
<ClCompile Include="lua\lua\lfunc.c" />
<ClCompile Include="lua\lua\lgc.c" />
<ClCompile Include="lua\lua\linit.c" />
<ClCompile Include="lua\lua\liolib.c" />
<ClCompile Include="lua\lua\llex.c" />
<ClCompile Include="lua\lua\lmathlib.c" />

View File

@ -180,6 +180,9 @@
<ClCompile Include="lua\lua\lgc.c">
<Filter>Lua\Lua</Filter>
</ClCompile>
<ClCompile Include="lua\lua\linit.c">
<Filter>Lua\Lua</Filter>
</ClCompile>
<ClCompile Include="lua\lua\liolib.c">
<Filter>Lua\Lua</Filter>
</ClCompile>

View File

@ -30,25 +30,7 @@ void LuaManager::Initialize()
// Initialize Lua
c_State = luaL_newstate();
// Initialize standard libraries except debug, modified from linit.c
const luaL_Reg lualibs[] =
{
{ "", luaopen_base },
{ LUA_LOADLIBNAME, luaopen_package },
{ LUA_TABLIBNAME, luaopen_table },
{ LUA_IOLIBNAME, luaopen_io },
{ LUA_OSLIBNAME, luaopen_os },
{ LUA_STRLIBNAME, luaopen_string },
{ LUA_MATHLIBNAME, luaopen_math },
{ NULL, NULL }
};
for (const luaL_Reg* lib = lualibs; lib->func; ++lib)
{
lua_pushcfunction(c_State, lib->func);
lua_pushstring(c_State, lib->name);
lua_call(c_State, 1, 0);
}
luaL_openlibs(c_State);
// Register custom types and functions
RegisterGlobal(c_State);

View File

@ -0,0 +1,14 @@
lbaselib.c
- Commented out collectgarbage, getfenv, print, and setfenv functions in base_funcs array
- Commented out luaL_register for coroutine library
liolib.c
- Commented out popen in iolib array
- Commented out createstdfile calls for stdin/stdout/stderr in luaopen_io
- Commented out popen related calls in luaopen_io
linit.c
- Commented out debug and package libraries
loslib.c
- Commented out exit function in syslib array

View File

@ -446,23 +446,23 @@ static int luaB_newproxy (lua_State *L) {
static const luaL_Reg base_funcs[] = {
{"assert", luaB_assert},
{"collectgarbage", luaB_collectgarbage},
// {"collectgarbage", luaB_collectgarbage},
{"dofile", luaB_dofile},
{"error", luaB_error},
{"gcinfo", luaB_gcinfo},
{"getfenv", luaB_getfenv},
// {"gcinfo", luaB_gcinfo},
// {"getfenv", luaB_getfenv},
{"getmetatable", luaB_getmetatable},
{"loadfile", luaB_loadfile},
{"load", luaB_load},
{"loadstring", luaB_loadstring},
{"next", luaB_next},
{"pcall", luaB_pcall},
{"print", luaB_print},
// {"print", luaB_print},
{"rawequal", luaB_rawequal},
{"rawget", luaB_rawget},
{"rawset", luaB_rawset},
{"select", luaB_select},
{"setfenv", luaB_setfenv},
// {"setfenv", luaB_setfenv},
{"setmetatable", luaB_setmetatable},
{"tonumber", luaB_tonumber},
{"tostring", luaB_tostring},
@ -647,7 +647,7 @@ static void base_open (lua_State *L) {
LUALIB_API int luaopen_base (lua_State *L) {
base_open(L);
luaL_register(L, LUA_COLIBNAME, co_funcs);
// luaL_register(L, LUA_COLIBNAME, co_funcs);
return 2;
}

View File

@ -16,13 +16,13 @@
static const luaL_Reg lualibs[] = {
{"", luaopen_base},
{LUA_LOADLIBNAME, luaopen_package},
// {LUA_LOADLIBNAME, luaopen_package},
{LUA_TABLIBNAME, luaopen_table},
{LUA_IOLIBNAME, luaopen_io},
{LUA_OSLIBNAME, luaopen_os},
{LUA_STRLIBNAME, luaopen_string},
{LUA_MATHLIBNAME, luaopen_math},
{LUA_DBLIBNAME, luaopen_debug},
// {LUA_DBLIBNAME, luaopen_debug},
{NULL, NULL}
};

View File

@ -484,7 +484,7 @@ static const luaL_Reg iolib[] = {
{"lines", io_lines},
{"open", io_open},
{"output", io_output},
{"popen", io_popen},
// {"popen", io_popen},
{"read", io_read},
{"tmpfile", io_tmpfile},
{"type", io_type},
@ -543,14 +543,14 @@ LUALIB_API int luaopen_io (lua_State *L) {
luaL_register(L, LUA_IOLIBNAME, iolib);
/* create (and set) default files */
newfenv(L, io_noclose); /* close function for default files */
createstdfile(L, stdin, IO_INPUT, "stdin");
createstdfile(L, stdout, IO_OUTPUT, "stdout");
createstdfile(L, stderr, 0, "stderr");
// createstdfile(L, stdin, IO_INPUT, "stdin");
// createstdfile(L, stdout, IO_OUTPUT, "stdout");
// createstdfile(L, stderr, 0, "stderr");
lua_pop(L, 1); /* pop environment for default files */
lua_getfield(L, -1, "popen");
newfenv(L, io_pclose); /* create environment for 'popen' */
lua_setfenv(L, -2); /* set fenv for 'popen' */
lua_pop(L, 1); /* pop 'popen' */
// lua_getfield(L, -1, "popen");
// newfenv(L, io_pclose); /* create environment for 'popen' */
// lua_setfenv(L, -2); /* set fenv for 'popen' */
// lua_pop(L, 1); /* pop 'popen' */
return 1;
}

View File

@ -202,14 +202,15 @@ static int os_difftime (lua_State *L) {
static int os_setlocale (lua_State *L) {
static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY,
LC_NUMERIC, LC_TIME};
static const char *const catnames[] = {"all", "collate", "ctype", "monetary",
"numeric", "time", NULL};
const char *l = luaL_optstring(L, 1, NULL);
int op = luaL_checkoption(L, 2, "all", catnames);
lua_pushstring(L, setlocale(cat[op], l));
return 1;
// static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY,
// LC_NUMERIC, LC_TIME};
// static const char *const catnames[] = {"all", "collate", "ctype", "monetary",
// "numeric", "time", NULL};
// const char *l = luaL_optstring(L, 1, NULL);
// int op = luaL_checkoption(L, 2, "all", catnames);
// lua_pushstring(L, setlocale(cat[op], l));
// return 1;
return 0;
}
@ -222,7 +223,7 @@ static const luaL_Reg syslib[] = {
{"date", os_date},
{"difftime", os_difftime},
{"execute", os_execute},
{"exit", os_exit},
// {"exit", os_exit},
{"getenv", os_getenv},
{"remove", os_remove},
{"rename", os_rename},

View File

@ -702,7 +702,7 @@ union luai_Cast { double l_d; long l_l; };
#endif
#if defined(LUA_WIN)
#define LUA_DL_DLL
//#define LUA_DL_DLL
#endif