aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 80b0039d..6e176990 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.232 2009/12/15 11:25:16 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.233 2009/12/17 16:20:01 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -23,7 +23,7 @@
23static int luaB_print (lua_State *L) { 23static int luaB_print (lua_State *L) {
24 int n = lua_gettop(L); /* number of arguments */ 24 int n = lua_gettop(L); /* number of arguments */
25 int i; 25 int i;
26 lua_getfield(L, LUA_GLOBALSINDEX, "tostring"); 26 lua_getfield(L, LUA_ENVIRONINDEX, "tostring");
27 for (i=1; i<=n; i++) { 27 for (i=1; i<=n; i++) {
28 const char *s; 28 const char *s;
29 size_t l; 29 size_t l;
@@ -125,7 +125,7 @@ static void getfunc (lua_State *L, int opt) {
125static int luaB_getfenv (lua_State *L) { 125static int luaB_getfenv (lua_State *L) {
126 getfunc(L, 1); 126 getfunc(L, 1);
127 if (lua_iscfunction(L, -1)) /* is a C function? */ 127 if (lua_iscfunction(L, -1)) /* is a C function? */
128 lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the global env. */ 128 lua_pushglobaltable(L); /* return the global env. */
129 else 129 else
130 lua_getfenv(L, -1); 130 lua_getfenv(L, -1);
131 return 1; 131 return 1;
@@ -695,12 +695,12 @@ static void auxopen (lua_State *L, const char *name,
695 695
696static void base_open (lua_State *L) { 696static void base_open (lua_State *L) {
697 /* set global _G */ 697 /* set global _G */
698 lua_pushvalue(L, LUA_GLOBALSINDEX); 698 lua_pushglobaltable(L);
699 lua_setfield(L, LUA_GLOBALSINDEX, "_G"); 699 lua_setfield(L, LUA_ENVIRONINDEX, "_G");
700 /* open lib into global table */ 700 /* open lib into global table */
701 luaL_register(L, "_G", base_funcs); 701 luaL_register(L, "_G", base_funcs);
702 lua_pushliteral(L, LUA_VERSION); 702 lua_pushliteral(L, LUA_VERSION);
703 lua_setfield(L, LUA_GLOBALSINDEX, "_VERSION"); /* set global _VERSION */ 703 lua_setfield(L, LUA_ENVIRONINDEX, "_VERSION"); /* set global _VERSION */
704 /* `ipairs' and `pairs' need auxiliary functions as upvalues */ 704 /* `ipairs' and `pairs' need auxiliary functions as upvalues */
705 auxopen(L, "ipairs", luaB_ipairs, ipairsaux); 705 auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
706 auxopen(L, "pairs", luaB_pairs, luaB_next); 706 auxopen(L, "pairs", luaB_pairs, luaB_next);
@@ -711,7 +711,7 @@ static void base_open (lua_State *L) {
711 lua_pushliteral(L, "kv"); 711 lua_pushliteral(L, "kv");
712 lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ 712 lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */
713 lua_pushcclosure(L, luaB_newproxy, 1); 713 lua_pushcclosure(L, luaB_newproxy, 1);
714 lua_setfield(L, LUA_GLOBALSINDEX, "newproxy"); /* set global `newproxy' */ 714 lua_setfield(L, LUA_ENVIRONINDEX, "newproxy"); /* set global `newproxy' */
715} 715}
716 716
717 717