From 76d8b8db06f7ae23da1543e1bf0a195d92b633a9 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 9 Jul 2004 13:01:38 -0300 Subject: `lua_pushfstring' now supports `%p' option too --- liolib.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'liolib.c') diff --git a/liolib.c b/liolib.c index 04961b5e..76323112 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.53 2004/05/28 18:35:05 roberto Exp roberto $ +** $Id: liolib.c,v 2.54 2004/07/09 15:47:48 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -114,13 +114,11 @@ static int io_gc (lua_State *L) { static int io_tostring (lua_State *L) { - char buff[4*sizeof(void *) + 8]; /* enough space for a `%p' */ - FILE **f = topfile(L); - if (*f == NULL) - strcpy(buff, "closed"); + FILE *f = *topfile(L); + if (f == NULL) + lua_pushstring(L, "file (closed)"); else - sprintf(buff, "%p", lua_touserdata(L, 1)); - lua_pushfstring(L, "file (%s)", buff); + lua_pushfstring(L, "file (%p)", f); return 1; } -- cgit v1.2.3-55-g6feb