From a25416a8d580c0dd72ae014f6a83b5205fbd11ce Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 18 Mar 2011 16:02:33 -0300 Subject: use of 'luaL_tolstring' for option '%s' in 'string.format' --- lstrlib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lstrlib.c b/lstrlib.c index 2efed9c0..ccecd311 100644 --- a/lstrlib.c +++ b/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.163 2011/01/26 16:30:02 roberto Exp roberto $ +** $Id: lstrlib.c,v 1.164 2011/02/07 19:15:24 roberto Exp roberto $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -889,16 +889,16 @@ static int str_format (lua_State *L) { } case 's': { size_t l; - const char *s = luaL_checklstring(L, arg, &l); + const char *s = luaL_tolstring(L, arg, &l); if (!strchr(form, '.') && l >= 100) { /* no precision and string is too long to be formatted; keep original string */ - lua_pushvalue(L, arg); luaL_addvalue(&b); break; } else { nb = sprintf(buff, form, s); + lua_pop(L, 1); /* remove result from 'luaL_tolstring' */ break; } } -- cgit v1.2.3-55-g6feb