Add tokens to the standard less-than comparison operator
This commit is contained in:
@@ -228,6 +228,8 @@ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
|
||||
return luai_numlt(L, nvalue(l), nvalue(r));
|
||||
else if (ttisstring(l) && ttisstring(r))
|
||||
return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
|
||||
else if (ttislightuserdata(l) && ttislightuserdata(r))
|
||||
return pvalue(l) < pvalue(r);
|
||||
else if ((res = call_orderTM(L, l, r, TM_LT)) < 0)
|
||||
luaG_ordererror(L, l, r);
|
||||
return res;
|
||||
@@ -240,6 +242,8 @@ int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) {
|
||||
return luai_numle(L, nvalue(l), nvalue(r));
|
||||
else if (ttisstring(l) && ttisstring(r))
|
||||
return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
|
||||
else if (ttislightuserdata(l) && ttislightuserdata(r))
|
||||
return pvalue(l) <= pvalue(r);
|
||||
else if ((res = call_orderTM(L, l, r, TM_LE)) >= 0) /* first try `le' */
|
||||
return res;
|
||||
else if ((res = call_orderTM(L, r, l, TM_LT)) < 0) /* else try `lt' */
|
||||
|
||||
Reference in New Issue
Block a user