MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / str_packsize

Function str_packsize

third-party/lua-5.5.0/src/lstrlib.c:1717–1735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1715
1716
1717static int str_packsize (lua_State *L) {
1718 Header h;
1719 const char *fmt = luaL_checkstring(L, 1); /* format string */
1720 size_t totalsize = 0; /* accumulate total size of result */
1721 initheader(L, &h);
1722 while (*fmt != '\0') {
1723 unsigned ntoalign;
1724 size_t size;
1725 KOption opt = getdetails(&h, totalsize, &fmt, &size, &ntoalign);
1726 luaL_argcheck(L, opt != Kstring && opt != Kzstr, 1,
1727 "variable-length format");
1728 size += ntoalign; /* total space used by option */
1729 luaL_argcheck(L, totalsize <= LUA_MAXINTEGER - size,
1730 1, "format result too large");
1731 totalsize += size;
1732 }
1733 lua_pushinteger(L, cast_st2S(totalsize));
1734 return 1;
1735}
1736
1737
1738/*

Callers

nothing calls this directly

Calls 3

initheaderFunction · 0.70
getdetailsFunction · 0.70
lua_pushintegerFunction · 0.70

Tested by

no test coverage detected