diff options
Diffstat (limited to 'liolib.c')
| -rw-r--r-- | liolib.c | 13 |
1 files changed, 5 insertions, 8 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: liolib.c,v 1.113 2001/06/06 18:00:19 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.114 2001/06/07 13:46:29 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 | */ |
| @@ -135,13 +135,10 @@ static void resetfile (lua_State *L, int inout) { | |||
| 135 | 135 | ||
| 136 | 136 | ||
| 137 | static int io_close (lua_State *L) { | 137 | static int io_close (lua_State *L) { |
| 138 | FILE *f; | 138 | FILE *f = (FILE *)luaL_check_userdata(L, 1, FILEHANDLE); |
| 139 | int status; | 139 | int status = 1; |
| 140 | lua_settop(L, 1); | 140 | if (f != stdin && f != stdout && f != stderr) { |
| 141 | f = luaL_check_userdata(L, 1, FILEHANDLE); | 141 | lua_settop(L, 1); /* make sure file is on top */ |
| 142 | if (f == stdin || f == stdout || f == stderr) | ||
| 143 | status = 1; | ||
| 144 | else { | ||
| 145 | lua_settag(L, lua_name2tag(L, CLOSEDFILEHANDLE)); | 142 | lua_settag(L, lua_name2tag(L, CLOSEDFILEHANDLE)); |
| 146 | status = (CLOSEFILE(L, f) == 0); | 143 | status = (CLOSEFILE(L, f) == 0); |
| 147 | } | 144 | } |
