aboutsummaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/liolib.c b/liolib.c
index cc572a55..ad94e6f4 100644
--- a/liolib.c
+++ b/liolib.c
@@ -72,7 +72,7 @@ static int pushresult (lua_State *L, int i) {
72 72
73static int checkfile (lua_State *L, int findex, const char *tname) { 73static int checkfile (lua_State *L, int findex, const char *tname) {
74 int res; 74 int res;
75 lua_geteventtable(L, findex); 75 lua_getmetatable(L, findex);
76 lua_getstr(L, LUA_REGISTRYINDEX, tname); 76 lua_getstr(L, LUA_REGISTRYINDEX, tname);
77 res = lua_equal(L, -1, -2); 77 res = lua_equal(L, -1, -2);
78 lua_pop(L, 2); 78 lua_pop(L, 2);
@@ -112,7 +112,7 @@ static FILE *getopthandle (lua_State *L, int inout) {
112static void newfile (lua_State *L, FILE *f) { 112static void newfile (lua_State *L, FILE *f) {
113 lua_newuserdatabox(L, f); 113 lua_newuserdatabox(L, f);
114 lua_getstr(L, LUA_REGISTRYINDEX, FILEHANDLE); 114 lua_getstr(L, LUA_REGISTRYINDEX, FILEHANDLE);
115 lua_seteventtable(L, -2); 115 lua_setmetatable(L, -2);
116} 116}
117 117
118 118
@@ -148,7 +148,7 @@ static int io_close (lua_State *L) {
148 if (f != stdin && f != stdout && f != stderr) { 148 if (f != stdin && f != stdout && f != stderr) {
149 lua_settop(L, 1); /* make sure file is on top */ 149 lua_settop(L, 1); /* make sure file is on top */
150 lua_getstr(L, LUA_REGISTRYINDEX, CLOSEDFILEHANDLE); 150 lua_getstr(L, LUA_REGISTRYINDEX, CLOSEDFILEHANDLE);
151 lua_seteventtable(L, 1); 151 lua_setmetatable(L, 1);
152 status = (CLOSEFILE(L, f) == 0); 152 status = (CLOSEFILE(L, f) == 0);
153 } 153 }
154 return pushresult(L, status); 154 return pushresult(L, status);
@@ -693,13 +693,13 @@ static const luaL_reg iolib[] = {
693 693
694 694
695LUALIB_API int lua_iolibopen (lua_State *L) { 695LUALIB_API int lua_iolibopen (lua_State *L) {
696 lua_newtable(L); /* event table for FILEHANDLE */ 696 lua_newtable(L); /* meta table for FILEHANDLE */
697 /* close files when collected */ 697 /* close files when collected */
698 lua_pushcfunction(L, file_collect); 698 lua_pushcfunction(L, file_collect);
699 lua_setstr(L, -2, "gc"); 699 lua_setstr(L, -2, "gc");
700 /* put new eventtable into registry */ 700 /* put new metatable into registry */
701 lua_setstr(L, LUA_REGISTRYINDEX, FILEHANDLE); 701 lua_setstr(L, LUA_REGISTRYINDEX, FILEHANDLE);
702 /* event table for CLOSEDFILEHANDLE */ 702 /* meta table for CLOSEDFILEHANDLE */
703 lua_newtable(L); 703 lua_newtable(L);
704 lua_setstr(L, LUA_REGISTRYINDEX, CLOSEDFILEHANDLE); 704 lua_setstr(L, LUA_REGISTRYINDEX, CLOSEDFILEHANDLE);
705 luaL_openl(L, iolib); 705 luaL_openl(L, iolib);