MCPcopy Create free account
hub / github.com/DFHack/dfhack / str_sub

Function str_sub

depends/lua/src/lstrlib.c:70–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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