MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / l_strcmp

Function l_strcmp

Source/Misc/lua/src/lua.c:15032–15051  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15030
15031
15032static int l_strcmp (const TString *ls, const TString *rs) {
15033const char *l = getstr(ls);
15034size_t ll = ls->tsv.len;
15035const char *r = getstr(rs);
15036size_t lr = rs->tsv.len;
15037for (;;) {
15038int temp = strcoll(l, r);
15039if (temp != 0) return temp;
15040else { /* strings are equal up to a `\0' */
15041size_t len = strlen(l); /* index of first `\0' in both strings */
15042if (len == lr) /* r is finished? */
15043return (len == ll) ? 0 : 1;
15044else if (len == ll) /* l is finished? */
15045return -1; /* l is smaller than r (because r is not finished) */
15046/* both strings longer than `len'; go on comparing (after the `\0') */
15047len++;
15048l += len; ll -= len; r += len; lr -= len;
15049}
15050}
15051}
15052
15053
15054int 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