From f84b575cfa52dc832751846aa0b4c8ff437d3ca3 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 22 Dec 2009 13:32:50 -0200 Subject: no more pseudoindex LUA_GLOBALSINDEX; global table now accessible through registry --- lua.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lua.c') diff --git a/lua.c b/lua.c index 4875b54d..69a560cb 100644 --- a/lua.c +++ b/lua.c @@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.179 2009/12/17 13:07:41 roberto Exp roberto $ +** $Id: lua.c,v 1.180 2009/12/17 16:20:01 roberto Exp roberto $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -214,7 +214,7 @@ static int dostring (lua_State *L, const char *s, const char *name) { static int dolibrary (lua_State *L, const char *name) { - lua_getfield(L, LUA_GLOBALSINDEX, "require"); + lua_getfield(L, LUA_ENVIRONINDEX, "require"); lua_pushstring(L, name); return report(L, docall(L, 1, 1)); } @@ -222,7 +222,7 @@ static int dolibrary (lua_State *L, const char *name) { static const char *get_prompt (lua_State *L, int firstline) { const char *p; - lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); + lua_getfield(L, LUA_ENVIRONINDEX, firstline ? "_PROMPT" : "_PROMPT2"); p = lua_tostring(L, -1); if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); lua_pop(L, 1); /* remove global */ @@ -296,7 +296,7 @@ static void dotty (lua_State *L) { report(L, status); if (status == LUA_OK && lua_gettop(L) > 0) { /* any result to print? */ luaL_checkstack(L, LUA_MINSTACK, "too many results to print"); - lua_getfield(L, LUA_GLOBALSINDEX, "print"); + lua_getfield(L, LUA_ENVIRONINDEX, "print"); lua_insert(L, 1); if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != LUA_OK) l_message(progname, lua_pushfstring(L, @@ -315,7 +315,7 @@ static int handle_script (lua_State *L, char **argv, int n) { int status; const char *fname; int narg = getargs(L, argv, n); /* collect arguments */ - lua_setfield(L, LUA_GLOBALSINDEX, "arg"); + lua_setfield(L, LUA_ENVIRONINDEX, "arg"); fname = argv[n]; if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) fname = NULL; /* stdin */ -- cgit v1.2.3-55-g6feb