MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / str_packsize

Function str_packsize

extlibs/lua/src/lstrlib.c:1639–1656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1637
1638
1639static int str_packsize (lua_State *L) {
1640 Header h;
1641 const char *fmt = luaL_checkstring(L, 1); /* format string */
1642 size_t totalsize = 0; /* accumulate total size of result */
1643 initheader(L, &h);
1644 while (*fmt != '\0') {
1645 int size, ntoalign;
1646 KOption opt = getdetails(&h, totalsize, &fmt, &size, &ntoalign);
1647 luaL_argcheck(L, opt != Kstring && opt != Kzstr, 1,
1648 "variable-length format");
1649 size += ntoalign; /* total space used by option */
1650 luaL_argcheck(L, totalsize <= MAXSIZE - size, 1,
1651 "format result too large");
1652 totalsize += size;
1653 }
1654 lua_pushinteger(L, (lua_Integer)totalsize);
1655 return 1;
1656}
1657
1658
1659/*

Callers

nothing calls this directly

Calls 3

initheaderFunction · 0.85
getdetailsFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected