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

Function str_byte

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

Source from the content-addressed store, hash-verified

164
165
166static int str_byte (lua_State *L) {
167 size_t l;
168 const char *s = luaL_checklstring(L, 1, &l);
169 lua_Integer pi = luaL_optinteger(L, 2, 1);
170 size_t posi = posrelatI(pi, l);
171 size_t pose = getendpos(L, 3, pi, l);
172 int n, i;
173 if (posi > pose) return 0; /* empty interval; return no values */
174 if (l_unlikely(pose - posi >= (size_t)INT_MAX)) /* arithmetic overflow? */
175 return luaL_error(L, "string slice too long");
176 n = (int)(pose - posi) + 1;
177 luaL_checkstack(L, n, "string slice too long");
178 for (i=0; i<n; i++)
179 lua_pushinteger(L, cast_uchar(s[posi + cast_uint(i) - 1]));
180 return n;
181}
182
183
184static int str_char (lua_State *L) {

Callers

nothing calls this directly

Calls 7

luaL_checklstringFunction · 0.70
luaL_optintegerFunction · 0.70
posrelatIFunction · 0.70
getendposFunction · 0.70
luaL_errorFunction · 0.70
luaL_checkstackFunction · 0.70
lua_pushintegerFunction · 0.70

Tested by

no test coverage detected