MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaB_unpack

Function luaB_unpack

app/redis-6.2.6/deps/lua/src/lbaselib.c:342–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340
341
342static int luaB_unpack (lua_State *L) {
343 int i, e;
344 unsigned int n;
345 luaL_checktype(L, 1, LUA_TTABLE);
346 i = luaL_optint(L, 2, 1);
347 e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
348 if (i > e) return 0; /* empty range */
349 n = (unsigned int)e - (unsigned int)i; /* number of elements minus 1 */
350 if (n >= INT_MAX || !lua_checkstack(L, ++n))
351 return luaL_error(L, "too many results to unpack");
352 lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */
353 while (i++ < e) /* push arg[i + 1...e] */
354 lua_rawgeti(L, 1, i);
355 return n;
356}
357
358
359static int luaB_select (lua_State *L) {

Callers

nothing calls this directly

Calls 5

luaL_getnFunction · 0.85
luaL_checktypeFunction · 0.70
lua_checkstackFunction · 0.70
luaL_errorFunction · 0.70
lua_rawgetiFunction · 0.70

Tested by

no test coverage detected