aboutsummaryrefslogtreecommitdiff
path: root/src/lua/lauxlib.c
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-01-22 17:54:39 +0800
committerLi Jin <dragon-fly@qq.com>2021-01-22 17:54:39 +0800
commit236bcc6e10f59b9336603571f1683cbe4aa411a9 (patch)
tree7116190d16a12bfcb0819e802c6e1d4ac8b0ec70 /src/lua/lauxlib.c
parentf61b96675547c8bf40c7f646e3766f4139efd927 (diff)
downloadyuescript-236bcc6e10f59b9336603571f1683cbe4aa411a9.tar.gz
yuescript-236bcc6e10f59b9336603571f1683cbe4aa411a9.tar.bz2
yuescript-236bcc6e10f59b9336603571f1683cbe4aa411a9.zip
update included Lua.
Diffstat (limited to 'src/lua/lauxlib.c')
-rw-r--r--src/lua/lauxlib.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/lua/lauxlib.c b/src/lua/lauxlib.c
index 074ff08..e8fc486 100644
--- a/src/lua/lauxlib.c
+++ b/src/lua/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