diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-18 10:36:14 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-18 10:36:14 -0300 |
| commit | ca41b43f53562e64abe433d6346d174c92548603 (patch) | |
| tree | 03f7a99f76359fc1e0bbc45fc13e579ff2aafabb /lvm.c | |
| parent | 3511e186cde4b78f268d17199d0f46fb3eaa9638 (diff) | |
| download | lua-ca41b43f53562e64abe433d6346d174c92548603.tar.gz lua-ca41b43f53562e64abe433d6346d174c92548603.tar.bz2 lua-ca41b43f53562e64abe433d6346d174c92548603.zip | |
type 'TString' refers directly to the structure inside the union
(union used only for size purposes)
Diffstat (limited to 'lvm.c')
| -rw-r--r-- | lvm.c | 14 |
1 files changed, 7 insertions, 7 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.217 2014/06/30 19:48:08 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.218 2014/07/17 12:30:53 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -262,9 +262,9 @@ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { | |||
| 262 | */ | 262 | */ |
| 263 | static int l_strcmp (const TString *ls, const TString *rs) { | 263 | static int l_strcmp (const TString *ls, const TString *rs) { |
| 264 | const char *l = getstr(ls); | 264 | const char *l = getstr(ls); |
| 265 | size_t ll = ls->tsv.len; | 265 | size_t ll = ls->len; |
| 266 | const char *r = getstr(rs); | 266 | const char *r = getstr(rs); |
| 267 | size_t lr = rs->tsv.len; | 267 | size_t lr = rs->len; |
| 268 | for (;;) { /* for each segment */ | 268 | for (;;) { /* for each segment */ |
| 269 | int temp = strcoll(l, r); | 269 | int temp = strcoll(l, r); |
| 270 | if (temp != 0) /* not equal? */ | 270 | if (temp != 0) /* not equal? */ |
| @@ -294,7 +294,7 @@ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { | |||
| 294 | else if (tofloat(l, &nl) && tofloat(r, &nr)) /* both are numbers? */ | 294 | else if (tofloat(l, &nl) && tofloat(r, &nr)) /* both are numbers? */ |
| 295 | return luai_numlt(nl, nr); | 295 | return luai_numlt(nl, nr); |
| 296 | else if (ttisstring(l) && ttisstring(r)) /* both are strings? */ | 296 | else if (ttisstring(l) && ttisstring(r)) /* both are strings? */ |
| 297 | return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; | 297 | return l_strcmp(tsvalue(l), tsvalue(r)) < 0; |
| 298 | else if ((res = luaT_callorderTM(L, l, r, TM_LT)) < 0) /* no metamethod? */ | 298 | else if ((res = luaT_callorderTM(L, l, r, TM_LT)) < 0) /* no metamethod? */ |
| 299 | luaG_ordererror(L, l, r); /* error */ | 299 | luaG_ordererror(L, l, r); /* error */ |
| 300 | return res; | 300 | return res; |
| @@ -312,7 +312,7 @@ int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) { | |||
| 312 | else if (tofloat(l, &nl) && tofloat(r, &nr)) /* both are numbers? */ | 312 | else if (tofloat(l, &nl) && tofloat(r, &nr)) /* both are numbers? */ |
| 313 | return luai_numle(nl, nr); | 313 | return luai_numle(nl, nr); |
| 314 | else if (ttisstring(l) && ttisstring(r)) /* both are strings? */ | 314 | else if (ttisstring(l) && ttisstring(r)) /* both are strings? */ |
| 315 | return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; | 315 | return l_strcmp(tsvalue(l), tsvalue(r)) <= 0; |
| 316 | else if ((res = luaT_callorderTM(L, l, r, TM_LE)) >= 0) /* first try `le' */ | 316 | else if ((res = luaT_callorderTM(L, l, r, TM_LE)) >= 0) /* first try `le' */ |
| 317 | return res; | 317 | return res; |
| 318 | else if ((res = luaT_callorderTM(L, r, l, TM_LT)) < 0) /* else try `lt' */ | 318 | else if ((res = luaT_callorderTM(L, r, l, TM_LT)) < 0) /* else try `lt' */ |
| @@ -345,8 +345,8 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) { | |||
| 345 | case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ | 345 | case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ |
| 346 | case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); | 346 | case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); |
| 347 | case LUA_TLCF: return fvalue(t1) == fvalue(t2); | 347 | case LUA_TLCF: return fvalue(t1) == fvalue(t2); |
| 348 | case LUA_TSHRSTR: return eqshrstr(rawtsvalue(t1), rawtsvalue(t2)); | 348 | case LUA_TSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2)); |
| 349 | case LUA_TLNGSTR: return luaS_eqlngstr(rawtsvalue(t1), rawtsvalue(t2)); | 349 | case LUA_TLNGSTR: return luaS_eqlngstr(tsvalue(t1), tsvalue(t2)); |
| 350 | case LUA_TUSERDATA: { | 350 | case LUA_TUSERDATA: { |
| 351 | if (uvalue(t1) == uvalue(t2)) return 1; | 351 | if (uvalue(t1) == uvalue(t2)) return 1; |
| 352 | else if (L == NULL) return 0; | 352 | else if (L == NULL) return 0; |
