| 201 | |
| 202 | |
| 203 | static int l_strcmp (const TString *ls, const TString *rs) { |
| 204 | const char *l = getstr(ls); |
| 205 | size_t ll = ls->tsv.len; |
| 206 | const char *r = getstr(rs); |
| 207 | size_t lr = rs->tsv.len; |
| 208 | for (;;) { |
| 209 | int temp = strcoll(l, r); |
| 210 | if (temp != 0) return temp; |
| 211 | else { /* strings are equal up to a `\0' */ |
| 212 | size_t len = strlen(l); /* index of first `\0' in both strings */ |
| 213 | if (len == lr) /* r is finished? */ |
| 214 | return (len == ll) ? 0 : 1; |
| 215 | else if (len == ll) /* l is finished? */ |
| 216 | return -1; /* l is smaller than r (because r is not finished) */ |
| 217 | /* both strings longer than `len'; go on comparing (after the `\0') */ |
| 218 | len++; |
| 219 | l += len; ll -= len; r += len; lr -= len; |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | |
| 225 | int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { |
no outgoing calls
no test coverage detected