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

Function getendpos

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

** Gets an optional ending string position from argument 'arg', ** with default value 'def'. ** Negative means back from end: clip result to [0, len] */

Source from the content-addressed store, hash-verified

70** Negative means back from end: clip result to [0, len]
71*/
72static size_t getendpos (lua_State *L, int arg, lua_Integer def,
73 size_t len) {
74 lua_Integer pos = luaL_optinteger(L, arg, def);
75 if (pos > (lua_Integer)len)
76 return len;
77 else if (pos >= 0)
78 return (size_t)pos;
79 else if (pos < -(lua_Integer)len)
80 return 0;
81 else return len + (size_t)pos + 1;
82}
83
84
85static int str_sub (lua_State *L) {

Callers 2

str_subFunction · 0.70
str_byteFunction · 0.70

Calls 1

luaL_optintegerFunction · 0.70

Tested by

no test coverage detected