aboutsummaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/liolib.c b/liolib.c
index 04961b5e..76323112 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 2.53 2004/05/28 18:35:05 roberto Exp roberto $ 2** $Id: liolib.c,v 2.54 2004/07/09 15:47:48 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*/
@@ -114,13 +114,11 @@ static int io_gc (lua_State *L) {
114 114
115 115
116static int io_tostring (lua_State *L) { 116static int io_tostring (lua_State *L) {
117 char buff[4*sizeof(void *) + 8]; /* enough space for a `%p' */ 117 FILE *f = *topfile(L);
118 FILE **f = topfile(L); 118 if (f == NULL)
119 if (*f == NULL) 119 lua_pushstring(L, "file (closed)");
120 strcpy(buff, "closed");
121 else 120 else
122 sprintf(buff, "%p", lua_touserdata(L, 1)); 121 lua_pushfstring(L, "file (%p)", f);
123 lua_pushfstring(L, "file (%s)", buff);
124 return 1; 122 return 1;
125} 123}
126 124