aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 74d176dd..f1a7b5ab 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -20,8 +20,9 @@
20 20
21 21
22static void aux_setn (lua_State *L, int t, int n) { 22static void aux_setn (lua_State *L, int t, int n) {
23 lua_pushliteral(L, "n");
23 lua_pushnumber(L, n); 24 lua_pushnumber(L, n);
24 lua_setstr(L, t, "n"); 25 lua_rawset(L, t);
25} 26}
26 27
27 28
@@ -444,7 +445,8 @@ static int luaB_coroutine (lua_State *L) {
444 } 445 }
445 lua_cobegin(NL, n-1); 446 lua_cobegin(NL, n-1);
446 lua_newuserdatabox(L, NL); 447 lua_newuserdatabox(L, NL);
447 lua_getstr(L, LUA_REGISTRYINDEX, "Coroutine"); 448 lua_pushliteral(L, "Coroutine");
449 lua_rawget(L, LUA_REGISTRYINDEX);
448 lua_setmetatable(L, -2); 450 lua_setmetatable(L, -2);
449 lua_pushcclosure(L, luaB_resume, 1); 451 lua_pushcclosure(L, luaB_resume, 1);
450 return 1; 452 return 1;
@@ -700,10 +702,12 @@ LUALIB_API int lua_baselibopen (lua_State *L) {
700 lua_pushcclosure(L, luaB_require, 1); 702 lua_pushcclosure(L, luaB_require, 1);
701 lua_setglobal(L, "require"); 703 lua_setglobal(L, "require");
702 /* create metatable for coroutines */ 704 /* create metatable for coroutines */
705 lua_pushliteral(L, "Coroutine");
703 lua_newtable(L); 706 lua_newtable(L);
707 lua_pushliteral(L, "gc");
704 lua_pushcfunction(L, gc_coroutine); 708 lua_pushcfunction(L, gc_coroutine);
705 lua_setstr(L, -2, "gc"); 709 lua_rawset(L, -3);
706 lua_setstr(L, LUA_REGISTRYINDEX, "Coroutine"); 710 lua_rawset(L, LUA_REGISTRYINDEX);
707 return 0; 711 return 0;
708} 712}
709 713