diff options
Diffstat (limited to 'liolib.c')
-rw-r--r-- | liolib.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 1.133 2002/03/27 15:30:41 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.1 2002/04/04 20:24:56 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -54,11 +54,11 @@ static int pushresult (lua_State *L, int i) { | |||
54 | 54 | ||
55 | 55 | ||
56 | static FILE *tofile (lua_State *L, int findex) { | 56 | static FILE *tofile (lua_State *L, int findex) { |
57 | FILE *f = (FILE *)lua_touserdata(L, findex); | 57 | FILE **f = (FILE **)lua_touserdata(L, findex); |
58 | if (f && lua_getmetatable(L, findex) && | 58 | if (f && lua_getmetatable(L, findex) && |
59 | lua_equal(L, -1, lua_upvalueindex(1))) { | 59 | lua_equal(L, -1, lua_upvalueindex(1))) { |
60 | lua_pop(L, 1); | 60 | lua_pop(L, 1); |
61 | return f; | 61 | return *f; |
62 | } | 62 | } |
63 | luaL_argerror(L, findex, "bad file"); | 63 | luaL_argerror(L, findex, "bad file"); |
64 | return NULL; /* to avoid warnings */ | 64 | return NULL; /* to avoid warnings */ |
@@ -66,7 +66,7 @@ static FILE *tofile (lua_State *L, int findex) { | |||
66 | 66 | ||
67 | 67 | ||
68 | static void newfile (lua_State *L, FILE *f) { | 68 | static void newfile (lua_State *L, FILE *f) { |
69 | lua_newuserdatabox(L, f); | 69 | lua_newpointerbox(L, f); |
70 | lua_pushliteral(L, FILEHANDLE); | 70 | lua_pushliteral(L, FILEHANDLE); |
71 | lua_rawget(L, LUA_REGISTRYINDEX); | 71 | lua_rawget(L, LUA_REGISTRYINDEX); |
72 | lua_setmetatable(L, -2); | 72 | lua_setmetatable(L, -2); |