use of 'luaL_tolstring' for option '%s' in 'string.format'
This commit is contained in:
@@ -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
|
** Standard library for string operations and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -889,16 +889,16 @@ static int str_format (lua_State *L) {
|
|||||||
}
|
}
|
||||||
case 's': {
|
case 's': {
|
||||||
size_t l;
|
size_t l;
|
||||||
const char *s = luaL_checklstring(L, arg, &l);
|
const char *s = luaL_tolstring(L, arg, &l);
|
||||||
if (!strchr(form, '.') && l >= 100) {
|
if (!strchr(form, '.') && l >= 100) {
|
||||||
/* no precision and string is too long to be formatted;
|
/* no precision and string is too long to be formatted;
|
||||||
keep original string */
|
keep original string */
|
||||||
lua_pushvalue(L, arg);
|
|
||||||
luaL_addvalue(&b);
|
luaL_addvalue(&b);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nb = sprintf(buff, form, s);
|
nb = sprintf(buff, form, s);
|
||||||
|
lua_pop(L, 1); /* remove result from 'luaL_tolstring' */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user