diff options
| -rw-r--r-- | liolib.c | 10 |
1 files changed, 7 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: liolib.c,v 2.20 2002/10/11 20:40:32 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.21 2002/10/16 20:41:35 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 | */ |
| @@ -100,8 +100,12 @@ static int aux_close (lua_State *L) { | |||
| 100 | FILE *f = tofile(L, 1); | 100 | FILE *f = tofile(L, 1); |
| 101 | if (f == stdin || f == stdout || f == stderr) | 101 | if (f == stdin || f == stdout || f == stderr) |
| 102 | return 0; /* file cannot be closed */ | 102 | return 0; /* file cannot be closed */ |
| 103 | *(FILE **)lua_touserdata(L, 1) = NULL; /* mark file as closed */ | 103 | else { |
| 104 | return (pclose(f) != -1) || (fclose(f) == 0); | 104 | int ok = (pclose(f) != -1) || (fclose(f) == 0); |
| 105 | if (ok) | ||
| 106 | *(FILE **)lua_touserdata(L, 1) = NULL; /* mark file as closed */ | ||
| 107 | return ok; | ||
| 108 | } | ||
| 105 | } | 109 | } |
| 106 | 110 | ||
| 107 | 111 | ||
