MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / l_strcmp

Function l_strcmp

deps/lua/src/lvm.c:203–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201
202
203static 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
225int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {

Callers 2

luaV_lessthanFunction · 0.85
lessequalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected