From cf86576a838dbe7a11f64116bdc9b1942d233ff8 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 7 Feb 2007 15:51:21 -0200 Subject: new function luaL_tostring --- lbaselib.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'lbaselib.c') diff --git a/lbaselib.c b/lbaselib.c index 01decb46..556325af 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.194 2006/10/20 19:30:53 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.195 2006/10/24 19:46:12 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -396,25 +396,7 @@ static int luaB_xpcall (lua_State *L) { static int luaB_tostring (lua_State *L) { luaL_checkany(L, 1); - if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ - return 1; /* use its value */ - switch (lua_type(L, 1)) { - case LUA_TNUMBER: - lua_pushstring(L, lua_tostring(L, 1)); - break; - case LUA_TSTRING: - lua_pushvalue(L, 1); - break; - case LUA_TBOOLEAN: - lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); - break; - case LUA_TNIL: - lua_pushliteral(L, "nil"); - break; - default: - lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1)); - break; - } + luaL_tostring(L, 1); return 1; } -- cgit v1.2.3-55-g6feb