MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / l_strcmp

Function l_strcmp

lua/lvm.c:212–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210
211
212static int l_strcmp (const TString *ls, const TString *rs) {
213 const char *l = getstr(ls);
214 size_t ll = ls->tsv.len;
215 const char *r = getstr(rs);
216 size_t lr = rs->tsv.len;
217 for (;;) {
218 int temp = strcoll(l, r);
219 if (temp != 0) return temp;
220 else { /* strings are equal up to a `\0' */
221 size_t len = strlen(l); /* index of first `\0' in both strings */
222 if (len == lr) /* r is finished? */
223 return (len == ll) ? 0 : 1;
224 else if (len == ll) /* l is finished? */
225 return -1; /* l is smaller than r (because r is not finished) */
226 /* both strings longer than `len'; go on comparing (after the `\0') */
227 len++;
228 l += len; ll -= len; r += len; lr -= len;
229 }
230 }
231}
232
233
234/* COMDB2 MODIFICATION */

Callers 2

luaV_lessthanFunction · 0.85
lessequalFunction · 0.85

Calls 1

getstrFunction · 0.85

Tested by

no test coverage detected