From 06c5d3825f03eafc90b56d43f70f70048b785bc8 Mon Sep 17 00:00:00 2001 From: Roberto I Date: Wed, 20 Aug 2025 16:10:54 -0300 Subject: Removed code for compatibility with version 5.3 --- lstate.h | 4 ---- ltests.h | 1 - ltm.c | 16 ---------------- lua.h | 7 ------- luaconf.h | 27 +-------------------------- lvm.c | 6 ------ testes/api.lua | 3 ++- 7 files changed, 3 insertions(+), 61 deletions(-) diff --git a/lstate.h b/lstate.h index a4d5570c..20dc4d24 100644 --- a/lstate.h +++ b/lstate.h @@ -249,10 +249,6 @@ struct CallInfo { #define CIST_HOOKYIELD (CIST_TAIL << 1) /* function "called" a finalizer */ #define CIST_FIN (CIST_HOOKYIELD << 1) -#if defined(LUA_COMPAT_LT_LE) -/* using __lt for __le */ -#define CIST_LEQ (CIST_FIN << 1) -#endif #define get_nresults(cs) (cast_int((cs) & CIST_NRESULTS) - 1) diff --git a/ltests.h b/ltests.h index c825bdcf..305f5619 100644 --- a/ltests.h +++ b/ltests.h @@ -13,7 +13,6 @@ /* test Lua with compatibility code */ #define LUA_COMPAT_MATHLIB -#define LUA_COMPAT_LT_LE #undef LUA_COMPAT_GLOBAL diff --git a/ltm.c b/ltm.c index 8eca2d6e..d1a61a62 100644 --- a/ltm.c +++ b/ltm.c @@ -196,28 +196,12 @@ void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2, /* ** Calls an order tag method. -** For lessequal, LUA_COMPAT_LT_LE keeps compatibility with old -** behavior: if there is no '__le', try '__lt', based on l <= r iff -** !(r < l) (assuming a total order). If the metamethod yields during -** this substitution, the continuation has to know about it (to negate -** the result of rtop.p, event); /* try original event */ if (tag >= 0) /* found tag method? */ return !tagisfalse(tag); -#if defined(LUA_COMPAT_LT_LE) - else if (event == TM_LE) { - /* try '!(p2 < p1)' for '(p1 <= p2)' */ - L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ - tag = callbinTM(L, p2, p1, L->top.p, TM_LT); - L->ci->callstatus ^= CIST_LEQ; /* clear mark */ - if (tag >= 0) /* found tag method? */ - return tagisfalse(tag); - } -#endif luaG_ordererror(L, p1, p2); /* no metamethod found */ return 0; /* to avoid warnings */ } diff --git a/lua.h b/lua.h index 131a8fcb..ab473dc3 100644 --- a/lua.h +++ b/lua.h @@ -432,13 +432,6 @@ LUA_API void (lua_closeslot) (lua_State *L, int idx); ** compatibility macros ** =============================================================== */ -#if defined(LUA_COMPAT_APIINTCASTS) - -#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) -#define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is)) -#define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL) - -#endif #define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1) #define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1) diff --git a/luaconf.h b/luaconf.h index 0adc9c13..56d29165 100644 --- a/luaconf.h +++ b/luaconf.h @@ -361,36 +361,13 @@ #define LUA_COMPAT_GLOBAL -/* -@@ LUA_COMPAT_5_3 controls other macros for compatibility with Lua 5.3. -** You can define it to get all options, or change specific options -** to fit your specific needs. -*/ -#if defined(LUA_COMPAT_5_3) /* { */ - /* @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated ** functions in the mathematical library. ** (These functions were already officially removed in 5.3; ** nevertheless they are still available here.) */ -#define LUA_COMPAT_MATHLIB - -/* -@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for -** manipulating other integer types (lua_pushunsigned, lua_tounsigned, -** luaL_checkint, luaL_checklong, etc.) -** (These macros were also officially removed in 5.3, but they are still -** available here.) -*/ -#define LUA_COMPAT_APIINTCASTS - - -/* -@@ LUA_COMPAT_LT_LE controls the emulation of the '__le' metamethod -** using '__lt'. -*/ -#define LUA_COMPAT_LT_LE +/* #define LUA_COMPAT_MATHLIB */ /* @@ -407,8 +384,6 @@ #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) -#endif /* } */ - /* }================================================================== */ diff --git a/lvm.c b/lvm.c index 8ad4344a..a9de5cbc 100644 --- a/lvm.c +++ b/lvm.c @@ -861,12 +861,6 @@ void luaV_finishOp (lua_State *L) { case OP_EQ: { /* note that 'OP_EQI'/'OP_EQK' cannot yield */ int res = !l_isfalse(s2v(L->top.p - 1)); L->top.p--; -#if defined(LUA_COMPAT_LT_LE) - if (ci->callstatus & CIST_LEQ) { /* "<=" using "<" instead? */ - ci->callstatus ^= CIST_LEQ; /* clear mark */ - res = !res; /* negate result */ - } -#endif lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP); if (res != GETARG_k(inst)) /* condition failed? */ ci->u.l.savedpc++; /* skip jump instruction */ diff --git a/testes/api.lua b/testes/api.lua index b3791654..9855f541 100644 --- a/testes/api.lua +++ b/testes/api.lua @@ -246,7 +246,8 @@ assert(not T.testC("compare LT 1 4, return 1")) assert(not T.testC("compare LE 9 1, return 1")) assert(not T.testC("compare EQ 9 9, return 1")) -local b = {__lt = function (a,b) return a[1] < b[1] end} +local b = {__lt = function (a,b) return a[1] < b[1] end, + __le = function (a,b) return a[1] <= b[1] end} local a1,a3,a4 = setmetatable({1}, b), setmetatable({3}, b), setmetatable({4}, b) -- cgit v1.2.3-55-g6feb