From da32450c3d4c8abd3fd6709692859a12a8886511 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 16 May 2005 16:21:11 -0300 Subject: new API function `lua_tolstring' --- lbaselib.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lbaselib.c') diff --git a/lbaselib.c b/lbaselib.c index 358ca427..badce346 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.172 2005/03/22 16:04:29 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.173 2005/03/28 17:17:53 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -294,11 +294,8 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) { return NULL; } else if (lua_isstring(L, -1)) { - const char *res; lua_replace(L, 3); /* save string in a reserved stack slot */ - res = lua_tostring(L, 3); - *size = lua_strlen(L, 3); - return res; + return lua_tolstring(L, 3, size); } else luaL_error(L, "reader function must return a string"); return NULL; /* to avoid warnings */ -- cgit v1.2.3-55-g6feb