diff options
author | Li Jin <dragon-fly@qq.com> | 2021-11-02 11:17:58 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-11-02 11:17:58 +0800 |
commit | 827c3736f357e09168fc108e8e740c6425d37d9b (patch) | |
tree | 259f977bf7f4ebe0e397fe5e1b74e7fbb1b75e8e /src/3rdParty/lua/lutf8lib.c | |
parent | aed806476fe50899c0f01750175531ac41267b9d (diff) | |
download | yuescript-827c3736f357e09168fc108e8e740c6425d37d9b.tar.gz yuescript-827c3736f357e09168fc108e8e740c6425d37d9b.tar.bz2 yuescript-827c3736f357e09168fc108e8e740c6425d37d9b.zip |
fix a wrong code generating issue, update builtin Lua.
Diffstat (limited to 'src/3rdParty/lua/lutf8lib.c')
-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; |