'luaO_pushvfstring' now uses 'incr_top' to increment top.

This commit is contained in:
Roberto Ierusalimschy
2015-11-02 12:02:35 -02:00
parent ffd0d1232d
commit 332a06bbd1

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lobject.c,v 2.105 2015/06/18 14:26:05 roberto Exp roberto $ ** $Id: lobject.c,v 2.106 2015/06/26 19:32:07 roberto Exp roberto $
** Some generic functions over Lua objects ** Some generic functions over Lua objects
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -346,7 +346,8 @@ void luaO_tostring (lua_State *L, StkId obj) {
static void pushstr (lua_State *L, const char *str, size_t l) { static void pushstr (lua_State *L, const char *str, size_t l) {
setsvalue2s(L, L->top++, luaS_newlstr(L, str, l)); setsvalue2s(L, L->top, luaS_newlstr(L, str, l));
incr_top(L);
} }
@@ -357,7 +358,6 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
for (;;) { for (;;) {
const char *e = strchr(fmt, '%'); const char *e = strchr(fmt, '%');
if (e == NULL) break; if (e == NULL) break;
luaD_checkstack(L, 2); /* fmt + item */
pushstr(L, fmt, e - fmt); pushstr(L, fmt, e - fmt);
switch (*(e+1)) { switch (*(e+1)) {
case 's': { case 's': {
@@ -375,17 +375,17 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
break; break;
} }
case 'd': { case 'd': {
setivalue(L->top++, va_arg(argp, int)); setivalue(L->top, va_arg(argp, int));
luaO_tostring(L, L->top - 1); goto top2str;
break;
} }
case 'I': { case 'I': {
setivalue(L->top++, cast(lua_Integer, va_arg(argp, l_uacInt))); setivalue(L->top, cast(lua_Integer, va_arg(argp, l_uacInt)));
luaO_tostring(L, L->top - 1); goto top2str;
break;
} }
case 'f': { case 'f': {
setfltvalue(L->top++, cast_num(va_arg(argp, l_uacNumber))); setfltvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
top2str:
incr_top(L);
luaO_tostring(L, L->top - 1); luaO_tostring(L, L->top - 1);
break; break;
} }