| 1101 | } |
| 1102 | |
| 1103 | static int Lslice_leave(lua_State *L) { |
| 1104 | lpb_Slice *s = check_lslice(L, 1); |
| 1105 | lua_Integer count = posrelat(luaL_optinteger(L, 2, 1), s->used); |
| 1106 | if (count > (lua_Integer)s->used) |
| 1107 | argcheck(L, 0, 2, "level (%d) exceed max level %d", |
| 1108 | (int)count, (int)s->used); |
| 1109 | else if (count == (lua_Integer)s->used) { |
| 1110 | s->curr = s->buff[0]; |
| 1111 | s->used = 1; |
| 1112 | } else { |
| 1113 | s->used -= (size_t)count; |
| 1114 | s->curr = s->buff[s->used]; |
| 1115 | } |
| 1116 | lua_settop(L, 1); |
| 1117 | lua_pushinteger(L, s->used); |
| 1118 | return 2; |
| 1119 | } |
| 1120 | |
| 1121 | LUALIB_API int lpb_newslice(lua_State *L, const char *s, size_t len) { |
| 1122 | pb_Slice *ls = (pb_Slice*)lua_newuserdata(L, sizeof(pb_Slice)); |
nothing calls this directly
no test coverage detected