aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 074ff08c..e8fc486e 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -545,10 +545,8 @@ static char *prepbuffsize (luaL_Buffer *B, size_t sz, int boxidx) {
545 if (buffonstack(B)) /* buffer already has a box? */ 545 if (buffonstack(B)) /* buffer already has a box? */
546 newbuff = (char *)resizebox(L, boxidx, newsize); /* resize it */ 546 newbuff = (char *)resizebox(L, boxidx, newsize); /* resize it */
547 else { /* no box yet */ 547 else { /* no box yet */
548 lua_pushnil(L); /* reserve slot for final result */
549 newbox(L); /* create a new box */ 548 newbox(L); /* create a new box */
550 /* move box (and slot) to its intended position */ 549 lua_insert(L, boxidx); /* move box to its intended position */
551 lua_rotate(L, boxidx - 1, 2);
552 lua_toclose(L, boxidx); 550 lua_toclose(L, boxidx);
553 newbuff = (char *)resizebox(L, boxidx, newsize); 551 newbuff = (char *)resizebox(L, boxidx, newsize);
554 memcpy(newbuff, B->b, B->n * sizeof(char)); /* copy original content */ 552 memcpy(newbuff, B->b, B->n * sizeof(char)); /* copy original content */
@@ -585,8 +583,8 @@ LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
585 lua_State *L = B->L; 583 lua_State *L = B->L;
586 lua_pushlstring(L, B->b, B->n); 584 lua_pushlstring(L, B->b, B->n);
587 if (buffonstack(B)) { 585 if (buffonstack(B)) {
588 lua_copy(L, -1, -3); /* move string to reserved slot */ 586 lua_closeslot(L, -2); /* close the box */
589 lua_pop(L, 2); /* pop string and box (closing the box) */ 587 lua_remove(L, -2); /* remove box from the stack */
590 } 588 }
591} 589}
592 590