diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-03-14 16:00:16 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-03-14 16:00:16 -0300 |
| commit | 05d567d52e9155327b73fab14d7d635726943d94 (patch) | |
| tree | 774a1f7aaee098cdf7f26cd60448fc127fb844e6 | |
| parent | d8a3a00d8481a13a94247c3dc33f43ebf3569e0b (diff) | |
| download | lua-05d567d52e9155327b73fab14d7d635726943d94.tar.gz lua-05d567d52e9155327b73fab14d7d635726943d94.tar.bz2 lua-05d567d52e9155327b73fab14d7d635726943d94.zip | |
`io.input'/`io.output' always return current file
| -rw-r--r-- | liolib.c | 7 |
1 files changed, 4 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: liolib.c,v 2.34 2003/03/06 19:36:44 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.35 2003/03/11 12:24:34 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 | */ |
| @@ -238,7 +238,6 @@ static int g_iofile (lua_State *L, const char *name, const char *mode) { | |||
| 238 | } | 238 | } |
| 239 | else { | 239 | else { |
| 240 | const char *filename = lua_tostring(L, 1); | 240 | const char *filename = lua_tostring(L, 1); |
| 241 | lua_pushstring(L, name); | ||
| 242 | if (filename) { | 241 | if (filename) { |
| 243 | FILE **pf = newfile(L); | 242 | FILE **pf = newfile(L); |
| 244 | *pf = fopen(filename, mode); | 243 | *pf = fopen(filename, mode); |
| @@ -251,8 +250,10 @@ static int g_iofile (lua_State *L, const char *name, const char *mode) { | |||
| 251 | tofile(L, 1); /* check that it's a valid file handle */ | 250 | tofile(L, 1); /* check that it's a valid file handle */ |
| 252 | lua_pushvalue(L, 1); | 251 | lua_pushvalue(L, 1); |
| 253 | } | 252 | } |
| 253 | lua_pushstring(L, name); | ||
| 254 | lua_pushvalue(L, -2); | ||
| 254 | lua_rawset(L, lua_upvalueindex(1)); | 255 | lua_rawset(L, lua_upvalueindex(1)); |
| 255 | return 0; | 256 | return 1; |
| 256 | } | 257 | } |
| 257 | } | 258 | } |
| 258 | 259 | ||
