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

Function str_sub

freebsd/contrib/openzfs/module/lua/lstrlib.c:63–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62
63static int str_sub (lua_State *L) {
64 size_t l;
65 const char *s = luaL_checklstring(L, 1, &l);
66 size_t start = posrelat(luaL_checkinteger(L, 2), l);
67 size_t end = posrelat(luaL_optinteger(L, 3, -1), l);
68 if (start < 1) start = 1;
69 if (end > l) end = l;
70 if (start <= end)
71 lua_pushlstring(L, s + start - 1, end - start + 1);
72 else lua_pushliteral(L, "");
73 return 1;
74}
75
76
77static int str_reverse (lua_State *L) {

Callers

nothing calls this directly

Calls 5

luaL_checklstringFunction · 0.70
posrelatFunction · 0.70
luaL_checkintegerFunction · 0.70
luaL_optintegerFunction · 0.70
lua_pushlstringFunction · 0.70

Tested by

no test coverage detected