This commit is contained in:
Roberto Ierusalimschy 2002-06-24 12:07:21 -03:00
parent ad41fc11eb
commit 922f36a05b
3 changed files with 20 additions and 19 deletions

View File

@ -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 ** Debug Interface
** See Copyright Notice in lua.h ** 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 *t1 = luaT_typenames[ttype(p1)];
const char *t2 = luaT_typenames[ttype(p2)]; const char *t2 = luaT_typenames[ttype(p2)];
if (t1[2] == t2[2]) if (t1[2] == t2[2])
luaG_runerror(L, "attempt to compare two %s values", t1); luaG_runerror(L, "attempt to compare two %s values", t1);
else else
luaG_runerror(L, "attempt to compare %s with %s", t1, t2); luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
return 0;
} }

View File

@ -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 ** Auxiliary functions from Debug Interface module
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -19,7 +19,7 @@
void luaG_typeerror (lua_State *L, const TObject *o, const char *opname); void luaG_typeerror (lua_State *L, const TObject *o, const char *opname);
void luaG_concaterror (lua_State *L, StkId p1, StkId p2); void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
void luaG_aritherror (lua_State *L, StkId p1, const TObject *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_runerror (lua_State *L, const char *fmt, ...);
void luaG_errormsg (lua_State *L, int internal); void luaG_errormsg (lua_State *L, int internal);
int luaG_checkcode (const Proto *pt); int luaG_checkcode (const Proto *pt);

28
lvm.c
View File

@ -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 ** Lua virtual machine
** See Copyright Notice in lua.h ** 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) { 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); 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; return luaV_strcmp(tsvalue(l), tsvalue(r)) < 0;
else { /* try TM */ else if (call_binTM(L, l, r, L->top, TM_LT))
if (!call_binTM(L, l, r, L->top, TM_LT))
luaG_ordererror(L, l, r);
return !l_isfalse(L->top); return !l_isfalse(L->top);
} return luaG_ordererror(L, l, r);
} }
static int luaV_lessequal (lua_State *L, const TObject *l, const TObject *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); 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; return luaV_strcmp(tsvalue(l), tsvalue(r)) <= 0;
else { /* try TM */ else if (call_binTM(L, l, r, L->top, TM_LE)) /* first try `le' */
if (call_binTM(L, l, r, L->top, TM_LE)) /* first try `le' */
return !l_isfalse(L->top); return !l_isfalse(L->top);
else if (!call_binTM(L, r, l, L->top, TM_LT)) /* else try `lt' */ else if (call_binTM(L, r, l, L->top, TM_LT)) /* else try `lt' */
luaG_ordererror(L, l, r);
return l_isfalse(L->top); return l_isfalse(L->top);
} return luaG_ordererror(L, l, r);
} }