diff options
Diffstat (limited to '')
| -rw-r--r-- | src/3rdParty/lua/lutf8lib.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/3rdParty/lua/lutf8lib.c b/src/3rdParty/lua/lutf8lib.c index 901d985..e7bf098 100644 --- a/src/3rdParty/lua/lutf8lib.c +++ b/src/3rdParty/lua/lutf8lib.c | |||
| @@ -224,14 +224,11 @@ static int byteoffset (lua_State *L) { | |||
| 224 | static int iter_aux (lua_State *L, int strict) { | 224 | static int iter_aux (lua_State *L, int strict) { |
| 225 | size_t len; | 225 | size_t len; |
| 226 | const char *s = luaL_checklstring(L, 1, &len); | 226 | const char *s = luaL_checklstring(L, 1, &len); |
| 227 | lua_Integer n = lua_tointeger(L, 2) - 1; | 227 | lua_Unsigned n = (lua_Unsigned)lua_tointeger(L, 2); |
| 228 | if (n < 0) /* first iteration? */ | 228 | if (n < len) { |
| 229 | n = 0; /* start from here */ | 229 | while (iscont(s + n)) n++; /* skip continuation bytes */ |
| 230 | else if (n < (lua_Integer)len) { | ||
| 231 | n++; /* skip current byte */ | ||
| 232 | while (iscont(s + n)) n++; /* and its continuations */ | ||
| 233 | } | 230 | } |
| 234 | if (n >= (lua_Integer)len) | 231 | if (n >= len) /* (also handles original 'n' being negative) */ |
| 235 | return 0; /* no more codepoints */ | 232 | return 0; /* no more codepoints */ |
| 236 | else { | 233 | else { |
| 237 | utfint code; | 234 | utfint code; |
