From 922f36a05b249739814c54142036dc81f23bc7a0 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 24 Jun 2002 12:07:21 -0300 Subject: [PATCH] details --- ldebug.c | 5 +++-- ldebug.h | 4 ++-- lvm.c | 30 +++++++++++++++--------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/ldebug.c b/ldebug.c index 2b7f566f..5123f77d 100644 --- a/ldebug.c +++ b/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 1.121 2002/06/18 17:10:43 roberto Exp roberto $ +** $Id: ldebug.c,v 1.122 2002/06/20 20:39:44 roberto Exp roberto $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -506,13 +506,14 @@ void luaG_aritherror (lua_State *L, StkId p1, const TObject *p2) { } -void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) { +int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) { const char *t1 = luaT_typenames[ttype(p1)]; const char *t2 = luaT_typenames[ttype(p2)]; if (t1[2] == t2[2]) luaG_runerror(L, "attempt to compare two %s values", t1); else luaG_runerror(L, "attempt to compare %s with %s", t1, t2); + return 0; } diff --git a/ldebug.h b/ldebug.h index cb168743..764b39a9 100644 --- a/ldebug.h +++ b/ldebug.h @@ -1,5 +1,5 @@ /* -** $Id: ldebug.h,v 1.21 2002/05/15 18:57:44 roberto Exp roberto $ +** $Id: ldebug.h,v 1.22 2002/06/18 15:19:27 roberto Exp roberto $ ** Auxiliary functions from Debug Interface module ** See Copyright Notice in lua.h */ @@ -19,7 +19,7 @@ void luaG_typeerror (lua_State *L, const TObject *o, const char *opname); void luaG_concaterror (lua_State *L, StkId p1, StkId p2); void luaG_aritherror (lua_State *L, StkId p1, const TObject *p2); -void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2); +int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2); void luaG_runerror (lua_State *L, const char *fmt, ...); void luaG_errormsg (lua_State *L, int internal); int luaG_checkcode (const Proto *pt); diff --git a/lvm.c b/lvm.c index f74ec12d..d61953fe 100644 --- a/lvm.c +++ b/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 1.241 2002/06/24 13:08:45 roberto Exp roberto $ +** $Id: lvm.c,v 1.242 2002/06/24 14:11:14 roberto Exp roberto $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -205,30 +205,30 @@ static int luaV_strcmp (const TString *ls, const TString *rs) { int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r) { - if (ttype(l) == LUA_TNUMBER && ttype(r) == LUA_TNUMBER) + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttype(l) == LUA_TNUMBER) return nvalue(l) < nvalue(r); - else if (ttype(l) == LUA_TSTRING && ttype(r) == LUA_TSTRING) + else if (ttype(l) == LUA_TSTRING) return luaV_strcmp(tsvalue(l), tsvalue(r)) < 0; - else { /* try TM */ - if (!call_binTM(L, l, r, L->top, TM_LT)) - luaG_ordererror(L, l, r); + else if (call_binTM(L, l, r, L->top, TM_LT)) return !l_isfalse(L->top); - } + return luaG_ordererror(L, l, r); } static int luaV_lessequal (lua_State *L, const TObject *l, const TObject *r) { - if (ttype(l) == LUA_TNUMBER && ttype(r) == LUA_TNUMBER) + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttype(l) == LUA_TNUMBER) return nvalue(l) <= nvalue(r); - else if (ttype(l) == LUA_TSTRING && ttype(r) == LUA_TSTRING) + else if (ttype(l) == LUA_TSTRING) return luaV_strcmp(tsvalue(l), tsvalue(r)) <= 0; - else { /* try TM */ - if (call_binTM(L, l, r, L->top, TM_LE)) /* first try `le' */ - return !l_isfalse(L->top); - else if (!call_binTM(L, r, l, L->top, TM_LT)) /* else try `lt' */ - luaG_ordererror(L, l, r); + else if (call_binTM(L, l, r, L->top, TM_LE)) /* first try `le' */ + return !l_isfalse(L->top); + else if (call_binTM(L, r, l, L->top, TM_LT)) /* else try `lt' */ return l_isfalse(L->top); - } + return luaG_ordererror(L, l, r); }