summaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-03-14 16:00:16 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-03-14 16:00:16 -0300
commit05d567d52e9155327b73fab14d7d635726943d94 (patch)
tree774a1f7aaee098cdf7f26cd60448fc127fb844e6 /liolib.c
parentd8a3a00d8481a13a94247c3dc33f43ebf3569e0b (diff)
downloadlua-github-05d567d52e9155327b73fab14d7d635726943d94.tar.gz
`io.input'/`io.output' always return current file
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/liolib.c b/liolib.c
index cc232c9e..b18a12e4 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
/*
-** $Id: liolib.c,v 2.34 2003/03/06 19:36:44 roberto Exp roberto $
+** $Id: liolib.c,v 2.35 2003/03/11 12:24:34 roberto Exp roberto $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -238,7 +238,6 @@ static int g_iofile (lua_State *L, const char *name, const char *mode) {
}
else {
const char *filename = lua_tostring(L, 1);
- lua_pushstring(L, name);
if (filename) {
FILE **pf = newfile(L);
*pf = fopen(filename, mode);
@@ -251,8 +250,10 @@ static int g_iofile (lua_State *L, const char *name, const char *mode) {
tofile(L, 1); /* check that it's a valid file handle */
lua_pushvalue(L, 1);
}
+ lua_pushstring(L, name);
+ lua_pushvalue(L, -2);
lua_rawset(L, lua_upvalueindex(1));
- return 0;
+ return 1;
}
}