Skip to content

Commit

Permalink
Changed lua stack indexing with negative values
Browse files Browse the repository at this point in the history
In Lua 5.2 using positive values to index Lua stack gives realy awkward
results once in while.

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
  • Loading branch information
asido committed Jun 9, 2012
1 parent 800ce0a commit 9be9de2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions luaa.c
Expand Up @@ -595,13 +595,13 @@ luaA_init(xdgHandle* xdg)

/* add Lua search paths */
lua_getglobal(L, "package");
if (LUA_TTABLE != lua_type(L, 1))
if (LUA_TTABLE != lua_type(L, -1))
{
warn("package is not a table");
return;
}
lua_getfield(L, 1, "path");
if (LUA_TSTRING != lua_type(L, 2))
lua_getfield(L, -1, "path");
if (LUA_TSTRING != lua_type(L, -1))
{
warn("package.path is not a string");
lua_pop(L, 1);
Expand Down Expand Up @@ -630,9 +630,9 @@ luaA_init(xdgHandle* xdg)
lua_pushliteral(L, ";" AWESOME_LUA_LIB_PATH "/?.lua");
lua_pushliteral(L, ";" AWESOME_LUA_LIB_PATH "/?/init.lua");
lua_concat(L, 3); /* concatenate with package.path */
lua_setfield(L, 1, "path"); /* package.path = "concatenated string" */
lua_setfield(L, -2, "path"); /* package.path = "concatenated string" */

lua_getfield(L, 1, "loaded");
lua_getfield(L, -1, "loaded");

lua_pop(L, 2); /* pop "package" and "package.loaded" */

Expand Down

0 comments on commit 9be9de2

Please sign in to comment.