aboutsummaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-07-09 13:01:38 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-07-09 13:01:38 -0300
commit76d8b8db06f7ae23da1543e1bf0a195d92b633a9 (patch)
treed09cf6fe34dcc929520fce0c6610d595b8742e94 /liolib.c
parentce455481ab587ed37c1a68e55efec205979b9c89 (diff)
downloadlua-76d8b8db06f7ae23da1543e1bf0a195d92b633a9.tar.gz
lua-76d8b8db06f7ae23da1543e1bf0a195d92b633a9.tar.bz2
lua-76d8b8db06f7ae23da1543e1bf0a195d92b633a9.zip
`lua_pushfstring' now supports `%p' option too
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