mirror of
https://github.com/lua/lua
synced 2025-05-04 03:08:15 +03:00
Always use unsigned int for indexing table-arrays
This commit is contained in:
parent
e3ce88c9e8
commit
25a2dac2bc
8
ltable.c
8
ltable.c
@ -951,7 +951,7 @@ lu_byte luaH_getint (Table *t, lua_Integer key, TValue *res) {
|
|||||||
if (keyinarray(t, key)) {
|
if (keyinarray(t, key)) {
|
||||||
lu_byte tag = *getArrTag(t, key - 1);
|
lu_byte tag = *getArrTag(t, key - 1);
|
||||||
if (!tagisempty(tag))
|
if (!tagisempty(tag))
|
||||||
farr2val(t, key - 1, tag, res);
|
farr2val(t, cast_uint(key) - 1, tag, res);
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1062,7 +1062,7 @@ int luaH_psetint (Table *t, lua_Integer key, TValue *val) {
|
|||||||
if (keyinarray(t, key)) {
|
if (keyinarray(t, key)) {
|
||||||
lu_byte *tag = getArrTag(t, key - 1);
|
lu_byte *tag = getArrTag(t, key - 1);
|
||||||
if (!tagisempty(*tag) || checknoTM(t->metatable, TM_NEWINDEX)) {
|
if (!tagisempty(*tag) || checknoTM(t->metatable, TM_NEWINDEX)) {
|
||||||
fval2arr(t, key - 1, tag, val);
|
fval2arr(t, cast_uint(key) - 1, tag, val);
|
||||||
return HOK; /* success */
|
return HOK; /* success */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1118,7 +1118,7 @@ void luaH_finishset (lua_State *L, Table *t, const TValue *key,
|
|||||||
}
|
}
|
||||||
else { /* array entry */
|
else { /* array entry */
|
||||||
hres = ~hres; /* real index */
|
hres = ~hres; /* real index */
|
||||||
obj2arr(t, hres, value);
|
obj2arr(t, cast_uint(hres), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1140,7 +1140,7 @@ void luaH_set (lua_State *L, Table *t, const TValue *key, TValue *value) {
|
|||||||
*/
|
*/
|
||||||
void luaH_setint (lua_State *L, Table *t, lua_Integer key, TValue *value) {
|
void luaH_setint (lua_State *L, Table *t, lua_Integer key, TValue *value) {
|
||||||
if (keyinarray(t, key))
|
if (keyinarray(t, key))
|
||||||
obj2arr(t, key - 1, value);
|
obj2arr(t, cast_uint(key) - 1, value);
|
||||||
else {
|
else {
|
||||||
int ok = rawfinishnodeset(getintfromhash(t, key), value);
|
int ok = rawfinishnodeset(getintfromhash(t, key), value);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
|
2
ltests.c
2
ltests.c
@ -1043,7 +1043,7 @@ static int table_query (lua_State *L) {
|
|||||||
}
|
}
|
||||||
else if (cast_uint(i) < asize) {
|
else if (cast_uint(i) < asize) {
|
||||||
lua_pushinteger(L, i);
|
lua_pushinteger(L, i);
|
||||||
arr2obj(t, i, s2v(L->top.p));
|
arr2obj(t, cast_uint(i), s2v(L->top.p));
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user