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

Function iter_aux

third-party/lua-5.3.5/src/lutf8lib.c:201–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199
200
201static int iter_aux (lua_State *L) {
202 size_t len;
203 const char *s = luaL_checklstring(L, 1, &len);
204 lua_Integer n = lua_tointeger(L, 2) - 1;
205 if (n < 0) /* first iteration? */
206 n = 0; /* start from here */
207 else if (n < (lua_Integer)len) {
208 n++; /* skip current byte */
209 while (iscont(s + n)) n++; /* and its continuations */
210 }
211 if (n >= (lua_Integer)len)
212 return 0; /* no more codepoints */
213 else {
214 int code;
215 const char *next = utf8_decode(s + n, &code);
216 if (next == NULL || iscont(next))
217 return luaL_error(L, "invalid UTF-8 code");
218 lua_pushinteger(L, n + 1);
219 lua_pushinteger(L, code);
220 return 2;
221 }
222}
223
224
225static int iter_codes (lua_State *L) {

Callers

nothing calls this directly

Calls 5

luaL_checklstringFunction · 0.70
utf8_decodeFunction · 0.70
luaL_errorFunction · 0.70
lua_pushintegerFunction · 0.70
lua_tointegerFunction · 0.50

Tested by

no test coverage detected