| 226 | |
| 227 | |
| 228 | static int iter_aux (lua_State *L, int strict) { |
| 229 | size_t len; |
| 230 | const char *s = luaL_checklstring(L, 1, &len); |
| 231 | lua_Unsigned n = (lua_Unsigned)lua_tointeger(L, 2); |
| 232 | if (n < len) { |
| 233 | while (iscontp(s + n)) n++; /* go to next character */ |
| 234 | } |
| 235 | if (n >= len) /* (also handles original 'n' being negative) */ |
| 236 | return 0; /* no more codepoints */ |
| 237 | else { |
| 238 | l_uint32 code; |
| 239 | const char *next = utf8_decode(s + n, &code, strict); |
| 240 | if (next == NULL || iscontp(next)) |
| 241 | return luaL_error(L, MSGInvalid); |
| 242 | lua_pushinteger(L, l_castU2S(n + 1)); |
| 243 | lua_pushinteger(L, l_castU2S(code)); |
| 244 | return 2; |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | |
| 249 | static int iter_auxstrict (lua_State *L) { |
no test coverage detected