MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / iter_aux

Function iter_aux

3rd/lua-5.4.3/src/lutf8lib.c:224–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222
223
224static int iter_aux (lua_State *L, int strict) {
225 size_t len;
226 const char *s = luaL_checklstring(L, 1, &len);
227 lua_Integer n = lua_tointeger(L, 2) - 1;
228 if (n < 0) /* first iteration? */
229 n = 0; /* start from here */
230 else if (n < (lua_Integer)len) {
231 n++; /* skip current byte */
232 while (iscont(s + n)) n++; /* and its continuations */
233 }
234 if (n >= (lua_Integer)len)
235 return 0; /* no more codepoints */
236 else {
237 utfint code;
238 const char *next = utf8_decode(s + n, &code, strict);
239 if (next == NULL)
240 return luaL_error(L, "invalid UTF-8 code");
241 lua_pushinteger(L, n + 1);
242 lua_pushinteger(L, code);
243 return 2;
244 }
245}
246
247
248static int iter_auxstrict (lua_State *L) {

Callers 2

iter_auxstrictFunction · 0.85
iter_auxlaxFunction · 0.85

Calls 4

luaL_checklstringFunction · 0.85
utf8_decodeFunction · 0.85
luaL_errorFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected