MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / str_sub

Function str_sub

src/Chain/libraries/glua/lstrlib.cpp:69–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68
69static int str_sub(lua_State *L) {
70 size_t l;
71 const char *s = luaL_checklstring(L, 1, &l);
72 lua_Integer start = posrelat(luaL_checkinteger(L, 2), l);
73 lua_Integer end = posrelat(luaL_optinteger(L, 3, -1), l);
74 if (start < 1) start = 1;
75 if (end > (lua_Integer)l) end = l;
76 if (start <= end)
77 lua_pushlstring(L, s + start - 1, (size_t)(end - start) + 1);
78 else lua_pushliteral(L, "");
79 return 1;
80}
81
82
83static int str_reverse(lua_State *L) {

Callers

nothing calls this directly

Calls 3

luaL_checklstringFunction · 0.85
posrelatFunction · 0.85
lua_pushlstringFunction · 0.85

Tested by

no test coverage detected