diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-10-24 15:33:25 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-10-24 15:33:25 -0300 |
commit | 25a2dac2bcab84d1f1ce8c49b673b4a032a29a4a (patch) | |
tree | eba12d537560a58565ea14a70c8dae172be6f292 /ltable.c | |
parent | e3ce88c9e850b7e79751083014699c5eae1bff31 (diff) | |
download | lua-25a2dac2bcab84d1f1ce8c49b673b4a032a29a4a.tar.gz lua-25a2dac2bcab84d1f1ce8c49b673b4a032a29a4a.tar.bz2 lua-25a2dac2bcab84d1f1ce8c49b673b4a032a29a4a.zip |
Always use unsigned int for indexing table-arrays
Diffstat (limited to 'ltable.c')
-rw-r--r-- | ltable.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -951,7 +951,7 @@ lu_byte luaH_getint (Table *t, lua_Integer key, TValue *res) { | |||
951 | if (keyinarray(t, key)) { | 951 | if (keyinarray(t, key)) { |
952 | lu_byte tag = *getArrTag(t, key - 1); | 952 | lu_byte tag = *getArrTag(t, key - 1); |
953 | if (!tagisempty(tag)) | 953 | if (!tagisempty(tag)) |
954 | farr2val(t, key - 1, tag, res); | 954 | farr2val(t, cast_uint(key) - 1, tag, res); |
955 | return tag; | 955 | return tag; |
956 | } | 956 | } |
957 | else | 957 | else |
@@ -1062,7 +1062,7 @@ int luaH_psetint (Table *t, lua_Integer key, TValue *val) { | |||
1062 | if (keyinarray(t, key)) { | 1062 | if (keyinarray(t, key)) { |
1063 | lu_byte *tag = getArrTag(t, key - 1); | 1063 | lu_byte *tag = getArrTag(t, key - 1); |
1064 | if (!tagisempty(*tag) || checknoTM(t->metatable, TM_NEWINDEX)) { | 1064 | if (!tagisempty(*tag) || checknoTM(t->metatable, TM_NEWINDEX)) { |
1065 | fval2arr(t, key - 1, tag, val); | 1065 | fval2arr(t, cast_uint(key) - 1, tag, val); |
1066 | return HOK; /* success */ | 1066 | return HOK; /* success */ |
1067 | } | 1067 | } |
1068 | else | 1068 | else |
@@ -1118,7 +1118,7 @@ void luaH_finishset (lua_State *L, Table *t, const TValue *key, | |||
1118 | } | 1118 | } |
1119 | else { /* array entry */ | 1119 | else { /* array entry */ |
1120 | hres = ~hres; /* real index */ | 1120 | hres = ~hres; /* real index */ |
1121 | obj2arr(t, hres, value); | 1121 | obj2arr(t, cast_uint(hres), value); |
1122 | } | 1122 | } |
1123 | } | 1123 | } |
1124 | 1124 | ||
@@ -1140,7 +1140,7 @@ void luaH_set (lua_State *L, Table *t, const TValue *key, TValue *value) { | |||
1140 | */ | 1140 | */ |
1141 | void luaH_setint (lua_State *L, Table *t, lua_Integer key, TValue *value) { | 1141 | void luaH_setint (lua_State *L, Table *t, lua_Integer key, TValue *value) { |
1142 | if (keyinarray(t, key)) | 1142 | if (keyinarray(t, key)) |
1143 | obj2arr(t, key - 1, value); | 1143 | obj2arr(t, cast_uint(key) - 1, value); |
1144 | else { | 1144 | else { |
1145 | int ok = rawfinishnodeset(getintfromhash(t, key), value); | 1145 | int ok = rawfinishnodeset(getintfromhash(t, key), value); |
1146 | if (!ok) { | 1146 | if (!ok) { |