| 452 | |
| 453 | |
| 454 | LUALIB_API void luaL_addvalue (luaL_Buffer *B) { |
| 455 | lua_State *L = B->L; |
| 456 | size_t vl; |
| 457 | const char *s = lua_tolstring(L, -1, &vl); |
| 458 | if (vl <= bufffree(B)) { /* fit into buffer? */ |
| 459 | memcpy(B->p, s, vl); /* put it there */ |
| 460 | B->p += vl; |
| 461 | lua_pop(L, 1); /* remove from stack */ |
| 462 | } |
| 463 | else { |
| 464 | if (emptybuffer(B)) |
| 465 | lua_insert(L, -2); /* put buffer before new value */ |
| 466 | B->lvl++; /* add new value into B stack */ |
| 467 | adjuststack(B); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | |
| 472 | LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { |
no test coverage detected