diff options
| -rw-r--r-- | lbaselib.c | 15 |
1 files changed, 6 insertions, 9 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbaselib.c,v 1.182 2005/08/26 17:36:32 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.183 2005/09/16 18:22:48 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 | */ |
| @@ -561,7 +561,7 @@ static int luaB_costatus (lua_State *L) { | |||
| 561 | lua_pushliteral(L, "dead"); | 561 | lua_pushliteral(L, "dead"); |
| 562 | else | 562 | else |
| 563 | lua_pushliteral(L, "suspended"); /* initial state */ | 563 | lua_pushliteral(L, "suspended"); /* initial state */ |
| 564 | break; | 564 | break; |
| 565 | } | 565 | } |
| 566 | default: /* some error occured */ | 566 | default: /* some error occured */ |
| 567 | lua_pushliteral(L, "dead"); | 567 | lua_pushliteral(L, "dead"); |
| @@ -602,8 +602,11 @@ static void auxopen (lua_State *L, const char *name, | |||
| 602 | 602 | ||
| 603 | 603 | ||
| 604 | static void base_open (lua_State *L) { | 604 | static void base_open (lua_State *L) { |
| 605 | /* set global _G */ | ||
| 605 | lua_pushvalue(L, LUA_GLOBALSINDEX); | 606 | lua_pushvalue(L, LUA_GLOBALSINDEX); |
| 606 | luaL_register(L, NULL, base_funcs); /* open lib into global table */ | 607 | lua_setglobal(L, "_G"); |
| 608 | /* open lib into global table */ | ||
| 609 | luaL_register(L, "_G", base_funcs); | ||
| 607 | lua_pushliteral(L, LUA_VERSION); | 610 | lua_pushliteral(L, LUA_VERSION); |
| 608 | lua_setglobal(L, "_VERSION"); /* set global _VERSION */ | 611 | lua_setglobal(L, "_VERSION"); /* set global _VERSION */ |
| 609 | /* `ipairs' and `pairs' need auxiliary functions as upvalues */ | 612 | /* `ipairs' and `pairs' need auxiliary functions as upvalues */ |
| @@ -617,12 +620,6 @@ static void base_open (lua_State *L) { | |||
| 617 | lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ | 620 | lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ |
| 618 | lua_pushcclosure(L, luaB_newproxy, 1); | 621 | lua_pushcclosure(L, luaB_newproxy, 1); |
| 619 | lua_setglobal(L, "newproxy"); /* set global `newproxy' */ | 622 | lua_setglobal(L, "newproxy"); /* set global `newproxy' */ |
| 620 | /* create register._LOADED to track loaded modules */ | ||
| 621 | lua_newtable(L); | ||
| 622 | lua_setfield(L, LUA_REGISTRYINDEX, "_LOADED"); | ||
| 623 | /* set global _G */ | ||
| 624 | lua_pushvalue(L, LUA_GLOBALSINDEX); | ||
| 625 | lua_setglobal(L, "_G"); | ||
| 626 | } | 623 | } |
| 627 | 624 | ||
| 628 | 625 | ||
