MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / str_sub

Function str_sub

Source/Misc/lua/src/lua.c:13720–13731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13718
13719
13720static int str_sub (lua_State *L) {
13721size_t l;
13722const char *s = luaL_checklstring(L, 1, &l);
13723ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l);
13724ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l);
13725if (start < 1) start = 1;
13726if (end > (ptrdiff_t)l) end = (ptrdiff_t)l;
13727if (start <= end)
13728lua_pushlstring(L, s+start-1, end-start+1);
13729else lua_pushliteral(L, "");
13730return 1;
13731}
13732
13733
13734static int str_reverse (lua_State *L) {

Callers

nothing calls this directly

Calls 5

luaL_checklstringFunction · 0.85
posrelatFunction · 0.85
luaL_checkintegerFunction · 0.85
luaL_optintegerFunction · 0.85
lua_pushlstringFunction · 0.85

Tested by

no test coverage detected