summaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/liolib.c b/liolib.c
index 8491edca..8a9e75cd 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 2.150 2016/09/01 16:14:56 roberto Exp roberto $ 2** $Id: liolib.c,v 2.151.1.1 2017/04/19 17:29:57 roberto Exp $
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*/
@@ -206,11 +206,16 @@ static int aux_close (lua_State *L) {
206} 206}
207 207
208 208
209static int f_close (lua_State *L) {
210 tofile(L); /* make sure argument is an open stream */
211 return aux_close(L);
212}
213
214
209static int io_close (lua_State *L) { 215static int io_close (lua_State *L) {
210 if (lua_isnone(L, 1)) /* no argument? */ 216 if (lua_isnone(L, 1)) /* no argument? */
211 lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use standard output */ 217 lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use standard output */
212 tofile(L); /* make sure argument is an open stream */ 218 return f_close(L);
213 return aux_close(L);
214} 219}
215 220
216 221
@@ -712,7 +717,7 @@ static const luaL_Reg iolib[] = {
712** methods for file handles 717** methods for file handles
713*/ 718*/
714static const luaL_Reg flib[] = { 719static const luaL_Reg flib[] = {
715 {"close", io_close}, 720 {"close", f_close},
716 {"flush", f_flush}, 721 {"flush", f_flush},
717 {"lines", f_lines}, 722 {"lines", f_lines},
718 {"read", f_read}, 723 {"read", f_read},