diff options
Diffstat (limited to 'loadlib.c')
-rw-r--r-- | loadlib.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loadlib.c,v 1.22 2005/03/18 16:38:43 roberto Exp roberto $ | 2 | ** $Id: loadlib.c,v 1.23 2005/03/29 14:30:16 roberto Exp roberto $ |
3 | ** Dynamic library loader for Lua | 3 | ** Dynamic library loader for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | ** | 5 | ** |
@@ -315,11 +315,13 @@ static int ll_loadlib (lua_State *L) { | |||
315 | static int loader_Lua (lua_State *L) { | 315 | static int loader_Lua (lua_State *L) { |
316 | const char *name = luaL_checkstring(L, 1); | 316 | const char *name = luaL_checkstring(L, 1); |
317 | const char *fname = luaL_gsub(L, name, ".", LUA_DIRSEP); | 317 | const char *fname = luaL_gsub(L, name, ".", LUA_DIRSEP); |
318 | const char *path; | 318 | const char *path = NULL; |
319 | #if LUA_COMPAT_PATH | ||
319 | /* try first `LUA_PATH' for compatibility */ | 320 | /* try first `LUA_PATH' for compatibility */ |
320 | lua_pushstring(L, "LUA_PATH"); | 321 | lua_pushstring(L, "LUA_PATH"); |
321 | lua_rawget(L, LUA_GLOBALSINDEX); | 322 | lua_rawget(L, LUA_GLOBALSINDEX); |
322 | path = lua_tostring(L, -1); | 323 | path = lua_tostring(L, -1); |
324 | #endif | ||
323 | if (!path) { | 325 | if (!path) { |
324 | lua_pop(L, 1); | 326 | lua_pop(L, 1); |
325 | lua_getfield(L, LUA_ENVIRONINDEX, "path"); | 327 | lua_getfield(L, LUA_ENVIRONINDEX, "path"); |
@@ -505,8 +507,10 @@ LUALIB_API int luaopen_loadlib (lua_State *L) { | |||
505 | lua_setfield(L, -2, "preload"); | 507 | lua_setfield(L, -2, "preload"); |
506 | /* create `loadlib' function */ | 508 | /* create `loadlib' function */ |
507 | lua_pushcfunction(L, ll_loadlib); | 509 | lua_pushcfunction(L, ll_loadlib); |
510 | #if LUA_COMPAT_LOADLIB | ||
508 | lua_pushvalue(L, -1); | 511 | lua_pushvalue(L, -1); |
509 | lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); /* COMPATIBILITY ONLY!! */ | 512 | lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); |
513 | #endif | ||
510 | lua_setfield(L, -2, "loadlib"); | 514 | lua_setfield(L, -2, "loadlib"); |
511 | lua_pushvalue(L, LUA_GLOBALSINDEX); | 515 | lua_pushvalue(L, LUA_GLOBALSINDEX); |
512 | luaL_openlib(L, NULL, ll_funcs, 0); /* open lib into global table */ | 516 | luaL_openlib(L, NULL, ll_funcs, 0); /* open lib into global table */ |