diff options
-rw-r--r-- | lcode.c | 3 | ||||
-rw-r--r-- | ldebug.c | 2 | ||||
-rw-r--r-- | lvm.c | 9 |
3 files changed, 10 insertions, 4 deletions
@@ -1298,7 +1298,8 @@ static int validop (int op, TValue *v1, TValue *v2) { | |||
1298 | case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: | 1298 | case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: |
1299 | case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ | 1299 | case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ |
1300 | lua_Integer i; | 1300 | lua_Integer i; |
1301 | return (tointegerns(v1, &i) && tointegerns(v2, &i)); | 1301 | return (luaV_tointegerns(v1, &i, LUA_FLOORN2I) && |
1302 | luaV_tointegerns(v2, &i, LUA_FLOORN2I)); | ||
1302 | } | 1303 | } |
1303 | case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ | 1304 | case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ |
1304 | return (nvalue(v2) != 0); | 1305 | return (nvalue(v2) != 0); |
@@ -726,7 +726,7 @@ l_noret luaG_opinterror (lua_State *L, const TValue *p1, | |||
726 | */ | 726 | */ |
727 | l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2) { | 727 | l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2) { |
728 | lua_Integer temp; | 728 | lua_Integer temp; |
729 | if (!tointegerns(p1, &temp)) | 729 | if (!luaV_tointegerns(p1, &temp, LUA_FLOORN2I)) |
730 | p2 = p1; | 730 | p2 = p1; |
731 | luaG_runerror(L, "number%s has no integer representation", varinfo(L, p2)); | 731 | luaG_runerror(L, "number%s has no integer representation", varinfo(L, p2)); |
732 | } | 732 | } |
@@ -568,8 +568,13 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) { | |||
568 | if (ttype(t1) != ttype(t2) || ttype(t1) != LUA_TNUMBER) | 568 | if (ttype(t1) != ttype(t2) || ttype(t1) != LUA_TNUMBER) |
569 | return 0; /* only numbers can be equal with different variants */ | 569 | return 0; /* only numbers can be equal with different variants */ |
570 | else { /* two numbers with different variants */ | 570 | else { /* two numbers with different variants */ |
571 | lua_Integer i1, i2; /* compare them as integers */ | 571 | /* One of them is an integer. If the other does not have an |
572 | return (tointegerns(t1, &i1) && tointegerns(t2, &i2) && i1 == i2); | 572 | integer value, they cannot be equal; otherwise, compare their |
573 | integer values. */ | ||
574 | lua_Integer i1, i2; | ||
575 | return (luaV_tointegerns(t1, &i1, F2Ieq) && | ||
576 | luaV_tointegerns(t2, &i2, F2Ieq) && | ||
577 | i1 == i2); | ||
573 | } | 578 | } |
574 | } | 579 | } |
575 | /* values have same type and same variant */ | 580 | /* values have same type and same variant */ |