aboutsummaryrefslogtreecommitdiff
path: root/lobject.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-11-02 12:02:35 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-11-02 12:02:35 -0200
commit332a06bbd1a8835c810e52bbf68014d6956b50b8 (patch)
tree41b25919098b635ec389827c9c7967bdfe347fb0 /lobject.c
parentffd0d1232d3a681b3db960d3c30721c3090587d0 (diff)
downloadlua-332a06bbd1a8835c810e52bbf68014d6956b50b8.tar.gz
lua-332a06bbd1a8835c810e52bbf68014d6956b50b8.tar.bz2
lua-332a06bbd1a8835c810e52bbf68014d6956b50b8.zip
'luaO_pushvfstring' now uses 'incr_top' to increment top.
Diffstat (limited to 'lobject.c')
-rw-r--r--lobject.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/lobject.c b/lobject.c
index f5e8a136..6b80c0ed 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 2.105 2015/06/18 14:26:05 roberto Exp roberto $ 2** $Id: lobject.c,v 2.106 2015/06/26 19:32:07 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -346,7 +346,8 @@ void luaO_tostring (lua_State *L, StkId obj) {
346 346
347 347
348static void pushstr (lua_State *L, const char *str, size_t l) { 348static void pushstr (lua_State *L, const char *str, size_t l) {
349 setsvalue2s(L, L->top++, luaS_newlstr(L, str, l)); 349 setsvalue2s(L, L->top, luaS_newlstr(L, str, l));
350 incr_top(L);
350} 351}
351 352
352 353
@@ -357,7 +358,6 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
357 for (;;) { 358 for (;;) {
358 const char *e = strchr(fmt, '%'); 359 const char *e = strchr(fmt, '%');
359 if (e == NULL) break; 360 if (e == NULL) break;
360 luaD_checkstack(L, 2); /* fmt + item */
361 pushstr(L, fmt, e - fmt); 361 pushstr(L, fmt, e - fmt);
362 switch (*(e+1)) { 362 switch (*(e+1)) {
363 case 's': { 363 case 's': {
@@ -375,17 +375,17 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
375 break; 375 break;
376 } 376 }
377 case 'd': { 377 case 'd': {
378 setivalue(L->top++, va_arg(argp, int)); 378 setivalue(L->top, va_arg(argp, int));
379 luaO_tostring(L, L->top - 1); 379 goto top2str;
380 break;
381 } 380 }
382 case 'I': { 381 case 'I': {
383 setivalue(L->top++, cast(lua_Integer, va_arg(argp, l_uacInt))); 382 setivalue(L->top, cast(lua_Integer, va_arg(argp, l_uacInt)));
384 luaO_tostring(L, L->top - 1); 383 goto top2str;
385 break;
386 } 384 }
387 case 'f': { 385 case 'f': {
388 setfltvalue(L->top++, cast_num(va_arg(argp, l_uacNumber))); 386 setfltvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
387 top2str:
388 incr_top(L);
389 luaO_tostring(L, L->top - 1); 389 luaO_tostring(L, L->top - 1);
390 break; 390 break;
391 } 391 }