diff options
Diffstat (limited to '')
| -rw-r--r-- | lvm.c | 16 |
1 files changed, 8 insertions, 8 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 1.150 2001/01/10 17:41:50 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.151 2001/01/10 18:56:11 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 | */ |
| @@ -237,20 +237,20 @@ static void call_arith (lua_State *L, StkId top, TMS event) { | |||
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | 239 | ||
| 240 | static int luaV_strcomp (const TString *ls, const TString *rs) { | 240 | static int luaV_strlessthan (const TString *ls, const TString *rs) { |
| 241 | const char *l = ls->str; | 241 | const char *l = ls->str; |
| 242 | size_t ll = ls->len; | 242 | size_t ll = ls->len; |
| 243 | const char *r = rs->str; | 243 | const char *r = rs->str; |
| 244 | size_t lr = rs->len; | 244 | size_t lr = rs->len; |
| 245 | for (;;) { | 245 | for (;;) { |
| 246 | int temp = strcoll(l, r); | 246 | int temp = strcoll(l, r); |
| 247 | if (temp != 0) return temp; | 247 | if (temp != 0) return (temp < 0); |
| 248 | else { /* strings are equal up to a '\0' */ | 248 | else { /* strings are equal up to a '\0' */ |
| 249 | size_t len = strlen(l); /* index of first '\0' in both strings */ | 249 | size_t len = strlen(l); /* index of first '\0' in both strings */ |
| 250 | if (len == ll) /* l is finished? */ | 250 | if (len == lr) /* r is finished? */ |
| 251 | return (len == lr) ? 0 : -1; /* l is equal or smaller than r */ | 251 | return 0; /* l is equal or greater than r */ |
| 252 | else if (len == lr) /* r is finished? */ | 252 | else if (len == ll) /* l is finished? */ |
| 253 | return 1; /* l is greater than r (because l is not finished) */ | 253 | return 1; /* l is smaller than r (because r is not finished) */ |
| 254 | /* both strings longer than `len'; go on comparing (after the '\0') */ | 254 | /* both strings longer than `len'; go on comparing (after the '\0') */ |
| 255 | len++; | 255 | len++; |
| 256 | l += len; ll -= len; r += len; lr -= len; | 256 | l += len; ll -= len; r += len; lr -= len; |
| @@ -263,7 +263,7 @@ int luaV_lessthan (lua_State *L, const TObject *l, const TObject *r, StkId top) | |||
| 263 | if (ttype(l) == LUA_TNUMBER && ttype(r) == LUA_TNUMBER) | 263 | if (ttype(l) == LUA_TNUMBER && ttype(r) == LUA_TNUMBER) |
| 264 | return (nvalue(l) < nvalue(r)); | 264 | return (nvalue(l) < nvalue(r)); |
| 265 | else if (ttype(l) == LUA_TSTRING && ttype(r) == LUA_TSTRING) | 265 | else if (ttype(l) == LUA_TSTRING && ttype(r) == LUA_TSTRING) |
| 266 | return (luaV_strcomp(tsvalue(l), tsvalue(r)) < 0); | 266 | return luaV_strlessthan(tsvalue(l), tsvalue(r)); |
| 267 | else { /* call TM */ | 267 | else { /* call TM */ |
| 268 | luaD_checkstack(L, 2); | 268 | luaD_checkstack(L, 2); |
| 269 | *top++ = *l; | 269 | *top++ = *l; |
